1 //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \brief This file implements OMPThreadPrivateDecl class.
12 //===----------------------------------------------------------------------===//
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"
20 using namespace clang;
22 //===----------------------------------------------------------------------===//
23 // OMPThreadPrivateDecl Implementation.
24 //===----------------------------------------------------------------------===//
26 void OMPThreadPrivateDecl::anchor() { }
28 OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
31 ArrayRef<Expr *> VL) {
32 unsigned Size = sizeof(OMPThreadPrivateDecl) +
33 (VL.size() * sizeof(Expr *));
35 void *Mem = C.Allocate(Size, llvm::alignOf<OMPThreadPrivateDecl>());
36 OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate,
38 D->NumVars = VL.size();
43 OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
46 unsigned Size = sizeof(OMPThreadPrivateDecl) + (N * sizeof(Expr *));
48 void *Mem = AllocateDeserializedDecl(C, ID, Size);
49 OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate,
55 void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
56 assert(VL.size() == NumVars &&
57 "Number of variables is not the same as the preallocated buffer");
58 Expr **Vars = reinterpret_cast<Expr **>(this + 1);
59 std::copy(VL.begin(), VL.end(), Vars);