1f4a2713aSLionel Sambuc //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc /// \file
10f4a2713aSLionel Sambuc /// \brief This file implements OMPThreadPrivateDecl class.
11f4a2713aSLionel Sambuc ///
12f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc #include "clang/AST/ASTContext.h"
15f4a2713aSLionel Sambuc #include "clang/AST/Decl.h"
16*0a6a1f1dSLionel Sambuc #include "clang/AST/DeclBase.h"
17f4a2713aSLionel Sambuc #include "clang/AST/DeclOpenMP.h"
18f4a2713aSLionel Sambuc #include "clang/AST/Expr.h"
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc using namespace clang;
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
23f4a2713aSLionel Sambuc // OMPThreadPrivateDecl Implementation.
24f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
25f4a2713aSLionel Sambuc
anchor()26f4a2713aSLionel Sambuc void OMPThreadPrivateDecl::anchor() { }
27f4a2713aSLionel Sambuc
Create(ASTContext & C,DeclContext * DC,SourceLocation L,ArrayRef<Expr * > VL)28f4a2713aSLionel Sambuc OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
29f4a2713aSLionel Sambuc DeclContext *DC,
30f4a2713aSLionel Sambuc SourceLocation L,
31f4a2713aSLionel Sambuc ArrayRef<Expr *> VL) {
32*0a6a1f1dSLionel Sambuc OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *))
33*0a6a1f1dSLionel Sambuc OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
34f4a2713aSLionel Sambuc D->NumVars = VL.size();
35f4a2713aSLionel Sambuc D->setVars(VL);
36f4a2713aSLionel Sambuc return D;
37f4a2713aSLionel Sambuc }
38f4a2713aSLionel Sambuc
CreateDeserialized(ASTContext & C,unsigned ID,unsigned N)39f4a2713aSLionel Sambuc OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
40f4a2713aSLionel Sambuc unsigned ID,
41f4a2713aSLionel Sambuc unsigned N) {
42*0a6a1f1dSLionel Sambuc OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *))
43*0a6a1f1dSLionel Sambuc OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
44f4a2713aSLionel Sambuc D->NumVars = N;
45f4a2713aSLionel Sambuc return D;
46f4a2713aSLionel Sambuc }
47f4a2713aSLionel Sambuc
setVars(ArrayRef<Expr * > VL)48f4a2713aSLionel Sambuc void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
49f4a2713aSLionel Sambuc assert(VL.size() == NumVars &&
50f4a2713aSLionel Sambuc "Number of variables is not the same as the preallocated buffer");
51f4a2713aSLionel Sambuc Expr **Vars = reinterpret_cast<Expr **>(this + 1);
52f4a2713aSLionel Sambuc std::copy(VL.begin(), VL.end(), Vars);
53f4a2713aSLionel Sambuc }
54f4a2713aSLionel Sambuc
55