]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/DeclOpenMP.h
Merge ^/head r293686 through r293849.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / DeclOpenMP.h
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 final
37     : public Decl,
38       private llvm::TrailingObjects<OMPThreadPrivateDecl, Expr *> {
39   friend class ASTDeclReader;
40   friend TrailingObjects;
41
42   unsigned NumVars;
43
44   virtual void anchor();
45
46   OMPThreadPrivateDecl(Kind DK, DeclContext *DC, SourceLocation L) :
47     Decl(DK, DC, L), NumVars(0) { }
48
49   ArrayRef<const Expr *> getVars() const {
50     return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumVars);
51   }
52
53   MutableArrayRef<Expr *> getVars() {
54     return MutableArrayRef<Expr *>(getTrailingObjects<Expr *>(), NumVars);
55   }
56
57   void setVars(ArrayRef<Expr *> VL);
58
59 public:
60   static OMPThreadPrivateDecl *Create(ASTContext &C, DeclContext *DC,
61                                       SourceLocation L,
62                                       ArrayRef<Expr *> VL);
63   static OMPThreadPrivateDecl *CreateDeserialized(ASTContext &C,
64                                                   unsigned ID, unsigned N);
65
66   typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
67   typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
68   typedef llvm::iterator_range<varlist_iterator> varlist_range;
69   typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
70
71   unsigned varlist_size() const { return NumVars; }
72   bool varlist_empty() const { return NumVars == 0; }
73
74   varlist_range varlists() {
75     return varlist_range(varlist_begin(), varlist_end());
76   }
77   varlist_const_range varlists() const {
78     return varlist_const_range(varlist_begin(), varlist_end());
79   }
80   varlist_iterator varlist_begin() { return getVars().begin(); }
81   varlist_iterator varlist_end() { return getVars().end(); }
82   varlist_const_iterator varlist_begin() const { return getVars().begin(); }
83   varlist_const_iterator varlist_end() const { return getVars().end(); }
84
85   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
86   static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
87 };
88
89 }  // end namespace clang
90
91 #endif