2013-03-22 14:34:35 +08:00
|
|
|
//===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
/// \brief This file implements OMPThreadPrivateDecl class.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
2014-01-07 19:51:46 +08:00
|
|
|
#include "clang/AST/DeclBase.h"
|
2013-03-22 14:34:35 +08:00
|
|
|
#include "clang/AST/DeclOpenMP.h"
|
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// OMPThreadPrivateDecl Implementation.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void OMPThreadPrivateDecl::anchor() { }
|
|
|
|
|
|
|
|
OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
|
|
|
|
DeclContext *DC,
|
|
|
|
SourceLocation L,
|
2013-05-13 12:18:18 +08:00
|
|
|
ArrayRef<Expr *> VL) {
|
2013-11-22 17:01:48 +08:00
|
|
|
OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *))
|
|
|
|
OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
|
2013-03-22 14:34:35 +08:00
|
|
|
D->NumVars = VL.size();
|
|
|
|
D->setVars(VL);
|
|
|
|
return D;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
|
|
|
|
unsigned ID,
|
|
|
|
unsigned N) {
|
2013-11-22 17:01:48 +08:00
|
|
|
OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *))
|
|
|
|
OMPThreadPrivateDecl(OMPThreadPrivate, 0, SourceLocation());
|
2013-03-22 14:34:35 +08:00
|
|
|
D->NumVars = N;
|
|
|
|
return D;
|
|
|
|
}
|
|
|
|
|
2013-05-13 12:18:18 +08:00
|
|
|
void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
|
2013-03-22 14:34:35 +08:00
|
|
|
assert(VL.size() == NumVars &&
|
|
|
|
"Number of variables is not the same as the preallocated buffer");
|
2013-05-13 12:18:18 +08:00
|
|
|
Expr **Vars = reinterpret_cast<Expr **>(this + 1);
|
2013-03-22 14:34:35 +08:00
|
|
|
std::copy(VL.begin(), VL.end(), Vars);
|
|
|
|
}
|
2013-07-19 11:13:43 +08:00
|
|
|
|