@@ -68,38 +68,49 @@ namespace {
68
68
// / Various utilities.
69
69
class Util {
70
70
public:
71
- using DeclContextDesc = std::pair<clang::Decl::Kind, StringRef>;
71
+ using DeclContextDesc = std::pair<Decl::Kind, StringRef>;
72
+
73
+ template <size_t N>
74
+ static constexpr DeclContextDesc MakeDeclContextDesc (Decl::Kind K,
75
+ const char (&Str)[N]) {
76
+ return DeclContextDesc{K, llvm::StringLiteral{Str}};
77
+ }
78
+
79
+ static constexpr DeclContextDesc MakeDeclContextDesc (Decl::Kind K,
80
+ StringRef SR) {
81
+ return DeclContextDesc{K, SR};
82
+ }
72
83
73
84
// / Checks whether given clang type is a full specialization of the SYCL
74
85
// / accessor class.
75
- static bool isSyclAccessorType (const QualType & Ty);
86
+ static bool isSyclAccessorType (QualType Ty);
76
87
77
88
// / Checks whether given clang type is a full specialization of the SYCL
78
89
// / sampler class.
79
- static bool isSyclSamplerType (const QualType & Ty);
90
+ static bool isSyclSamplerType (QualType Ty);
80
91
81
92
// / Checks whether given clang type is a full specialization of the SYCL
82
93
// / stream class.
83
- static bool isSyclStreamType (const QualType & Ty);
94
+ static bool isSyclStreamType (QualType Ty);
84
95
85
96
// / Checks whether given clang type is a full specialization of the SYCL
86
97
// / half class.
87
- static bool isSyclHalfType (const QualType & Ty);
98
+ static bool isSyclHalfType (QualType Ty);
88
99
89
100
// / Checks whether given clang type is a full specialization of the SYCL
90
101
// / accessor_property_list class.
91
- static bool isAccessorPropertyListType (const QualType & Ty);
102
+ static bool isAccessorPropertyListType (QualType Ty);
92
103
93
104
// / Checks whether given clang type is a full specialization of the SYCL
94
105
// / buffer_location class.
95
- static bool isSyclBufferLocationType (const QualType & Ty);
106
+ static bool isSyclBufferLocationType (QualType Ty);
96
107
97
108
// / Checks whether given clang type is a standard SYCL API class with given
98
109
// / name.
99
110
// / \param Ty the clang type being checked
100
111
// / \param Name the class name checked against
101
112
// / \param Tmpl whether the class is template instantiation or simple record
102
- static bool isSyclType (const QualType & Ty, StringRef Name, bool Tmpl = false );
113
+ static bool isSyclType (QualType Ty, StringRef Name, bool Tmpl = false );
103
114
104
115
// / Checks whether given function is a standard SYCL API function with given
105
116
// / name.
@@ -109,11 +120,11 @@ class Util {
109
120
110
121
// / Checks whether given clang type is a full specialization of the SYCL
111
122
// / specialization constant class.
112
- static bool isSyclSpecConstantType (const QualType & Ty);
123
+ static bool isSyclSpecConstantType (QualType Ty);
113
124
114
125
// / Checks whether given clang type is a full specialization of the SYCL
115
126
// / kernel_handler class.
116
- static bool isSyclKernelHandlerType (const QualType & Ty);
127
+ static bool isSyclKernelHandlerType (QualType Ty);
117
128
118
129
// Checks declaration context hierarchy.
119
130
// / \param DC the context of the item to be checked.
@@ -127,7 +138,7 @@ class Util {
127
138
// / \param Ty the clang type being checked
128
139
// / \param Scopes the declaration scopes leading from the type to the
129
140
// / translation unit (excluding the latter)
130
- static bool matchQualifiedTypeName (const QualType & Ty,
141
+ static bool matchQualifiedTypeName (QualType Ty,
131
142
ArrayRef<Util::DeclContextDesc> Scopes);
132
143
};
133
144
@@ -1321,7 +1332,7 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1321
1332
DiagnosticsEngine &Diag;
1322
1333
// Check whether the object should be disallowed from being copied to kernel.
1323
1334
// Return true if not copyable, false if copyable.
1324
- bool checkNotCopyableToKernel (const FieldDecl *FD, const QualType & FieldTy) {
1335
+ bool checkNotCopyableToKernel (const FieldDecl *FD, QualType FieldTy) {
1325
1336
if (FieldTy->isArrayType ()) {
1326
1337
if (const auto *CAT =
1327
1338
SemaRef.getASTContext ().getAsConstantArrayType (FieldTy)) {
@@ -4305,70 +4316,62 @@ bool SYCLIntegrationFooter::emit(raw_ostream &O) {
4305
4316
// Utility class methods
4306
4317
// -----------------------------------------------------------------------------
4307
4318
4308
- bool Util::isSyclAccessorType (const QualType & Ty) {
4319
+ bool Util::isSyclAccessorType (QualType Ty) {
4309
4320
return isSyclType (Ty, " accessor" , true /* Tmpl*/ );
4310
4321
}
4311
4322
4312
- bool Util::isSyclSamplerType (const QualType &Ty) {
4313
- return isSyclType (Ty, " sampler" );
4314
- }
4323
+ bool Util::isSyclSamplerType (QualType Ty) { return isSyclType (Ty, " sampler" ); }
4315
4324
4316
- bool Util::isSyclStreamType (const QualType &Ty) {
4317
- return isSyclType (Ty, " stream" );
4318
- }
4325
+ bool Util::isSyclStreamType (QualType Ty) { return isSyclType (Ty, " stream" ); }
4319
4326
4320
- bool Util::isSyclHalfType (const QualType &Ty) {
4321
- const StringRef &Name = " half" ;
4327
+ bool Util::isSyclHalfType (QualType Ty) {
4322
4328
std::array<DeclContextDesc, 5 > Scopes = {
4323
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " cl" } ,
4324
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " sycl" } ,
4325
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " detail" } ,
4326
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " half_impl" } ,
4327
- Util::DeclContextDesc{ Decl::Kind::CXXRecord, Name} };
4329
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " cl" ) ,
4330
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " sycl" ) ,
4331
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " detail" ) ,
4332
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " half_impl" ) ,
4333
+ Util::MakeDeclContextDesc ( Decl::Kind::CXXRecord, " half " ) };
4328
4334
return matchQualifiedTypeName (Ty, Scopes);
4329
4335
}
4330
4336
4331
- bool Util::isSyclSpecConstantType (const QualType &Ty) {
4332
- const StringRef &Name = " spec_constant" ;
4337
+ bool Util::isSyclSpecConstantType (QualType Ty) {
4333
4338
std::array<DeclContextDesc, 5 > Scopes = {
4334
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " cl" },
4335
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " sycl" },
4336
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " ONEAPI" },
4337
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " experimental" },
4338
- Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
4339
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " cl" ),
4340
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " sycl" ),
4341
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " ONEAPI" ),
4342
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " experimental" ),
4343
+ Util::MakeDeclContextDesc (Decl::Kind::ClassTemplateSpecialization,
4344
+ " spec_constant" )};
4339
4345
return matchQualifiedTypeName (Ty, Scopes);
4340
4346
}
4341
4347
4342
- bool Util::isSyclKernelHandlerType (const QualType &Ty) {
4343
- const StringRef &Name = " kernel_handler" ;
4348
+ bool Util::isSyclKernelHandlerType (QualType Ty) {
4344
4349
std::array<DeclContextDesc, 3 > Scopes = {
4345
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " cl" } ,
4346
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " sycl" } ,
4347
- Util::DeclContextDesc{ Decl::Kind::CXXRecord, Name} };
4350
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " cl" ) ,
4351
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " sycl" ) ,
4352
+ Util::MakeDeclContextDesc ( Decl::Kind::CXXRecord, " kernel_handler " ) };
4348
4353
return matchQualifiedTypeName (Ty, Scopes);
4349
4354
}
4350
4355
4351
- bool Util::isSyclBufferLocationType (const QualType &Ty) {
4352
- const StringRef &PropertyName = " buffer_location" ;
4353
- const StringRef &InstanceName = " instance" ;
4356
+ bool Util::isSyclBufferLocationType (QualType Ty) {
4354
4357
std::array<DeclContextDesc, 6 > Scopes = {
4355
- Util::DeclContextDesc{ Decl::Kind::Namespace, " cl" } ,
4356
- Util::DeclContextDesc{ Decl::Kind::Namespace, " sycl" } ,
4357
- Util::DeclContextDesc{ Decl::Kind::Namespace, " INTEL" } ,
4358
- Util::DeclContextDesc{ Decl::Kind::Namespace, " property" } ,
4359
- Util::DeclContextDesc{ Decl::Kind::CXXRecord, PropertyName} ,
4360
- Util::DeclContextDesc{ Decl::Kind::ClassTemplateSpecialization,
4361
- InstanceName} };
4358
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " cl" ) ,
4359
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " sycl" ) ,
4360
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " INTEL" ) ,
4361
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " property" ) ,
4362
+ Util::MakeDeclContextDesc ( Decl::Kind::CXXRecord, " buffer_location " ) ,
4363
+ Util::MakeDeclContextDesc ( Decl::Kind::ClassTemplateSpecialization,
4364
+ " instance " ) };
4362
4365
return matchQualifiedTypeName (Ty, Scopes);
4363
4366
}
4364
4367
4365
- bool Util::isSyclType (const QualType & Ty, StringRef Name, bool Tmpl) {
4368
+ bool Util::isSyclType (QualType Ty, StringRef Name, bool Tmpl) {
4366
4369
Decl::Kind ClassDeclKind =
4367
4370
Tmpl ? Decl::Kind::ClassTemplateSpecialization : Decl::Kind::CXXRecord;
4368
4371
std::array<DeclContextDesc, 3 > Scopes = {
4369
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " cl" } ,
4370
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " sycl" } ,
4371
- Util::DeclContextDesc{ ClassDeclKind, Name} };
4372
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " cl" ) ,
4373
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " sycl" ) ,
4374
+ Util::MakeDeclContextDesc ( ClassDeclKind, Name) };
4372
4375
return matchQualifiedTypeName (Ty, Scopes);
4373
4376
}
4374
4377
@@ -4382,18 +4385,18 @@ bool Util::isSyclFunction(const FunctionDecl *FD, StringRef Name) {
4382
4385
return false ;
4383
4386
4384
4387
std::array<DeclContextDesc, 2 > Scopes = {
4385
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " cl" } ,
4386
- Util::DeclContextDesc{clang:: Decl::Kind::Namespace, " sycl" } };
4388
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " cl" ) ,
4389
+ Util::MakeDeclContextDesc ( Decl::Kind::Namespace, " sycl" ) };
4387
4390
return matchContext (DC, Scopes);
4388
4391
}
4389
4392
4390
- bool Util::isAccessorPropertyListType (const QualType &Ty) {
4391
- const StringRef &Name = " accessor_property_list" ;
4393
+ bool Util::isAccessorPropertyListType (QualType Ty) {
4392
4394
std::array<DeclContextDesc, 4 > Scopes = {
4393
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " cl" },
4394
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " sycl" },
4395
- Util::DeclContextDesc{clang::Decl::Kind::Namespace, " ONEAPI" },
4396
- Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
4395
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " cl" ),
4396
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " sycl" ),
4397
+ Util::MakeDeclContextDesc (Decl::Kind::Namespace, " ONEAPI" ),
4398
+ Util::MakeDeclContextDesc (Decl::Kind::ClassTemplateSpecialization,
4399
+ " accessor_property_list" )};
4397
4400
return matchQualifiedTypeName (Ty, Scopes);
4398
4401
}
4399
4402
@@ -4405,17 +4408,17 @@ bool Util::matchContext(const DeclContext *Ctx,
4405
4408
StringRef Name = " " ;
4406
4409
4407
4410
for (const auto &Scope : llvm::reverse (Scopes)) {
4408
- clang:: Decl::Kind DK = Ctx->getDeclKind ();
4411
+ Decl::Kind DK = Ctx->getDeclKind ();
4409
4412
if (DK != Scope.first )
4410
4413
return false ;
4411
4414
4412
4415
switch (DK) {
4413
- case clang:: Decl::Kind::ClassTemplateSpecialization:
4416
+ case Decl::Kind::ClassTemplateSpecialization:
4414
4417
// ClassTemplateSpecializationDecl inherits from CXXRecordDecl
4415
- case clang:: Decl::Kind::CXXRecord:
4418
+ case Decl::Kind::CXXRecord:
4416
4419
Name = cast<CXXRecordDecl>(Ctx)->getName ();
4417
4420
break ;
4418
- case clang:: Decl::Kind::Namespace:
4421
+ case Decl::Kind::Namespace:
4419
4422
Name = cast<NamespaceDecl>(Ctx)->getName ();
4420
4423
break ;
4421
4424
default :
@@ -4428,7 +4431,7 @@ bool Util::matchContext(const DeclContext *Ctx,
4428
4431
return Ctx->isTranslationUnit ();
4429
4432
}
4430
4433
4431
- bool Util::matchQualifiedTypeName (const QualType & Ty,
4434
+ bool Util::matchQualifiedTypeName (QualType Ty,
4432
4435
ArrayRef<Util::DeclContextDesc> Scopes) {
4433
4436
const CXXRecordDecl *RecTy = Ty->getAsCXXRecordDecl ();
4434
4437
0 commit comments