clang  3.7.0
DeclOpenMP.h
Go to the documentation of this file.
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_DECLOPENMP_H
16 #define LLVM_CLANG_AST_DECLOPENMP_H
17 
18 #include "clang/AST/DeclBase.h"
19 #include "llvm/ADT/ArrayRef.h"
20 
21 namespace clang {
22 class Expr;
23 
24 /// \brief This represents '#pragma omp threadprivate ...' directive.
25 /// For example, in the following, both 'a' and 'A::b' are threadprivate:
26 ///
27 /// \code
28 /// int a;
29 /// #pragma omp threadprivate(a)
30 /// struct A {
31 /// static int b;
32 /// #pragma omp threadprivate(b)
33 /// };
34 /// \endcode
35 ///
36 class OMPThreadPrivateDecl : public Decl {
37  friend class ASTDeclReader;
38  unsigned NumVars;
39 
40  virtual void anchor();
41 
43  Decl(DK, DC, L), NumVars(0) { }
44 
45  ArrayRef<const Expr *> getVars() const {
46  return llvm::makeArrayRef(reinterpret_cast<const Expr * const *>(this + 1),
47  NumVars);
48  }
49 
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 
67  typedef llvm::iterator_range<varlist_iterator> varlist_range;
68  typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
69 
70  unsigned varlist_size() const { return NumVars; }
71  bool varlist_empty() const { return NumVars == 0; }
72 
75  }
78  }
79  varlist_iterator varlist_begin() { return getVars().begin(); }
80  varlist_iterator varlist_end() { return getVars().end(); }
81  varlist_const_iterator varlist_begin() const { return getVars().begin(); }
82  varlist_const_iterator varlist_end() const { return getVars().end(); }
83 
84  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
85  static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
86 };
87 
88 } // end namespace clang
89 
90 #endif
llvm::iterator_range< varlist_const_iterator > varlist_const_range
Definition: DeclOpenMP.h:68
varlist_const_iterator varlist_end() const
Definition: DeclOpenMP.h:82
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Definition: DeclOpenMP.cpp:39
friend class DeclContext
Definition: DeclBase.h:211
bool varlist_empty() const
Definition: DeclOpenMP.h:71
static bool classof(const Decl *D)
Definition: DeclOpenMP.h:84
varlist_const_iterator varlist_begin() const
Definition: DeclOpenMP.h:81
static OMPThreadPrivateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr * > VL)
Definition: DeclOpenMP.cpp:28
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: DeclOpenMP.h:65
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
Kind getKind() const
Definition: DeclBase.h:375
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
varlist_iterator varlist_begin()
Definition: DeclOpenMP.h:79
unsigned varlist_size() const
Definition: DeclOpenMP.h:70
varlist_const_range varlists() const
Definition: DeclOpenMP.h:76
static bool classofKind(Kind K)
Definition: DeclOpenMP.h:85
varlist_iterator varlist_end()
Definition: DeclOpenMP.h:80
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:76
varlist_range varlists()
Definition: DeclOpenMP.h:73
llvm::iterator_range< varlist_iterator > varlist_range
Definition: DeclOpenMP.h:67
ArrayRef< const Expr * >::iterator varlist_const_iterator
Definition: DeclOpenMP.h:66
This represents '#pragma omp threadprivate ...' directive. For example, in the following, both 'a' and 'A::b' are threadprivate:
Definition: DeclOpenMP.h:36