clang 10.0.0git

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