clang API Documentation

DeclOpenMP.h
Go to the documentation of this file.
00001 //===- DeclOpenMP.h - Classes for representing OpenMP directives -*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 ///
00010 /// \file
00011 /// \brief This file defines OpenMP nodes for declarative directives.
00012 ///
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CLANG_AST_DECLOPENMP_H
00016 #define LLVM_CLANG_AST_DECLOPENMP_H
00017 
00018 #include "clang/AST/DeclBase.h"
00019 #include "llvm/ADT/ArrayRef.h"
00020 
00021 namespace clang {
00022 class Expr;
00023 
00024 /// \brief This represents '#pragma omp threadprivate ...' directive.
00025 /// For example, in the following, both 'a' and 'A::b' are threadprivate:
00026 ///
00027 /// \code
00028 /// int a;
00029 /// #pragma omp threadprivate(a)
00030 /// struct A {
00031 ///   static int b;
00032 /// #pragma omp threadprivate(b)
00033 /// };
00034 /// \endcode
00035 ///
00036 class OMPThreadPrivateDecl : public Decl {
00037   friend class ASTDeclReader;
00038   unsigned NumVars;
00039 
00040   virtual void anchor();
00041 
00042   OMPThreadPrivateDecl(Kind DK, DeclContext *DC, SourceLocation L) :
00043     Decl(DK, DC, L), NumVars(0) { }
00044 
00045   ArrayRef<const Expr *> getVars() const {
00046     return llvm::makeArrayRef(reinterpret_cast<const Expr * const *>(this + 1),
00047                               NumVars);
00048   }
00049 
00050   MutableArrayRef<Expr *> getVars() {
00051     return MutableArrayRef<Expr *>(
00052                            reinterpret_cast<Expr **>(this + 1),
00053                            NumVars);
00054   }
00055 
00056   void setVars(ArrayRef<Expr *> VL);
00057 
00058 public:
00059   static OMPThreadPrivateDecl *Create(ASTContext &C, DeclContext *DC,
00060                                       SourceLocation L,
00061                                       ArrayRef<Expr *> VL);
00062   static OMPThreadPrivateDecl *CreateDeserialized(ASTContext &C,
00063                                                   unsigned ID, unsigned N);
00064 
00065   typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
00066   typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
00067   typedef llvm::iterator_range<varlist_iterator> varlist_range;
00068   typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
00069 
00070   unsigned varlist_size() const { return NumVars; }
00071   bool varlist_empty() const { return NumVars == 0; }
00072 
00073   varlist_range varlists() {
00074     return varlist_range(varlist_begin(), varlist_end());
00075   }
00076   varlist_const_range varlists() const {
00077     return varlist_const_range(varlist_begin(), varlist_end());
00078   }
00079   varlist_iterator varlist_begin() { return getVars().begin(); }
00080   varlist_iterator varlist_end() { return getVars().end(); }
00081   varlist_const_iterator varlist_begin() const { return getVars().begin(); }
00082   varlist_const_iterator varlist_end() const { return getVars().end(); }
00083 
00084   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
00085   static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
00086 };
00087 
00088 }  // end namespace clang
00089 
00090 #endif