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
|
2016-02-11 13:35:55 +08:00
|
|
|
/// \brief This file implements OMPThreadPrivateDecl, OMPCapturedExprDecl
|
2016-02-08 17:29:13 +08:00
|
|
|
/// classes.
|
2013-03-22 14:34:35 +08:00
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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) {
|
2015-12-30 06:13:13 +08:00
|
|
|
OMPThreadPrivateDecl *D =
|
|
|
|
new (C, DC, additionalSizeToAlloc<Expr *>(VL.size()))
|
|
|
|
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) {
|
2015-12-30 06:13:13 +08:00
|
|
|
OMPThreadPrivateDecl *D = new (C, ID, additionalSizeToAlloc<Expr *>(N))
|
2014-05-12 13:36:57 +08:00
|
|
|
OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, 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");
|
2015-12-30 06:13:13 +08:00
|
|
|
std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>());
|
2013-03-22 14:34:35 +08:00
|
|
|
}
|
2013-07-19 11:13:43 +08:00
|
|
|
|
2016-03-03 13:21:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// OMPDeclareReductionDecl Implementation.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void OMPDeclareReductionDecl::anchor() {}
|
|
|
|
|
|
|
|
OMPDeclareReductionDecl *OMPDeclareReductionDecl::Create(
|
|
|
|
ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name,
|
|
|
|
QualType T, OMPDeclareReductionDecl *PrevDeclInScope) {
|
|
|
|
return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name,
|
|
|
|
T, PrevDeclInScope);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPDeclareReductionDecl *
|
|
|
|
OMPDeclareReductionDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
|
|
|
|
return new (C, ID) OMPDeclareReductionDecl(
|
|
|
|
OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(),
|
|
|
|
QualType(), /*PrevDeclInScope=*/nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPDeclareReductionDecl *OMPDeclareReductionDecl::getPrevDeclInScope() {
|
|
|
|
return cast_or_null<OMPDeclareReductionDecl>(
|
|
|
|
PrevDeclInScope.get(getASTContext().getExternalSource()));
|
|
|
|
}
|
|
|
|
const OMPDeclareReductionDecl *
|
|
|
|
OMPDeclareReductionDecl::getPrevDeclInScope() const {
|
|
|
|
return cast_or_null<OMPDeclareReductionDecl>(
|
|
|
|
PrevDeclInScope.get(getASTContext().getExternalSource()));
|
|
|
|
}
|
|
|
|
|
2016-02-08 17:29:13 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2016-02-11 13:35:55 +08:00
|
|
|
// OMPCapturedExprDecl Implementation.
|
2016-02-08 17:29:13 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-11 13:35:55 +08:00
|
|
|
void OMPCapturedExprDecl::anchor() {}
|
2016-02-08 17:29:13 +08:00
|
|
|
|
2016-02-11 13:35:55 +08:00
|
|
|
OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext &C, DeclContext *DC,
|
2016-12-21 00:51:02 +08:00
|
|
|
IdentifierInfo *Id, QualType T,
|
|
|
|
SourceLocation StartLoc) {
|
|
|
|
return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T, StartLoc);
|
2016-02-08 17:29:13 +08:00
|
|
|
}
|
|
|
|
|
2016-02-11 13:35:55 +08:00
|
|
|
OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C,
|
|
|
|
unsigned ID) {
|
2016-12-21 00:51:02 +08:00
|
|
|
return new (C, ID)
|
|
|
|
OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), SourceLocation());
|
2016-02-08 17:29:13 +08:00
|
|
|
}
|
|
|
|
|
2016-12-21 00:51:02 +08:00
|
|
|
SourceRange OMPCapturedExprDecl::getSourceRange() const {
|
|
|
|
assert(hasInit());
|
|
|
|
return SourceRange(getInit()->getLocStart(), getInit()->getLocEnd());
|
|
|
|
}
|