17
17
#include " clang/AST/ASTContext.h"
18
18
19
19
namespace clang {
20
- // / OmpSs 4.0 [2.4, Array Sections] .
21
- // / To specify an array section in an OmpSs construct, array subscript
20
+ // / OmpSs-2 Array Sections.
21
+ // / To specify an array section in an OmpSs-2 construct, array subscript
22
22
// / expressions are extended with the following syntax:
23
23
// / \code
24
- // / [ lower-bound : length ]
25
- // / [ lower-bound : ]
26
- // / [ : length ]
27
- // / [ : ]
24
+ // / depend(in : [ lower-bound : length ])
25
+ // / depend(in : [ lower-bound : ])
26
+ // / depend(in : [ : length ])
27
+ // / depend(in : [ : ])
28
+ // /
29
+ // / in([ lower-bound ; length ])
30
+ // / in([ lower-bound ; ])
31
+ // / in([ ; length ])
32
+ // / in([ ; ])
33
+ // /
34
+ // / in([ lower-bound : upper-bound ])
35
+ // / in([ lower-bound : ])
36
+ // / in([ : upper-bound ])
37
+ // / in([ : ])
38
+ // /
28
39
// / \endcode
29
40
// / The array section must be a subset of the original array.
30
41
// / Array sections are allowed on multidimensional arrays. Base language array
31
42
// / subscript expressions can be used to specify length-one dimensions of
32
43
// / 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:
44
+ // / The lower-bound, upper-bound and length are integral type expressions.
45
+ // / When evaluated they represent a set of integer values as follows:
35
46
// / \code
36
47
// / { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length -
37
48
// / 1 }
49
+ // /
50
+ // / { lower-bound, lower-bound + 1, lower-bound + 2,... , upper-bound }
38
51
// / \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.
52
+ // / The lower-bound, upper-bound and length must evaluate to non-negative integers.
53
+ // / When the size of the array dimension is not known, the length/upper-bound
54
+ // / must be specified explicitly.
42
55
// / When the length is absent, it defaults to the size of the array dimension
43
56
// / minus the lower-bound.
57
+ // / When the upper-bound is absent, it defaults to the size of the
58
+ // / array dimension - 1
44
59
// / When the lower-bound is absent it defaults to 0.
45
60
class OSSArraySectionExpr : public Expr {
46
- enum { BASE, LOWER_BOUND, LENGTH , END_EXPR };
61
+ enum { BASE, LOWER_BOUND, LENGTH_UPPER , END_EXPR };
47
62
Stmt *SubExprs[END_EXPR];
48
63
SourceLocation ColonLoc;
49
64
SourceLocation RBracketLoc;
65
+ bool ColonForm;
50
66
51
67
public:
52
- OSSArraySectionExpr (Expr *Base, Expr *LowerBound, Expr *Length , QualType Type,
68
+ OSSArraySectionExpr (Expr *Base, Expr *LowerBound, Expr *LengthUpper , QualType Type,
53
69
ExprValueKind VK, ExprObjectKind OK,
54
- SourceLocation ColonLoc, SourceLocation RBracketLoc)
70
+ SourceLocation ColonLoc, SourceLocation RBracketLoc,
71
+ bool ColonForm)
55
72
: Expr(
56
73
OSSArraySectionExprClass, Type, VK, OK,
57
74
Base->isTypeDependent () ||
58
75
(LowerBound && LowerBound->isTypeDependent ()) ||
59
- (Length && Length ->isTypeDependent ()),
76
+ (LengthUpper && LengthUpper ->isTypeDependent ()),
60
77
Base->isValueDependent() ||
61
78
(LowerBound && LowerBound->isValueDependent ()) ||
62
- (Length && Length ->isValueDependent ()),
79
+ (LengthUpper && LengthUpper ->isValueDependent ()),
63
80
Base->isInstantiationDependent() ||
64
81
(LowerBound && LowerBound->isInstantiationDependent ()) ||
65
- (Length && Length ->isInstantiationDependent ()),
82
+ (LengthUpper && LengthUpper ->isInstantiationDependent ()),
66
83
Base->containsUnexpandedParameterPack() ||
67
84
(LowerBound && LowerBound->containsUnexpandedParameterPack ()) ||
68
- (Length && Length ->containsUnexpandedParameterPack ())),
69
- ColonLoc(ColonLoc), RBracketLoc(RBracketLoc) {
85
+ (LengthUpper && LengthUpper ->containsUnexpandedParameterPack ())),
86
+ ColonLoc(ColonLoc), RBracketLoc(RBracketLoc), ColonForm(ColonForm) {
70
87
SubExprs[BASE] = Base;
71
88
SubExprs[LOWER_BOUND] = LowerBound;
72
- SubExprs[LENGTH ] = Length ;
89
+ SubExprs[LENGTH_UPPER ] = LengthUpper ;
73
90
}
74
91
75
92
// / Create an empty array section expression.
76
93
explicit OSSArraySectionExpr (EmptyShell Shell)
77
94
: Expr(OSSArraySectionExprClass, Shell) {}
78
95
79
- // / An array section can be written only as Base[LowerBound:Length].
96
+ // / An array section can be written as:
97
+ // / Base[LowerBound : Length]
98
+ // / Base[LowerBound ; Length]
99
+ // / Base[LowerBound : UpperBound]
80
100
81
101
// / Get base of the array section.
82
102
Expr *getBase () { return cast<Expr>(SubExprs[BASE]); }
@@ -95,11 +115,14 @@ class OSSArraySectionExpr : public Expr {
95
115
// / Set lower bound of the array section.
96
116
void setLowerBound (Expr *E) { SubExprs[LOWER_BOUND] = E; }
97
117
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; }
118
+ // / Get length or upper-bound of array section.
119
+ Expr *getLengthUpper () { return cast_or_null<Expr>(SubExprs[LENGTH_UPPER]); }
120
+ const Expr *getLengthUpper () const { return cast_or_null<Expr>(SubExprs[LENGTH_UPPER]); }
121
+ // / Set length or upper-bound of the array section.
122
+ void setLengthUpper (Expr *E) { SubExprs[LENGTH_UPPER] = E; }
123
+
124
+ // Get section form ';' or ':'
125
+ bool isColonForm () const { return ColonForm; }
103
126
104
127
SourceLocation getBeginLoc () const LLVM_READONLY {
105
128
return getBase ()->getBeginLoc ();
0 commit comments