1249261Sdim//===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===// 2249261Sdim// 3249261Sdim// The LLVM Compiler Infrastructure 4249261Sdim// 5249261Sdim// This file is distributed under the University of Illinois Open Source 6249261Sdim// License. See LICENSE.TXT for details. 7249261Sdim// 8249261Sdim//===----------------------------------------------------------------------===// 9249261Sdim/// \file 10249261Sdim/// \brief This file implements OMPThreadPrivateDecl class. 11249261Sdim/// 12249261Sdim//===----------------------------------------------------------------------===// 13249261Sdim 14249261Sdim#include "clang/AST/ASTContext.h" 15249261Sdim#include "clang/AST/DeclBase.h" 16249261Sdim#include "clang/AST/Decl.h" 17249261Sdim#include "clang/AST/DeclOpenMP.h" 18249261Sdim#include "clang/AST/Expr.h" 19249261Sdim 20249261Sdimusing namespace clang; 21249261Sdim 22249261Sdim//===----------------------------------------------------------------------===// 23249261Sdim// OMPThreadPrivateDecl Implementation. 24249261Sdim//===----------------------------------------------------------------------===// 25249261Sdim 26249261Sdimvoid OMPThreadPrivateDecl::anchor() { } 27249261Sdim 28249261SdimOMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C, 29249261Sdim DeclContext *DC, 30249261Sdim SourceLocation L, 31263509Sdim ArrayRef<Expr *> VL) { 32249261Sdim unsigned Size = sizeof(OMPThreadPrivateDecl) + 33263509Sdim (VL.size() * sizeof(Expr *)); 34249261Sdim 35249261Sdim void *Mem = C.Allocate(Size, llvm::alignOf<OMPThreadPrivateDecl>()); 36249261Sdim OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate, 37249261Sdim DC, L); 38249261Sdim D->NumVars = VL.size(); 39249261Sdim D->setVars(VL); 40249261Sdim return D; 41249261Sdim} 42249261Sdim 43249261SdimOMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C, 44249261Sdim unsigned ID, 45249261Sdim unsigned N) { 46263509Sdim unsigned Size = sizeof(OMPThreadPrivateDecl) + (N * sizeof(Expr *)); 47249261Sdim 48249261Sdim void *Mem = AllocateDeserializedDecl(C, ID, Size); 49249261Sdim OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate, 50249261Sdim 0, SourceLocation()); 51249261Sdim D->NumVars = N; 52249261Sdim return D; 53249261Sdim} 54249261Sdim 55263509Sdimvoid OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) { 56249261Sdim assert(VL.size() == NumVars && 57249261Sdim "Number of variables is not the same as the preallocated buffer"); 58263509Sdim Expr **Vars = reinterpret_cast<Expr **>(this + 1); 59249261Sdim std::copy(VL.begin(), VL.end(), Vars); 60249261Sdim} 61263509Sdim 62