clang 8.0.0

ExprOpenMP.h
Go to the documentation of this file.
1 //===--- ExprOpenMP.h - Classes for representing expressions ----*- C++ -*-===//
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 //
10 // This file defines the Expr interface and subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_AST_EXPROPENMP_H
15 #define LLVM_CLANG_AST_EXPROPENMP_H
16
17 #include "clang/AST/Expr.h"
18
19 namespace clang {
20 /// OpenMP 4.0 [2.4, Array Sections].
21 /// To specify an array section in an OpenMP construct, array subscript
22 /// expressions are extended with the following syntax:
23 /// \code
24 /// [ lower-bound : length ]
25 /// [ lower-bound : ]
26 /// [ : length ]
27 /// [ : ]
28 /// \endcode
29 /// The array section must be a subset of the original array.
30 /// Array sections are allowed on multidimensional arrays. Base language array
31 /// subscript expressions can be used to specify length-one dimensions of
32 /// multidimensional array sections.
33 /// The lower-bound and length are integral type expressions. When evaluated
34 /// they represent a set of integer values as follows:
35 /// \code
36 /// { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length -
37 /// 1 }
38 /// \endcode
39 /// The lower-bound and length must evaluate to non-negative integers.
40 /// When the size of the array dimension is not known, the length must be
41 /// specified explicitly.
42 /// When the length is absent, it defaults to the size of the array dimension
43 /// minus the lower-bound.
44 /// When the lower-bound is absent it defaults to 0.
45 class OMPArraySectionExpr : public Expr {
46 enum { BASE, LOWER_BOUND, LENGTH, END_EXPR };
47 Stmt *SubExprs[END_EXPR];
48 SourceLocation ColonLoc;
49 SourceLocation RBracketLoc;
50
51 public:
52 OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type,
53 ExprValueKind VK, ExprObjectKind OK,
54 SourceLocation ColonLoc, SourceLocation RBracketLoc)
55 : Expr(
56 OMPArraySectionExprClass, Type, VK, OK,
57 Base->isTypeDependent() ||
58 (LowerBound && LowerBound->isTypeDependent()) ||
59 (Length && Length->isTypeDependent()),
60 Base->isValueDependent() ||
61 (LowerBound && LowerBound->isValueDependent()) ||
62 (Length && Length->isValueDependent()),
63 Base->isInstantiationDependent() ||
64 (LowerBound && LowerBound->isInstantiationDependent()) ||
65 (Length && Length->isInstantiationDependent()),
66 Base->containsUnexpandedParameterPack() ||
67 (LowerBound && LowerBound->containsUnexpandedParameterPack()) ||
68 (Length && Length->containsUnexpandedParameterPack())),
69 ColonLoc(ColonLoc), RBracketLoc(RBracketLoc) {
70 SubExprs[BASE] = Base;
71 SubExprs[LOWER_BOUND] = LowerBound;
72 SubExprs[LENGTH] = Length;
73 }
74
75 /// Create an empty array section expression.
76 explicit OMPArraySectionExpr(EmptyShell Shell)
77 : Expr(OMPArraySectionExprClass, Shell) {}
78
79 /// An array section can be written only as Base[LowerBound:Length].
80
81 /// Get base of the array section.
82 Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
83 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
84 /// Set base of the array section.
85 void setBase(Expr *E) { SubExprs[BASE] = E; }
86
87 /// Return original type of the base expression for array section.
88 static QualType getBaseOriginalType(const Expr *Base);
89
90 /// Get lower bound of array section.
91 Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
92 const Expr *getLowerBound() const {
93 return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
94 }
95 /// Set lower bound of the array section.
96 void setLowerBound(Expr *E) { SubExprs[LOWER_BOUND] = E; }
97
98 /// Get length of array section.
99 Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
100 const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
101 /// Set length of the array section.
102 void setLength(Expr *E) { SubExprs[LENGTH] = E; }
103
104 SourceLocation getBeginLoc() const LLVM_READONLY {
105 return getBase()->getBeginLoc();
106 }
107 SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
108
109 SourceLocation getColonLoc() const { return ColonLoc; }
110 void setColonLoc(SourceLocation L) { ColonLoc = L; }
111
112 SourceLocation getRBracketLoc() const { return RBracketLoc; }
113 void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
114
115 SourceLocation getExprLoc() const LLVM_READONLY {
116 return getBase()->getExprLoc();
117 }
118
119 static bool classof(const Stmt *T) {
120 return T->getStmtClass() == OMPArraySectionExprClass;
121 }
122
123 child_range children() {
124 return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
125 }
126 };
127 } // end namespace clang
128
129 #endif
clang::OMPArraySectionExpr::getExprLoc
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprOpenMP.h:115
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
Base
clang::OMPArraySectionExpr::getLength
const Expr * getLength() const
Definition: ExprOpenMP.h:100
clang::OMPArraySectionExpr::getLowerBound
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:91
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1407
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1098
clang::OMPArraySectionExpr::setLength
void setLength(Expr *E)
Set length of the array section.
Definition: ExprOpenMP.h:102
clang::OMPArraySectionExpr::setBase
void setBase(Expr *E)
Set base of the array section.
Definition: ExprOpenMP.h:85
clang::OMPArraySectionExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprOpenMP.h:107
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:288
clang::OMPArraySectionExpr::OMPArraySectionExpr
OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type, ExprValueKind VK, ExprObjectKind OK, SourceLocation ColonLoc, SourceLocation RBracketLoc)
Definition: ExprOpenMP.h:52
clang::Expr::isTypeDependent
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:167
clang::OMPArraySectionExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprOpenMP.h:104
clang::OMPArraySectionExpr
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
clang::OMPArraySectionExpr::OMPArraySectionExpr
OMPArraySectionExpr(EmptyShell Shell)
Create an empty array section expression.
Definition: ExprOpenMP.h:76
clang::Expr
This represents one expression.
Definition: Expr.h:106
clang::ExprValueKind
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:107
clang::OMPArraySectionExpr::setRBracketLoc
void setRBracketLoc(SourceLocation L)
Definition: ExprOpenMP.h:113
clang::OMPArraySectionExpr::getRBracketLoc
SourceLocation getRBracketLoc() const
Definition: ExprOpenMP.h:112
clang::OMPArraySectionExpr::setColonLoc
void setColonLoc(SourceLocation L)
Definition: ExprOpenMP.h:110
clang::OMPArraySectionExpr::getBase
const Expr * getBase() const
Definition: ExprOpenMP.h:83
clang::Expr::isInstantiationDependent
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::OMPArraySectionExpr::getLowerBound
const Expr * getLowerBound() const
Definition: ExprOpenMP.h:92
clang::ExprObjectKind
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:124
clang::OMPArraySectionExpr::getColonLoc
SourceLocation getColonLoc() const
Definition: ExprOpenMP.h:109
clang::Expr::isValueDependent
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:149
clang::Stmt::EmptyShell
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:976
clang::Expr::getExprLoc
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:215
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::Stmt::getStmtClass
StmtClass getStmtClass() const
Definition: Stmt.h:1029
clang::OMPArraySectionExpr::setLowerBound
void setLowerBound(Expr *E)
Set lower bound of the array section.
Definition: ExprOpenMP.h:96
clang::OMPArraySectionExpr::children
child_range children()
Definition: ExprOpenMP.h:123
clang::OMPArraySectionExpr::getBaseOriginalType
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
Definition: Expr.cpp:4257
clang::Expr::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:214
Expr.h
clang::OMPArraySectionExpr::classof
static bool classof(const Stmt *T)
Definition: ExprOpenMP.h:119
clang::OMPArraySectionExpr::getLength
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:99
clang::OMPArraySectionExpr::getBase
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:82