Skip to content

[SYCL] Set lexical context for generated OpenCL kernel function #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,8 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
FunctionDecl *OpenCLKernel =
CreateOpenCLKernelDeclaration(getASTContext(), Name, ParamDescs);

ContextRAII FuncContext(*this, OpenCLKernel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? We disabled diagnosing during OpenCL kernel generation, is it possible that we once enable it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, I no longer have a true motivating example. However, this is a bug we have worked around a few times, so I suspect we will need this fixed eventually.

Additionally, this is one of the conditions where getLexicalContext gave us not a Function Decl, so now that this is fixed, we know !FD means exactly what it should, that we are evaluating a global (and this can properly handle that once we figure that out).

Copy link
Contributor

@Fznamznon Fznamznon Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sounds reasonable to me.


// Let's copy source location of a functor/lambda to emit nicer diagnostics
OpenCLKernel->setLocation(LE->getLocation());

Expand Down