diff options
Diffstat (limited to 'clang/include/clang/AST/DeclOpenMP.h')
-rw-r--r-- | clang/include/clang/AST/DeclOpenMP.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h index d3d7cf51aa4..5faf6c84c8c 100644 --- a/clang/include/clang/AST/DeclOpenMP.h +++ b/clang/include/clang/AST/DeclOpenMP.h @@ -206,6 +206,108 @@ public: } }; +/// This represents '#pragma omp declare mapper ...' directive. Map clauses are +/// allowed to use with this directive. The following example declares a user +/// defined mapper for the type 'struct vec'. This example instructs the fields +/// 'len' and 'data' should be mapped when mapping instances of 'struct vec'. +/// +/// \code +/// #pragma omp declare mapper(mid: struct vec v) map(v.len, v.data[0:N]) +/// \endcode +class OMPDeclareMapperDecl final : public ValueDecl, public DeclContext { + friend class ASTDeclReader; + + /// Clauses assoicated with this mapper declaration + MutableArrayRef<OMPClause *> Clauses; + + /// Mapper variable, which is 'v' in the example above + Expr *MapperVarRef = nullptr; + + /// Name of the mapper variable + DeclarationName VarName; + + LazyDeclPtr PrevDeclInScope; + + virtual void anchor(); + + OMPDeclareMapperDecl(Kind DK, DeclContext *DC, SourceLocation L, + DeclarationName Name, QualType Ty, + DeclarationName VarName, + OMPDeclareMapperDecl *PrevDeclInScope) + : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), VarName(VarName), + PrevDeclInScope(PrevDeclInScope) {} + + void setPrevDeclInScope(OMPDeclareMapperDecl *Prev) { + PrevDeclInScope = Prev; + } + + /// Sets an array of clauses to this mapper declaration + void setClauses(ArrayRef<OMPClause *> CL); + +public: + /// Creates declare mapper node. + static OMPDeclareMapperDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, DeclarationName Name, + QualType T, DeclarationName VarName, + OMPDeclareMapperDecl *PrevDeclInScope); + /// Creates deserialized declare mapper node. + static OMPDeclareMapperDecl *CreateDeserialized(ASTContext &C, unsigned ID, + unsigned N); + + /// Creates an array of clauses to this mapper declaration and intializes + /// them. + void CreateClauses(ASTContext &C, ArrayRef<OMPClause *> CL); + + using clauselist_iterator = MutableArrayRef<OMPClause *>::iterator; + using clauselist_const_iterator = ArrayRef<const OMPClause *>::iterator; + using clauselist_range = llvm::iterator_range<clauselist_iterator>; + using clauselist_const_range = + llvm::iterator_range<clauselist_const_iterator>; + + unsigned clauselist_size() const { return Clauses.size(); } + bool clauselist_empty() const { return Clauses.empty(); } + + clauselist_range clauselists() { + return clauselist_range(clauselist_begin(), clauselist_end()); + } + clauselist_const_range clauselists() const { + return clauselist_const_range(clauselist_begin(), clauselist_end()); + } + clauselist_iterator clauselist_begin() { return Clauses.begin(); } + clauselist_iterator clauselist_end() { return Clauses.end(); } + clauselist_const_iterator clauselist_begin() const { return Clauses.begin(); } + clauselist_const_iterator clauselist_end() const { return Clauses.end(); } + + /// Get the variable declared in the mapper + Expr *getMapperVarRef() { return MapperVarRef; } + const Expr *getMapperVarRef() const { return MapperVarRef; } + /// Set the variable declared in the mapper + void setMapperVarRef(Expr *MapperVarRefE) { MapperVarRef = MapperVarRefE; } + + /// Get the name of the variable declared in the mapper + DeclarationName getVarName() { return VarName; } + + /// Get reference to previous declare mapper construct in the same + /// scope with the same name. + OMPDeclareMapperDecl *getPrevDeclInScope() { + return cast_or_null<OMPDeclareMapperDecl>( + PrevDeclInScope.get(getASTContext().getExternalSource())); + } + const OMPDeclareMapperDecl *getPrevDeclInScope() const { + return cast_or_null<OMPDeclareMapperDecl>( + PrevDeclInScope.get(getASTContext().getExternalSource())); + } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == OMPDeclareMapper; } + static DeclContext *castToDeclContext(const OMPDeclareMapperDecl *D) { + return static_cast<DeclContext *>(const_cast<OMPDeclareMapperDecl *>(D)); + } + static OMPDeclareMapperDecl *castFromDeclContext(const DeclContext *DC) { + return static_cast<OMPDeclareMapperDecl *>(const_cast<DeclContext *>(DC)); + } +}; + /// Pseudo declaration for capturing expressions. Also is used for capturing of /// non-static data members in non-static member functions. /// |