[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 30 13:23:01 PST 2020
tra added a comment.
LGTM in general.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:1944
+ // host variable in a device or host device lambda.
+ auto IsCapturingReferenceToHostVarInCUDADeviceLambda = [&](VarDecl *VD) {
+ if (!getLangOpts().CUDA || !VD->hasInit())
----------------
Nit: I'd make it a free function.
The large-ish lambda handling a niche case makes the original simple function less readable. I think keeping capture check separate would be a bit cleaner.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:1982
!(getLangOpts().OpenMP && isOpenMPCapturedDecl(D)) &&
+ !IsCapturingReferenceToHostVarInCUDADeviceLambda(VD) &&
VD->isUsableInConstantExpressions(Context))
----------------
This could use some Sema tests.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91088/new/
https://reviews.llvm.org/D91088
More information about the cfe-commits
mailing list