1 //===- DeclOpenMP.h - Classes for representing OpenMP directives -*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief This file defines OpenMP nodes for declarative directives. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_AST_OPENMP_H 16 #define LLVM_CLANG_AST_OPENMP_H 17 18 #include "clang/AST/DeclBase.h" 19 #include "llvm/ADT/ArrayRef.h" 20 21 namespace clang { 22 23 /// \brief This represents '#pragma omp threadprivate ...' directive. 24 /// For example, in the following, both 'a' and 'A::b' are threadprivate: 25 /// 26 /// \code 27 /// int a; 28 /// #pragma omp threadprivate(a) 29 /// struct A { 30 /// static int b; 31 /// #pragma omp threadprivate(b) 32 /// }; 33 /// \endcode 34 /// 35 class OMPThreadPrivateDecl : public Decl { 36 friend class ASTDeclReader; 37 unsigned NumVars; 38 39 virtual void anchor(); 40 OMPThreadPrivateDecl(Kind DK,DeclContext * DC,SourceLocation L)41 OMPThreadPrivateDecl(Kind DK, DeclContext *DC, SourceLocation L) : 42 Decl(DK, DC, L), NumVars(0) { } 43 getVars()44 ArrayRef<const Expr *> getVars() const { 45 return ArrayRef<const Expr *>( 46 reinterpret_cast<const Expr * const *>(this + 1), 47 NumVars); 48 } 49 getVars()50 MutableArrayRef<Expr *> getVars() { 51 return MutableArrayRef<Expr *>( 52 reinterpret_cast<Expr **>(this + 1), 53 NumVars); 54 } 55 56 void setVars(ArrayRef<Expr *> VL); 57 58 public: 59 static OMPThreadPrivateDecl *Create(ASTContext &C, DeclContext *DC, 60 SourceLocation L, 61 ArrayRef<Expr *> VL); 62 static OMPThreadPrivateDecl *CreateDeserialized(ASTContext &C, 63 unsigned ID, unsigned N); 64 65 typedef MutableArrayRef<Expr *>::iterator varlist_iterator; 66 typedef ArrayRef<const Expr *>::iterator varlist_const_iterator; 67 typedef llvm::iterator_range<varlist_iterator> varlist_range; 68 typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range; 69 varlist_size()70 unsigned varlist_size() const { return NumVars; } varlist_empty()71 bool varlist_empty() const { return NumVars == 0; } 72 varlists()73 varlist_range varlists() { 74 return varlist_range(varlist_begin(), varlist_end()); 75 } varlists()76 varlist_const_range varlists() const { 77 return varlist_const_range(varlist_begin(), varlist_end()); 78 } varlist_begin()79 varlist_iterator varlist_begin() { return getVars().begin(); } varlist_end()80 varlist_iterator varlist_end() { return getVars().end(); } varlist_begin()81 varlist_const_iterator varlist_begin() const { return getVars().begin(); } varlist_end()82 varlist_const_iterator varlist_end() const { return getVars().end(); } 83 classof(const Decl * D)84 static bool classof(const Decl *D) { return classofKind(D->getKind()); } classofKind(Kind K)85 static bool classofKind(Kind K) { return K == OMPThreadPrivate; } 86 }; 87 88 } // end namespace clang 89 90 #endif 91