clang 8.0.0

DeclOpenMP.cpp
Go to the documentation of this file.
1 //===--- 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 /// This file implements OMPThreadPrivateDecl, OMPCapturedExprDecl
11 /// classes.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclBase.h"
18 #include "clang/AST/DeclOpenMP.h"
19 #include "clang/AST/Expr.h"
20
21 using namespace clang;
22
23 //===----------------------------------------------------------------------===//
24 // OMPThreadPrivateDecl Implementation.
25 //===----------------------------------------------------------------------===//
26
27 void OMPThreadPrivateDecl::anchor() { }
28
29 OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
30 DeclContext *DC,
31 SourceLocation L,
32 ArrayRef<Expr *> VL) {
33 OMPThreadPrivateDecl *D =
34 new (C, DC, additionalSizeToAlloc<Expr *>(VL.size()))
35 OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
36 D->NumVars = VL.size();
37 D->setVars(VL);
38 return D;
39 }
40
41 OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
42 unsigned ID,
43 unsigned N) {
44 OMPThreadPrivateDecl *D = new (C, ID, additionalSizeToAlloc<Expr *>(N))
45 OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
46 D->NumVars = N;
47 return D;
48 }
49
50 void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
51 assert(VL.size() == NumVars &&
52 "Number of variables is not the same as the preallocated buffer");
53 std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>());
54 }
55
56 //===----------------------------------------------------------------------===//
57 // OMPRequiresDecl Implementation.
58 //===----------------------------------------------------------------------===//
59
60 void OMPRequiresDecl::anchor() {}
61
62 OMPRequiresDecl *OMPRequiresDecl::Create(ASTContext &C, DeclContext *DC,
63 SourceLocation L,
64 ArrayRef<OMPClause *> CL) {
65 OMPRequiresDecl *D =
66 new (C, DC, additionalSizeToAlloc<OMPClause *>(CL.size()))
67 OMPRequiresDecl(OMPRequires, DC, L);
68 D->NumClauses = CL.size();
69 D->setClauses(CL);
70 return D;
71 }
72
73 OMPRequiresDecl *OMPRequiresDecl::CreateDeserialized(ASTContext &C, unsigned ID,
74 unsigned N) {
75 OMPRequiresDecl *D = new (C, ID, additionalSizeToAlloc<OMPClause *>(N))
76 OMPRequiresDecl(OMPRequires, nullptr, SourceLocation());
77 D->NumClauses = N;
78 return D;
79 }
80
81 void OMPRequiresDecl::setClauses(ArrayRef<OMPClause *> CL) {
82 assert(CL.size() == NumClauses &&
83 "Number of clauses is not the same as the preallocated buffer");
84 std::uninitialized_copy(CL.begin(), CL.end(),
85 getTrailingObjects<OMPClause *>());
86 }
87
88 //===----------------------------------------------------------------------===//
89 // OMPDeclareReductionDecl Implementation.
90 //===----------------------------------------------------------------------===//
91
92 OMPDeclareReductionDecl::OMPDeclareReductionDecl(
93 Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name,
94 QualType Ty, OMPDeclareReductionDecl *PrevDeclInScope)
95 : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr),
96 PrevDeclInScope(PrevDeclInScope) {
97 setInitializer(nullptr, CallInit);
98 }
99
100 void OMPDeclareReductionDecl::anchor() {}
101
102 OMPDeclareReductionDecl *OMPDeclareReductionDecl::Create(
103 ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name,
104 QualType T, OMPDeclareReductionDecl *PrevDeclInScope) {
105 return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name,
106 T, PrevDeclInScope);
107 }
108
109 OMPDeclareReductionDecl *
110 OMPDeclareReductionDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
111 return new (C, ID) OMPDeclareReductionDecl(
112 OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(),
113 QualType(), /*PrevDeclInScope=*/nullptr);
114 }
115
116 OMPDeclareReductionDecl *OMPDeclareReductionDecl::getPrevDeclInScope() {
117 return cast_or_null<OMPDeclareReductionDecl>(
118 PrevDeclInScope.get(getASTContext().getExternalSource()));
119 }
120 const OMPDeclareReductionDecl *
121 OMPDeclareReductionDecl::getPrevDeclInScope() const {
122 return cast_or_null<OMPDeclareReductionDecl>(
123 PrevDeclInScope.get(getASTContext().getExternalSource()));
124 }
125
126 //===----------------------------------------------------------------------===//
127 // OMPCapturedExprDecl Implementation.
128 //===----------------------------------------------------------------------===//
129
130 void OMPCapturedExprDecl::anchor() {}
131
132 OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext &C, DeclContext *DC,
133 IdentifierInfo *Id, QualType T,
134 SourceLocation StartLoc) {
135 return new (C, DC) OMPCapturedExprDecl(
136 C, DC, Id, T, C.getTrivialTypeSourceInfo(T), StartLoc);
137 }
138
139 OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C,
140 unsigned ID) {
141 return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType(),
142 /*TInfo=*/nullptr, SourceLocation());
143 }
144
145 SourceRange OMPCapturedExprDecl::getSourceRange() const {
146 assert(hasInit());
147 return SourceRange(getInit()->getBeginLoc(), getInit()->getEndLoc());
148 }
clang::Builtin::ID
ID
Definition: Builtins.h:49
ASTContext.h
Defines the clang::ASTContext interface.
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
clang::Decl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:410
clang::OMPDeclareReductionDecl::Create
static OMPDeclareReductionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, QualType T, OMPDeclareReductionDecl *PrevDeclInScope)
Create declare reduction node.
Definition: DeclOpenMP.cpp:102
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:414
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:58
clang::OMPThreadPrivateDecl::CreateDeserialized
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Definition: DeclOpenMP.cpp:41
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:155
clang::Decl::DeclContext
friend class DeclContext
Definition: DeclBase.h:243
clang::OMPCapturedExprDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclOpenMP.cpp:145
clang::OMPCapturedExprDecl::CreateDeserialized
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclOpenMP.cpp:139
llvm::ArrayRef
Definition: LLVM.h:32
clang::OMPRequiresDecl::CreateDeserialized
static OMPRequiresDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Create deserialized requires node.
Definition: DeclOpenMP.cpp:73
clang::ASTContext::getTrivialTypeSourceInfo
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
Definition: ASTContext.cpp:2600
clang::OMPRequiresDecl
This represents &#39;#pragma omp requires...&#39; directive.
Definition: DeclOpenMP.h:250
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
Id
int Id
Definition: ASTDiff.cpp:191
clang::OMPDeclareReductionDecl::getPrevDeclInScope
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
Definition: DeclOpenMP.cpp:116
DeclBase.h
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::OMPDeclareReductionDecl
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:103
clang::OMPCapturedExprDecl
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:217
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:376
DeclOpenMP.h
This file defines OpenMP nodes for declarative directives.
clang::OMPCapturedExprDecl::Create
static OMPCapturedExprDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, QualType T, SourceLocation StartLoc)
Definition: DeclOpenMP.cpp:132
Decl.h
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1262
clang::OMPThreadPrivateDecl::Create
static OMPThreadPrivateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr *> VL)
Definition: DeclOpenMP.cpp:29
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:146
clang::OMPRequiresDecl::Create
static OMPRequiresDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< OMPClause *> CL)
Create requires node.
Definition: DeclOpenMP.cpp:62
clang::OMPDeclareReductionDecl::CreateDeserialized
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create deserialized declare reduction node.
Definition: DeclOpenMP.cpp:110
clang::AttrSyntax::C
Expr.h
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:90
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:198
clang::OMPThreadPrivateDecl
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:40