@@ -84,7 +84,7 @@ class KernelBodyTransform : public TreeTransform<KernelBodyTransform> {
84
84
Sema &SemaRef;
85
85
};
86
86
87
- CXXRecordDecl* getBodyAsLambda (FunctionDecl *FD) {
87
+ CXXRecordDecl * getBodyAsLambda (FunctionDecl *FD) {
88
88
auto FirstArg = (*FD->param_begin ());
89
89
if (FirstArg)
90
90
if (FirstArg->getType ()->getAsCXXRecordDecl ()->isLambda ())
@@ -215,19 +215,18 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
215
215
// to replace all refs to this lambda with our vardecl.
216
216
// I used TreeTransform here, but I'm not sure that it is good solution
217
217
// Also I used map and I'm not sure about it too.
218
- Stmt* FunctionBody = KernelHelper->getBody ();
218
+ Stmt * FunctionBody = KernelHelper->getBody ();
219
219
DeclMap DMap;
220
- ParmVarDecl* LambdaParam = *(KernelHelper->param_begin ());
220
+ ParmVarDecl * LambdaParam = *(KernelHelper->param_begin ());
221
221
// DeclRefExpr with valid source location but with decl which is not marked
222
222
// as used is invalid.
223
223
LambdaVD->setIsUsed ();
224
224
DMap[LambdaParam] = LambdaVD;
225
225
// Without PushFunctionScope I had segfault. Maybe we also need to do pop.
226
226
S.PushFunctionScope ();
227
227
KernelBodyTransform KBT (DMap, S);
228
- Stmt* NewBody = KBT.TransformStmt (FunctionBody).get ();
228
+ Stmt * NewBody = KBT.TransformStmt (FunctionBody).get ();
229
229
BodyStmts.push_back (NewBody);
230
-
231
230
}
232
231
return CompoundStmt::Create (S.Context , BodyStmts, SourceLocation (),
233
232
SourceLocation ());
@@ -323,11 +322,19 @@ void Sema::ConstructSYCLKernel(FunctionDecl *KernelHelper) {
323
322
Name += " _" + ParamType.getAsString () + " _" ;
324
323
}
325
324
}
325
+ const std::string ToBeErased[2 ] = {" class " , " struct " };
326
+ for (size_t i = 0 ; i < 2 ; ++i) {
327
+ for (size_t pos = Name.find (ToBeErased[i]); pos != std::string::npos;
328
+ pos = Name.find (ToBeErased[i])) {
329
+ Name.erase (pos, ToBeErased[i].length ());
330
+ }
331
+ }
326
332
327
333
FunctionDecl *SYCLKernel =
328
334
CreateSYCLKernelFunction (getASTContext (), Name, ArgTys, NewArgDecls);
329
335
330
- CompoundStmt *SYCLKernelBody = CreateSYCLKernelBody (*this , KernelHelper, SYCLKernel);
336
+ CompoundStmt *SYCLKernelBody =
337
+ CreateSYCLKernelBody (*this , KernelHelper, SYCLKernel);
331
338
SYCLKernel->setBody (SYCLKernelBody);
332
339
333
340
AddSyclKernel (SYCLKernel);
@@ -337,4 +344,3 @@ void Sema::ConstructSYCLKernel(FunctionDecl *KernelHelper) {
337
344
Marker.TraverseStmt (SYCLKernelBody);
338
345
}
339
346
}
340
-
0 commit comments