Skip to content

Commit d409f95

Browse files
author
Erich Keane
committed
[NFC][SYCL] Fix some uses of stringref& and qualtype&
Identified elsewhere, these are a few cases of 'simple' types that are intended to be copied being passed around as const references. This patch just replaces them. Also, StringRefs for can be just llvm::StringLiteral for literals, since that does constexpr construction.
1 parent f110dd4 commit d409f95

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,34 @@ class Util {
7272

7373
/// Checks whether given clang type is a full specialization of the SYCL
7474
/// accessor class.
75-
static bool isSyclAccessorType(const QualType &Ty);
75+
static bool isSyclAccessorType(QualType Ty);
7676

7777
/// Checks whether given clang type is a full specialization of the SYCL
7878
/// sampler class.
79-
static bool isSyclSamplerType(const QualType &Ty);
79+
static bool isSyclSamplerType(QualType Ty);
8080

8181
/// Checks whether given clang type is a full specialization of the SYCL
8282
/// stream class.
83-
static bool isSyclStreamType(const QualType &Ty);
83+
static bool isSyclStreamType(QualType Ty);
8484

8585
/// Checks whether given clang type is a full specialization of the SYCL
8686
/// half class.
87-
static bool isSyclHalfType(const QualType &Ty);
87+
static bool isSyclHalfType(QualType Ty);
8888

8989
/// Checks whether given clang type is a full specialization of the SYCL
9090
/// accessor_property_list class.
91-
static bool isAccessorPropertyListType(const QualType &Ty);
91+
static bool isAccessorPropertyListType(QualType Ty);
9292

9393
/// Checks whether given clang type is a full specialization of the SYCL
9494
/// buffer_location class.
95-
static bool isSyclBufferLocationType(const QualType &Ty);
95+
static bool isSyclBufferLocationType(QualType Ty);
9696

9797
/// Checks whether given clang type is a standard SYCL API class with given
9898
/// name.
9999
/// \param Ty the clang type being checked
100100
/// \param Name the class name checked against
101101
/// \param Tmpl whether the class is template instantiation or simple record
102-
static bool isSyclType(const QualType &Ty, StringRef Name, bool Tmpl = false);
102+
static bool isSyclType(QualType Ty, StringRef Name, bool Tmpl = false);
103103

104104
/// Checks whether given function is a standard SYCL API function with given
105105
/// name.
@@ -109,11 +109,11 @@ class Util {
109109

110110
/// Checks whether given clang type is a full specialization of the SYCL
111111
/// specialization constant class.
112-
static bool isSyclSpecConstantType(const QualType &Ty);
112+
static bool isSyclSpecConstantType(QualType Ty);
113113

114114
/// Checks whether given clang type is a full specialization of the SYCL
115115
/// kernel_handler class.
116-
static bool isSyclKernelHandlerType(const QualType &Ty);
116+
static bool isSyclKernelHandlerType(QualType Ty);
117117

118118
// Checks declaration context hierarchy.
119119
/// \param DC the context of the item to be checked.
@@ -127,7 +127,7 @@ class Util {
127127
/// \param Ty the clang type being checked
128128
/// \param Scopes the declaration scopes leading from the type to the
129129
/// translation unit (excluding the latter)
130-
static bool matchQualifiedTypeName(const QualType &Ty,
130+
static bool matchQualifiedTypeName(QualType Ty,
131131
ArrayRef<Util::DeclContextDesc> Scopes);
132132
};
133133

@@ -1321,7 +1321,7 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
13211321
DiagnosticsEngine &Diag;
13221322
// Check whether the object should be disallowed from being copied to kernel.
13231323
// Return true if not copyable, false if copyable.
1324-
bool checkNotCopyableToKernel(const FieldDecl *FD, const QualType &FieldTy) {
1324+
bool checkNotCopyableToKernel(const FieldDecl *FD, QualType FieldTy) {
13251325
if (FieldTy->isArrayType()) {
13261326
if (const auto *CAT =
13271327
SemaRef.getASTContext().getAsConstantArrayType(FieldTy)) {
@@ -4305,20 +4305,16 @@ bool SYCLIntegrationFooter::emit(raw_ostream &O) {
43054305
// Utility class methods
43064306
// -----------------------------------------------------------------------------
43074307

4308-
bool Util::isSyclAccessorType(const QualType &Ty) {
4308+
bool Util::isSyclAccessorType(QualType Ty) {
43094309
return isSyclType(Ty, "accessor", true /*Tmpl*/);
43104310
}
43114311

4312-
bool Util::isSyclSamplerType(const QualType &Ty) {
4313-
return isSyclType(Ty, "sampler");
4314-
}
4312+
bool Util::isSyclSamplerType(QualType Ty) { return isSyclType(Ty, "sampler"); }
43154313

4316-
bool Util::isSyclStreamType(const QualType &Ty) {
4317-
return isSyclType(Ty, "stream");
4318-
}
4314+
bool Util::isSyclStreamType(QualType Ty) { return isSyclType(Ty, "stream"); }
43194315

4320-
bool Util::isSyclHalfType(const QualType &Ty) {
4321-
const StringRef &Name = "half";
4316+
bool Util::isSyclHalfType(QualType Ty) {
4317+
llvm::StringLiteral Name = "half";
43224318
std::array<DeclContextDesc, 5> Scopes = {
43234319
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
43244320
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
@@ -4328,8 +4324,8 @@ bool Util::isSyclHalfType(const QualType &Ty) {
43284324
return matchQualifiedTypeName(Ty, Scopes);
43294325
}
43304326

4331-
bool Util::isSyclSpecConstantType(const QualType &Ty) {
4332-
const StringRef &Name = "spec_constant";
4327+
bool Util::isSyclSpecConstantType(QualType Ty) {
4328+
llvm::StringLiteral Name = "spec_constant";
43334329
std::array<DeclContextDesc, 5> Scopes = {
43344330
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
43354331
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
@@ -4339,18 +4335,18 @@ bool Util::isSyclSpecConstantType(const QualType &Ty) {
43394335
return matchQualifiedTypeName(Ty, Scopes);
43404336
}
43414337

4342-
bool Util::isSyclKernelHandlerType(const QualType &Ty) {
4343-
const StringRef &Name = "kernel_handler";
4338+
bool Util::isSyclKernelHandlerType(QualType Ty) {
4339+
llvm::StringLiteral Name = "kernel_handler";
43444340
std::array<DeclContextDesc, 3> Scopes = {
43454341
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
43464342
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
43474343
Util::DeclContextDesc{Decl::Kind::CXXRecord, Name}};
43484344
return matchQualifiedTypeName(Ty, Scopes);
43494345
}
43504346

4351-
bool Util::isSyclBufferLocationType(const QualType &Ty) {
4352-
const StringRef &PropertyName = "buffer_location";
4353-
const StringRef &InstanceName = "instance";
4347+
bool Util::isSyclBufferLocationType(QualType Ty) {
4348+
llvm::StringLiteral PropertyName = "buffer_location";
4349+
llvm::StringLiteral InstanceName = "instance";
43544350
std::array<DeclContextDesc, 6> Scopes = {
43554351
Util::DeclContextDesc{Decl::Kind::Namespace, "cl"},
43564352
Util::DeclContextDesc{Decl::Kind::Namespace, "sycl"},
@@ -4362,7 +4358,7 @@ bool Util::isSyclBufferLocationType(const QualType &Ty) {
43624358
return matchQualifiedTypeName(Ty, Scopes);
43634359
}
43644360

4365-
bool Util::isSyclType(const QualType &Ty, StringRef Name, bool Tmpl) {
4361+
bool Util::isSyclType(QualType Ty, StringRef Name, bool Tmpl) {
43664362
Decl::Kind ClassDeclKind =
43674363
Tmpl ? Decl::Kind::ClassTemplateSpecialization : Decl::Kind::CXXRecord;
43684364
std::array<DeclContextDesc, 3> Scopes = {
@@ -4387,8 +4383,8 @@ bool Util::isSyclFunction(const FunctionDecl *FD, StringRef Name) {
43874383
return matchContext(DC, Scopes);
43884384
}
43894385

4390-
bool Util::isAccessorPropertyListType(const QualType &Ty) {
4391-
const StringRef &Name = "accessor_property_list";
4386+
bool Util::isAccessorPropertyListType(QualType Ty) {
4387+
llvm::StringLiteral Name = "accessor_property_list";
43924388
std::array<DeclContextDesc, 4> Scopes = {
43934389
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
43944390
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
@@ -4428,7 +4424,7 @@ bool Util::matchContext(const DeclContext *Ctx,
44284424
return Ctx->isTranslationUnit();
44294425
}
44304426

4431-
bool Util::matchQualifiedTypeName(const QualType &Ty,
4427+
bool Util::matchQualifiedTypeName(QualType Ty,
44324428
ArrayRef<Util::DeclContextDesc> Scopes) {
44334429
const CXXRecordDecl *RecTy = Ty->getAsCXXRecordDecl();
44344430

0 commit comments

Comments
 (0)