diff options
Diffstat (limited to 'clang/include/clang')
-rw-r--r-- | clang/include/clang/AST/DeclOpenMP.h | 31 | ||||
-rw-r--r-- | clang/include/clang/AST/RecursiveASTVisitor.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Basic/DeclNodes.td | 1 | ||||
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Serialization/ASTBitCodes.h | 2 |
5 files changed, 38 insertions, 2 deletions
diff --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h index 524e78eb3fa..ed7cb35e60a 100644 --- a/clang/include/clang/AST/DeclOpenMP.h +++ b/clang/include/clang/AST/DeclOpenMP.h @@ -87,6 +87,35 @@ public: static bool classofKind(Kind K) { return K == OMPThreadPrivate; } }; -} // end namespace clang +/// Pseudo declaration for capturing of non-static data members in non-static +/// member functions. +/// +/// Clang supports capturing of variables only, but OpenMP 4.5 allows to +/// privatize non-static members of current class in non-static member +/// functions. This pseudo-declaration allows properly handle this kind of +/// capture by wrapping captured expression into a variable-like declaration. +class OMPCapturedFieldDecl final : public VarDecl { + friend class ASTDeclReader; + void anchor() override; + + OMPCapturedFieldDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, + QualType Type) + : VarDecl(OMPCapturedField, C, DC, SourceLocation(), SourceLocation(), Id, + Type, nullptr, SC_None) { + setImplicit(); + } + +public: + static OMPCapturedFieldDecl *Create(ASTContext &C, DeclContext *DC, + IdentifierInfo *Id, QualType T); + + static OMPCapturedFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == OMPCapturedField; } +}; + +} // end namespace clang #endif diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 1a28bad51be..ea10df13a22 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1434,6 +1434,8 @@ DEF_TRAVERSE_DECL(OMPThreadPrivateDecl, { } }) +DEF_TRAVERSE_DECL(OMPCapturedFieldDecl, { TRY_TO(TraverseVarHelper(D)); }) + // A helper method for TemplateDecl's children. template <typename Derived> bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper( diff --git a/clang/include/clang/Basic/DeclNodes.td b/clang/include/clang/Basic/DeclNodes.td index 723ea547d8a..490c5f25521 100644 --- a/clang/include/clang/Basic/DeclNodes.td +++ b/clang/include/clang/Basic/DeclNodes.td @@ -51,6 +51,7 @@ def Named : Decl<1>; : DDecl<VarTemplateSpecialization>; def ImplicitParam : DDecl<Var>; def ParmVar : DDecl<Var>; + def OMPCapturedField : DDecl<Var>; def NonTypeTemplateParm : DDecl<Declarator>; def Template : DDecl<Named, 1>; def RedeclarableTemplate : DDecl<Template, 1>; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 002abe85071..7514373897e 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7789,7 +7789,9 @@ public: /// \brief Check if the specified variable is used in one of the private /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP /// constructs. - bool IsOpenMPCapturedDecl(ValueDecl *D); + VarDecl *IsOpenMPCapturedDecl(ValueDecl *D); + ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, + ExprObjectKind OK); /// \brief Check if the specified variable is used in 'private' clause. /// \param Level Relative level of nested OpenMP construct for that the check diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 5ee73f16889..cc663d00cf0 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1163,6 +1163,8 @@ namespace clang { DECL_EMPTY, /// \brief An ObjCTypeParamDecl record. DECL_OBJC_TYPE_PARAM, + /// \brief An OMPCapturedFieldDecl record. + DECL_OMP_CAPTUREDFIELD, }; /// \brief Record codes for each kind of statement or expression. |