blob: 493e2cd41226bde471bf8e1c3df6458dd6010cc2 [file] [log] [blame]
Alexey Bataeva769e072013-03-22 06:34:35 +00001//===--- 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"
Alexey Bataeva769e072013-03-22 06:34:35 +000015#include "clang/AST/Decl.h"
Chandler Carruth5553d0d2014-01-07 11:51:46 +000016#include "clang/AST/DeclBase.h"
Alexey Bataeva769e072013-03-22 06:34:35 +000017#include "clang/AST/DeclOpenMP.h"
18#include "clang/AST/Expr.h"
19
20using namespace clang;
21
22//===----------------------------------------------------------------------===//
23// OMPThreadPrivateDecl Implementation.
24//===----------------------------------------------------------------------===//
25
26void OMPThreadPrivateDecl::anchor() { }
27
28OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
29 DeclContext *DC,
30 SourceLocation L,
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000031 ArrayRef<Expr *> VL) {
James Y Knight967eb202015-12-29 22:13:13 +000032 OMPThreadPrivateDecl *D =
33 new (C, DC, additionalSizeToAlloc<Expr *>(VL.size()))
34 OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
Alexey Bataeva769e072013-03-22 06:34:35 +000035 D->NumVars = VL.size();
36 D->setVars(VL);
37 return D;
38}
39
40OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
41 unsigned ID,
42 unsigned N) {
James Y Knight967eb202015-12-29 22:13:13 +000043 OMPThreadPrivateDecl *D = new (C, ID, additionalSizeToAlloc<Expr *>(N))
Craig Topper36250ad2014-05-12 05:36:57 +000044 OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
Alexey Bataeva769e072013-03-22 06:34:35 +000045 D->NumVars = N;
46 return D;
47}
48
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000049void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
Alexey Bataeva769e072013-03-22 06:34:35 +000050 assert(VL.size() == NumVars &&
51 "Number of variables is not the same as the preallocated buffer");
James Y Knight967eb202015-12-29 22:13:13 +000052 std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>());
Alexey Bataeva769e072013-03-22 06:34:35 +000053}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000054