Skip to content

Commit

Permalink
[SYCL][NFC] Rename KernelLambda to KernelObj (#2031)
Browse files Browse the repository at this point in the history
These variables can also represent a function object, so they have
CXXRecordDecl type and the name KernelLambda is confusing and
incorrect in this case.
  • Loading branch information
Fznamznon authored Jul 2, 2020
1 parent 95d3ec6 commit eaf3396
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ class SyclKernelBodyCreator
class SyclKernelIntHeaderCreator
: public SyclKernelFieldHandler<SyclKernelIntHeaderCreator> {
SYCLIntegrationHeader &Header;
const CXXRecordDecl *KernelLambda;
const CXXRecordDecl *KernelObj;
// Necessary to figure out the offset of the base class.
const CXXRecordDecl *CurStruct = nullptr;
int64_t CurOffset = 0;
Expand All @@ -1608,11 +1608,10 @@ class SyclKernelIntHeaderCreator

public:
SyclKernelIntHeaderCreator(Sema &S, SYCLIntegrationHeader &H,
const CXXRecordDecl *KernelLambda,
QualType NameType, StringRef Name,
StringRef StableName)
: SyclKernelFieldHandler(S), Header(H), KernelLambda(KernelLambda) {
Header.startKernel(Name, NameType, StableName, KernelLambda->getLocation());
const CXXRecordDecl *KernelObj, QualType NameType,
StringRef Name, StringRef StableName)
: SyclKernelFieldHandler(S), Header(H), KernelObj(KernelObj) {
Header.startKernel(Name, NameType, StableName, KernelObj->getLocation());
}

bool handleSyclAccessorType(const CXXBaseSpecifier &BC,
Expand Down Expand Up @@ -1773,8 +1772,8 @@ class SyclKernelIntHeaderCreator
void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
MangleContext &MC) {
// The first argument to the KernelCallerFunc is the lambda object.
CXXRecordDecl *KernelLambda = getKernelObjectType(KernelCallerFunc);
assert(KernelLambda && "invalid kernel caller");
CXXRecordDecl *KernelObj = getKernelObjectType(KernelCallerFunc);
assert(KernelObj && "invalid kernel caller");

// Calculate both names, since Integration headers need both.
std::string CalculatedName, StableName;
Expand All @@ -1784,17 +1783,17 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
: CalculatedName);
SyclKernelFieldChecker checker(*this);
SyclKernelDeclCreator kernel_decl(
*this, checker, KernelName, KernelLambda->getLocation(),
*this, checker, KernelName, KernelObj->getLocation(),
KernelCallerFunc->isInlined(), KernelCallerFunc->hasAttr<SYCLSimdAttr>());
SyclKernelBodyCreator kernel_body(*this, kernel_decl, KernelLambda,
SyclKernelBodyCreator kernel_body(*this, kernel_decl, KernelObj,
KernelCallerFunc);
SyclKernelIntHeaderCreator int_header(
*this, getSyclIntegrationHeader(), KernelLambda,
*this, getSyclIntegrationHeader(), KernelObj,
calculateKernelNameType(Context, KernelCallerFunc), KernelName,
StableName);

ConstructingOpenCLKernel = true;
VisitRecordFields(KernelLambda->fields(), checker, kernel_decl, kernel_body,
VisitRecordFields(KernelObj->fields(), checker, kernel_decl, kernel_body,
int_header);
ConstructingOpenCLKernel = false;
}
Expand Down

0 comments on commit eaf3396

Please sign in to comment.