clang 22.0.0git
DeclOpenMP.cpp
Go to the documentation of this file.
1//===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file implements OMPThreadPrivateDecl, OMPCapturedExprDecl
10/// classes.
11///
12//===----------------------------------------------------------------------===//
13
15#include "clang/AST/Decl.h"
16#include "clang/AST/DeclBase.h"
18#include "clang/AST/Expr.h"
19
20using namespace clang;
21
22//===----------------------------------------------------------------------===//
23// OMPThreadPrivateDecl Implementation.
24//===----------------------------------------------------------------------===//
25
26void OMPThreadPrivateDecl::anchor() {}
27
29 DeclContext *DC,
33 C, DC, {}, VL.size(), L);
34 D->setVars(VL);
35 return D;
36}
37
44
45void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
46 assert(VL.size() == Data->getNumChildren() &&
47 "Number of variables is not the same as the preallocated buffer");
48 llvm::copy(VL, getVars().begin());
49}
50
51//===----------------------------------------------------------------------===//
52// OMPGroupPrivateDecl Implementation.
53//===----------------------------------------------------------------------===//
54
55void OMPGroupPrivateDecl::anchor() {}
56
61 C, DC, {}, VL.size(), L);
62 D->setVars(VL);
63 return D;
64}
65
72
73void OMPGroupPrivateDecl::setVars(ArrayRef<Expr *> VL) {
74 assert(VL.size() == Data->getNumChildren() &&
75 "Number of variables is not the same as the preallocated buffer");
76 llvm::copy(VL, getVars().begin());
77}
78
79//===----------------------------------------------------------------------===//
80// OMPAllocateDecl Implementation.
81//===----------------------------------------------------------------------===//
82
83void OMPAllocateDecl::anchor() { }
84
89 C, DC, CL, VL.size(), L);
90 D->setVars(VL);
91 return D;
92}
93
95 GlobalDeclID ID,
96 unsigned NVars,
97 unsigned NClauses) {
99 C, ID, NClauses, NVars, SourceLocation());
100}
101
102void OMPAllocateDecl::setVars(ArrayRef<Expr *> VL) {
103 assert(VL.size() == Data->getNumChildren() &&
104 "Number of variables is not the same as the preallocated buffer");
105 llvm::copy(VL, getVars().begin());
106}
107
108//===----------------------------------------------------------------------===//
109// OMPRequiresDecl Implementation.
110//===----------------------------------------------------------------------===//
111
112void OMPRequiresDecl::anchor() {}
113
120
127
128//===----------------------------------------------------------------------===//
129// OMPDeclareReductionDecl Implementation.
130//===----------------------------------------------------------------------===//
131
132OMPDeclareReductionDecl::OMPDeclareReductionDecl(
133 Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name,
134 QualType Ty, OMPDeclareReductionDecl *PrevDeclInScope)
135 : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr),
136 PrevDeclInScope(PrevDeclInScope) {
137 setInitializer(nullptr, OMPDeclareReductionInitKind::Call);
138}
139
140void OMPDeclareReductionDecl::anchor() {}
141
142OMPDeclareReductionDecl *OMPDeclareReductionDecl::Create(
144 QualType T, OMPDeclareReductionDecl *PrevDeclInScope) {
145 return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name,
146 T, PrevDeclInScope);
147}
148
151 return new (C, ID) OMPDeclareReductionDecl(
152 OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(),
153 QualType(), /*PrevDeclInScope=*/nullptr);
154}
155
157 return cast_or_null<OMPDeclareReductionDecl>(
158 PrevDeclInScope.get(getASTContext().getExternalSource()));
159}
162 return cast_or_null<OMPDeclareReductionDecl>(
163 PrevDeclInScope.get(getASTContext().getExternalSource()));
164}
165
166//===----------------------------------------------------------------------===//
167// OMPDeclareMapperDecl Implementation.
168//===----------------------------------------------------------------------===//
169
170void OMPDeclareMapperDecl::anchor() {}
171
172OMPDeclareMapperDecl *OMPDeclareMapperDecl::Create(
175 OMPDeclareMapperDecl *PrevDeclInScope) {
177 C, DC, Clauses, 1, L, Name, T, VarName, PrevDeclInScope);
178}
179
181 GlobalDeclID ID,
182 unsigned N) {
184 C, ID, N, 1, SourceLocation(), DeclarationName(), QualType(),
185 DeclarationName(), /*PrevDeclInScope=*/nullptr);
186}
187
189 return cast_or_null<OMPDeclareMapperDecl>(
190 PrevDeclInScope.get(getASTContext().getExternalSource()));
191}
192
193const OMPDeclareMapperDecl *OMPDeclareMapperDecl::getPrevDeclInScope() const {
194 return cast_or_null<OMPDeclareMapperDecl>(
195 PrevDeclInScope.get(getASTContext().getExternalSource()));
196}
197
198//===----------------------------------------------------------------------===//
199// OMPCapturedExprDecl Implementation.
200//===----------------------------------------------------------------------===//
201
202void OMPCapturedExprDecl::anchor() {}
203
206 SourceLocation StartLoc) {
207 return new (C, DC) OMPCapturedExprDecl(
208 C, DC, Id, T, C.getTrivialTypeSourceInfo(T), StartLoc);
209}
210
212 GlobalDeclID ID) {
213 return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType(),
214 /*TInfo=*/nullptr, SourceLocation());
215}
216
Defines the clang::ASTContext interface.
This file defines OpenMP nodes for declarative directives.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:188
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
DeclContext(Decl::Kind K)
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclBase.h:435
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:524
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:830
One of these records is kept for each identifier that is lexed.
static OMPAllocateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr * > VL, ArrayRef< OMPClause * > CL)
static OMPAllocateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NVars, unsigned NClauses)
static OMPCapturedExprDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, QualType T, SourceLocation StartLoc)
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static T * createEmptyDirective(const ASTContext &C, GlobalDeclID ID, unsigned NumClauses, unsigned NumChildren, Params &&... P)
Definition DeclOpenMP.h:62
static T * createDirective(const ASTContext &C, DeclContext *DC, ArrayRef< OMPClause * > Clauses, unsigned NumChildren, Params &&... P)
Definition DeclOpenMP.h:50
static OMPDeclareMapperDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned N)
Creates deserialized declare mapper node.
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
static OMPDeclareMapperDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, QualType T, DeclarationName VarName, ArrayRef< OMPClause * > Clauses, OMPDeclareMapperDecl *PrevDeclInScope)
Creates declare mapper node.
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
static OMPDeclareReductionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, QualType T, OMPDeclareReductionDecl *PrevDeclInScope)
Create declare reduction node.
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Create deserialized declare reduction node.
static OMPGroupPrivateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr * > VL)
static OMPGroupPrivateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned N)
static OMPRequiresDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned N)
Create deserialized requires node.
static OMPRequiresDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< OMPClause * > CL)
Create requires node.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned N)
static OMPThreadPrivateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr * > VL)
A (possibly-)qualified type.
Definition TypeBase.h:937
Encodes a location in the source.
A trivial tuple used to represent a source range.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:711
bool hasInit() const
Definition Decl.cpp:2398
const Expr * getInit() const
Definition Decl.h:1367
Definition SPIR.cpp:35
The JSON file list parser is used to communicate input to InstallAPI.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
const FunctionProtoType * T