13#ifndef LLVM_CLANG_AST_EXPROPENMP_H
14#define LLVM_CLANG_AST_EXPROPENMP_H
57 enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
58 Stmt *SubExprs[END_EXPR];
68 :
Expr(OMPArraySectionExprClass,
Type, VK, OK),
69 ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
70 RBracketLoc(RBracketLoc) {
71 SubExprs[BASE] =
Base;
72 SubExprs[LOWER_BOUND] = LowerBound;
73 SubExprs[LENGTH] = Length;
74 SubExprs[STRIDE] = Stride;
80 :
Expr(OMPArraySectionExprClass, Shell) {}
86 const Expr *
getBase()
const {
return cast<Expr>(SubExprs[BASE]); }
96 return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
103 const Expr *
getLength()
const {
return cast_or_null<Expr>(SubExprs[LENGTH]); }
109 const Expr *
getStride()
const {
return cast_or_null<Expr>(SubExprs[STRIDE]); }
136 return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
148 private llvm::TrailingObjects<OMPArrayShapingExpr, Expr *, SourceRange> {
149 friend TrailingObjects;
155 unsigned NumDims = 0;
163 :
Expr(OMPArrayShapingExprClass, Shell), NumDims(NumDims) {}
169 void setBase(
Expr *Op) { getTrailingObjects<Expr *>()[NumDims] = Op; }
172 void setBracketsRanges(ArrayRef<SourceRange> BR);
174 unsigned numTrailingObjects(OverloadToken<Expr *>)
const {
179 unsigned numTrailingObjects(OverloadToken<SourceRange>)
const {
184 static OMPArrayShapingExpr *
Create(
const ASTContext &Context, QualType T,
185 Expr *Op, SourceLocation L,
186 SourceLocation R, ArrayRef<Expr *> Dims,
187 ArrayRef<SourceRange> BracketRanges);
189 static OMPArrayShapingExpr *
CreateEmpty(
const ASTContext &Context,
210 return llvm::ArrayRef(getTrailingObjects<SourceRange>(), NumDims);
215 const Expr *
getBase()
const {
return getTrailingObjects<Expr *>()[NumDims]; }
223 Stmt **
Begin =
reinterpret_cast<Stmt **
>(getTrailingObjects<Expr *>());
228 reinterpret_cast<Stmt *
const *
>(getTrailingObjects<Expr *>());
274 private llvm::TrailingObjects<OMPIteratorExpr, Decl *, Expr *,
275 SourceLocation, OMPIteratorHelperData> {
292 friend TrailingObjects;
297 enum class RangeExprOffset {
305 enum class RangeLocOffset {
312 SourceLocation IteratorKwLoc;
314 SourceLocation LPLoc;
316 SourceLocation RPLoc;
318 unsigned NumIterators = 0;
320 OMPIteratorExpr(QualType ExprTy, SourceLocation IteratorKwLoc,
321 SourceLocation L, SourceLocation R,
322 ArrayRef<IteratorDefinition>
Data,
323 ArrayRef<OMPIteratorHelperData> Helpers);
326 explicit OMPIteratorExpr(EmptyShell Shell,
unsigned NumIterators)
327 :
Expr(OMPIteratorExprClass, Shell), NumIterators(NumIterators) {}
330 void setIteratorDeclaration(
unsigned I, Decl *D);
334 void setAssignmentLoc(
unsigned I, SourceLocation Loc);
338 void setIteratorRange(
unsigned I,
Expr *
Begin, SourceLocation ColonLoc,
339 Expr *End, SourceLocation SecondColonLoc,
Expr *Step);
342 void setHelper(
unsigned I,
const OMPIteratorHelperData &D);
344 unsigned numTrailingObjects(OverloadToken<Decl *>)
const {
348 unsigned numTrailingObjects(OverloadToken<Expr *>)
const {
349 return NumIterators *
static_cast<int>(RangeExprOffset::Total);
352 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
353 return NumIterators *
static_cast<int>(RangeLocOffset::Total);
357 static OMPIteratorExpr *
Create(
const ASTContext &Context, QualType T,
358 SourceLocation IteratorKwLoc, SourceLocation L,
360 ArrayRef<IteratorDefinition>
Data,
361 ArrayRef<OMPIteratorHelperData> Helpers);
363 static OMPIteratorExpr *
CreateEmpty(
const ASTContext &Context,
364 unsigned NumIterators);
411 Stmt **
Begin =
reinterpret_cast<Stmt **
>(getTrailingObjects<Expr *>());
413 Begin,
Begin + NumIterators *
static_cast<int>(RangeExprOffset::Total));
417 reinterpret_cast<Stmt *
const *
>(getTrailingObjects<Expr *>());
419 Begin,
Begin + NumIterators *
static_cast<int>(RangeExprOffset::Total));
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
OpenMP 5.0 [2.1.5, Array Sections].
void setStride(Expr *E)
Set length of the array section.
const Expr * getBase() const
Expr * getLength()
Get length of array section.
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getStride()
Get stride of array section.
SourceLocation getColonLocFirst() const
OMPArraySectionExpr(EmptyShell Shell)
Create an empty array section expression.
SourceLocation getExprLoc() const LLVM_READONLY
SourceLocation getColonLocSecond() const
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
static bool classof(const Stmt *T)
const Expr * getLowerBound() const
const_child_range children() const
void setLength(Expr *E)
Set length of the array section.
void setColonLocFirst(SourceLocation L)
const Expr * getStride() const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
SourceLocation getRBracketLoc() const
const Expr * getLength() const
void setLowerBound(Expr *E)
Set lower bound of the array section.
void setRBracketLoc(SourceLocation L)
void setBase(Expr *E)
Set base of the array section.
OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride, QualType Type, ExprValueKind VK, ExprObjectKind OK, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
Expr * getLowerBound()
Get lower bound of array section.
SourceLocation getEndLoc() const LLVM_READONLY
void setColonLocSecond(SourceLocation L)
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
const_child_range children() const
Expr * getBase()
Fetches base expression of array shaping expression.
void setLParenLoc(SourceLocation L)
SourceLocation getEndLoc() const LLVM_READONLY
static OMPArrayShapingExpr * CreateEmpty(const ASTContext &Context, unsigned NumDims)
static OMPArrayShapingExpr * Create(const ASTContext &Context, QualType T, Expr *Op, SourceLocation L, SourceLocation R, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketRanges)
SourceLocation getLParenLoc() const
ArrayRef< Expr * > getDimensions() const
Fetches the dimensions for array shaping expression.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setRParenLoc(SourceLocation L)
static bool classof(const Stmt *T)
ArrayRef< SourceRange > getBracketsRanges() const
Fetches source ranges for the brackets os the array shaping expression.
const Expr * getBase() const
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
static OMPIteratorExpr * Create(const ASTContext &Context, QualType T, SourceLocation IteratorKwLoc, SourceLocation L, SourceLocation R, ArrayRef< IteratorDefinition > Data, ArrayRef< OMPIteratorHelperData > Helpers)
void setLParenLoc(SourceLocation L)
SourceLocation getLParenLoc() const
static OMPIteratorExpr * CreateEmpty(const ASTContext &Context, unsigned NumIterators)
SourceLocation getSecondColonLoc(unsigned I) const
Gets the location of the second ':' (if any) in the range for the given iteratori definition.
void setRParenLoc(SourceLocation L)
SourceLocation getColonLoc(unsigned I) const
Gets the location of the first ':' in the range for the given iterator definition.
SourceLocation getRParenLoc() const
const IteratorRange getIteratorRange(unsigned I) const
SourceLocation getBeginLoc() const LLVM_READONLY
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
const Decl * getIteratorDecl(unsigned I) const
OMPIteratorHelperData & getHelper(unsigned I)
Fetches helper data for the specified iteration space.
const_child_range children() const
void setIteratorKwLoc(SourceLocation L)
SourceLocation getAssignLoc(unsigned I) const
Gets the location of '=' for the given iterator definition.
SourceLocation getIteratorKwLoc() const
unsigned numOfIterators() const
Returns number of iterator definitions.
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
SourceLocation getEndLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
A (possibly-)qualified type.
Encodes a location in the source.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
llvm::iterator_range< child_iterator > child_range
SourceLocation getBeginLoc() const LLVM_READONLY
llvm::iterator_range< const_child_iterator > const_child_range
The base class of the type hierarchy.
Represents a variable declaration or definition.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
ExprDependence computeDependence(FullExpr *E)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Iterator definition representation.
SourceLocation AssignmentLoc
SourceLocation SecondColonLoc
Iterator range representation begin:end[:step].
Helper expressions and declaration for OMPIteratorExpr class for each iteration space.
Expr * CounterUpdate
Updater for the internal counter: ++CounterVD;.
Expr * Upper
Normalized upper bound.
Expr * Update
Update expression for the originally specified iteration variable, calculated as VD = Begin + Counter...
VarDecl * CounterVD
Internal normalized counter.
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....