Generate the capture for the field when the field is used in openmp
authorJennifer Yu <jennifer.yu@intel.com>
Tue, 14 Jun 2022 17:11:10 +0000 (10:11 -0700)
committerJennifer Yu <jennifer.yu@intel.com>
Sat, 2 Jul 2022 00:09:01 +0000 (17:09 -0700)
commit927156a67445a6edb1b09e3d6246b0e5a9cf8a16
treed64ee2f9d42ff158e24e61de87a3e428d29df89a
parent17c811956464afcdb6702cf22d91a4667493c948
Generate the capture for the field when the field is used in openmp
region with implicit default inside the member function.

This is to fix assert when field is referenced in OpenMP region with
default (first|private) clause inside member function.

The problem of assert is that the capture is not generated for the field.

This patch is to generate capture when the field is used with implicit
default, use it in the code, and save the capture off to make sure it is
considered from that point and add first/private clauses.

1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to
   store generated capture fields info.
2> In function isOpenMPCaptureDecl: the caputer is generated and saved
   in ImplicitDefaultFirstprivateFDs.
3> Add new help functions:
   getImplicitFDCapExprDecl
   isImplicitDefaultFirstprivateFD
   addImplicitDefaultFirstprivateFD
4> Add addition argument in hasDSA to check default attribute for
   default(first|private).
5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to
   build the implicit clause.
6> Add new parameter "Context" for buildCaptureDecl, due to when capture
   field, the parent context is needed to be used.
7> Change in isOpenMPPrivateDecl where stop propagate the capture from
   the enclosing region for private variable.
8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info
   to generate first|private clause.
9> Add new function isOpenMPRebuildMemberExpr: use to determine if field
   needs to be rebuild during template instantiation.

Differential Revision: https://reviews.llvm.org/D127803
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/test/OpenMP/default_firstprivate_ast_print.cpp
clang/test/OpenMP/default_private_ast_print.cpp