[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 24 08:00:06 PDT 2022


jyu2 added inline comments.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:2398
+        return VD;
+      ExprResult ThisExpr = ActOnCXXThis(SourceLocation());
+      if (ThisExpr.isInvalid())
----------------
ABataev wrote:
> Maybe `BuildCXXThisExpr(SourceLocation(), getCurrentThisType(), /*IsImplicit=*/true)`?
Thanks.  Change


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:2410
+          buildCaptureDecl(*this, FD->getIdentifier(), ME,
+                           DVarPrivate.CKind == OMPC_private ? false : true,
+                           CurContext->getParent(),
----------------
ABataev wrote:
> Just `DVarPrivate.CKind != OMPC_private`
Yes!! changed


================
Comment at: clang/lib/Sema/TreeTransform.h:11071-11073
+  if (!getDerived().AlwaysRebuild() && !getSema().getLangOpts().OpenMP &&
+      Base.get() == E->getBase() && QualifierLoc == E->getQualifierLoc() &&
+      Member == E->getMemberDecl() && FoundDecl == E->getFoundDecl() &&
----------------
ABataev wrote:
> Why do we need this check here?
Without, the field is not getting rebuild during the template instantiation.  That cause the field is not getting captured and implicit firstprivate clause is not getting generate.  The test  is added in default_firstprivate_ast_print.cpp
where I add check for it on line 58:
// DUMP-NEXT:  -OMPFirstprivateClause
// DUMP-NEXT:    -DeclRefExpr {{.*}} 'targetDev'


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127803/new/

https://reviews.llvm.org/D127803



More information about the cfe-commits mailing list