Skip to content

Commit defd543

Browse files
Erich Keanebader
authored andcommitted
[SYCL] Set lexical context for generated OpenCL kernel function (#1020)
When doing ConstructOpenCLKernel, we don't set the current function/lexical context correctly, so getCurLexicalContext (or getCurFunctionDecl) fails, as we're in the TU-level at that point. This function should set the function for diagnostics purposes (and other analysis purposes). At the moment, this isn't causing any problems (particularly since the diagnostic changes previously made don't try to diagnose during this), however this is likely something we would notice later. Start a RAII container to set the current function decl to the kernel. Signed-off-by: Erich Keane [email protected]
1 parent 67b24d4 commit defd543

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,8 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
12851285
FunctionDecl *OpenCLKernel =
12861286
CreateOpenCLKernelDeclaration(getASTContext(), Name, ParamDescs);
12871287

1288+
ContextRAII FuncContext(*this, OpenCLKernel);
1289+
12881290
// Let's copy source location of a functor/lambda to emit nicer diagnostics
12891291
OpenCLKernel->setLocation(LE->getLocation());
12901292

0 commit comments

Comments
 (0)