]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/lib/AST/DeclOpenMP.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / clang / lib / AST / DeclOpenMP.cpp
1 //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
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 /// \file
10 /// \brief This file implements OMPThreadPrivateDecl class.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/DeclBase.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclOpenMP.h"
18 #include "clang/AST/Expr.h"
19
20 using namespace clang;
21
22 //===----------------------------------------------------------------------===//
23 // OMPThreadPrivateDecl Implementation.
24 //===----------------------------------------------------------------------===//
25
26 void OMPThreadPrivateDecl::anchor() { }
27
28 OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
29                                                    DeclContext *DC,
30                                                    SourceLocation L,
31                                                    ArrayRef<DeclRefExpr *> VL) {
32   unsigned Size = sizeof(OMPThreadPrivateDecl) +
33                   (VL.size() * sizeof(DeclRefExpr *));
34
35   void *Mem = C.Allocate(Size, llvm::alignOf<OMPThreadPrivateDecl>());
36   OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate,
37                                                            DC, L);
38   D->NumVars = VL.size();
39   D->setVars(VL);
40   return D;
41 }
42
43 OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
44                                                                unsigned ID,
45                                                                unsigned N) {
46   unsigned Size = sizeof(OMPThreadPrivateDecl) + (N * sizeof(DeclRefExpr *));
47
48   void *Mem = AllocateDeserializedDecl(C, ID, Size);
49   OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate,
50                                                            0, SourceLocation());
51   D->NumVars = N;
52   return D;
53 }
54
55 void OMPThreadPrivateDecl::setVars(ArrayRef<DeclRefExpr *> VL) {
56   assert(VL.size() == NumVars &&
57          "Number of variables is not the same as the preallocated buffer");
58   DeclRefExpr **Vars = reinterpret_cast<DeclRefExpr **>(this + 1);
59   std::copy(VL.begin(), VL.end(), Vars);
60 }