Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) {
.Default(InvokeUnknown);
}

static CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) {
static const CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) {
return (*Caller->param_begin())->getType()->getAsCXXRecordDecl();
}

Expand Down Expand Up @@ -878,12 +878,12 @@ class KernelObjVisitor {
}

template <typename ParentTy, typename... Handlers>
void VisitRecord(CXXRecordDecl *Owner, ParentTy &Parent,
CXXRecordDecl *Wrapper, Handlers &... handlers);
void VisitRecord(const CXXRecordDecl *Owner, ParentTy &Parent,
const CXXRecordDecl *Wrapper, Handlers &... handlers);

template <typename... Handlers>
void VisitRecordHelper(CXXRecordDecl *Owner,
clang::CXXRecordDecl::base_class_range Range,
void VisitRecordHelper(const CXXRecordDecl *Owner,
clang::CXXRecordDecl::base_class_const_range Range,
Handlers &... handlers) {
for (const auto &Base : Range) {
(void)std::initializer_list<int>{
Expand All @@ -906,15 +906,15 @@ class KernelObjVisitor {
}

template <typename... Handlers>
void VisitRecordHelper(CXXRecordDecl *Owner,
clang::RecordDecl::field_range Range,
void VisitRecordHelper(const CXXRecordDecl *Owner,
RecordDecl::field_range Range,
Handlers &... handlers) {
VisitRecordFields(Owner, handlers...);
}

// FIXME: Can this be refactored/handled some other way?
template <typename ParentTy, typename... Handlers>
void VisitStreamRecord(CXXRecordDecl *Owner, ParentTy &Parent,
void VisitStreamRecord(const CXXRecordDecl *Owner, ParentTy &Parent,
CXXRecordDecl *Wrapper, Handlers &... handlers) {
(void)std::initializer_list<int>{
(handlers.enterStruct(Owner, Parent), 0)...};
Expand All @@ -933,14 +933,15 @@ class KernelObjVisitor {
}

template <typename... Handlers>
void VisitRecordBases(CXXRecordDecl *KernelFunctor, Handlers &... handlers) {
void VisitRecordBases(const CXXRecordDecl *KernelFunctor,
Handlers &... handlers) {
VisitRecordHelper(KernelFunctor, KernelFunctor->bases(), handlers...);
}

// A visitor function that dispatches to functions as defined in
// SyclKernelFieldHandler for the purposes of kernel generation.
template <typename... Handlers>
void VisitRecordFields(CXXRecordDecl *Owner, Handlers &... handlers) {
void VisitRecordFields(const CXXRecordDecl *Owner, Handlers &... handlers) {

for (const auto Field : Owner->fields()) {
(void)std::initializer_list<int>{
Expand Down Expand Up @@ -987,8 +988,8 @@ class KernelObjVisitor {
// type (which doesn't exist in cases where it is a FieldDecl in the
// 'root'), and Wrapper is the current struct being unwrapped.
template <typename ParentTy, typename... Handlers>
void KernelObjVisitor::VisitRecord(CXXRecordDecl *Owner, ParentTy &Parent,
CXXRecordDecl *Wrapper,
void KernelObjVisitor::VisitRecord(const CXXRecordDecl *Owner, ParentTy &Parent,
const CXXRecordDecl *Wrapper,
Handlers &... handlers) {
(void)std::initializer_list<int>{(handlers.enterStruct(Owner, Parent), 0)...};
VisitRecordHelper(Wrapper, Wrapper->bases(), handlers...);
Expand Down Expand Up @@ -1357,7 +1358,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
llvm::SmallVector<Expr *, 16> InitExprs;
VarDecl *KernelObjClone;
InitializedEntity VarEntity;
CXXRecordDecl *KernelObj;
const CXXRecordDecl *KernelObj;
llvm::SmallVector<Expr *, 16> MemberExprBases;
uint64_t ArrayIndex;
FunctionDecl *KernelCallerFunc;
Expand Down Expand Up @@ -1524,7 +1525,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
// FIXME Avoid creation of kernel obj clone.
// See https://github.com/intel/llvm/issues/1544 for details.
static VarDecl *createKernelObjClone(ASTContext &Ctx, DeclContext *DC,
CXXRecordDecl *KernelObj) {
const CXXRecordDecl *KernelObj) {
TypeSourceInfo *TSInfo =
KernelObj->isLambda() ? KernelObj->getLambdaTypeInfo() : nullptr;
VarDecl *VD = VarDecl::Create(
Expand Down Expand Up @@ -1572,7 +1573,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {

public:
SyclKernelBodyCreator(Sema &S, SyclKernelDeclCreator &DC,
CXXRecordDecl *KernelObj,
const CXXRecordDecl *KernelObj,
FunctionDecl *KernelCallerFunc)
: SyclKernelFieldHandler(S), DeclCreator(DC),
KernelObjClone(createKernelObjClone(S.getASTContext(),
Expand Down Expand Up @@ -1934,7 +1935,7 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
MangleContext &MC) {
// The first argument to the KernelCallerFunc is the lambda object.
CXXRecordDecl *KernelObj = getKernelObjectType(KernelCallerFunc);
const CXXRecordDecl *KernelObj = getKernelObjectType(KernelCallerFunc);
assert(KernelObj && "invalid kernel caller");

// Calculate both names, since Integration headers need both.
Expand Down