1717#include " clang/AST/ASTContext.h"
1818
1919namespace 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
2222// / expressions are extended with the following syntax:
2323// / \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+ // /
2839// / \endcode
2940// / The array section must be a subset of the original array.
3041// / Array sections are allowed on multidimensional arrays. Base language array
3142// / subscript expressions can be used to specify length-one dimensions of
3243// / 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:
3546// / \code
3647// / { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length -
3748// / 1 }
49+ // /
50+ // / { lower-bound, lower-bound + 1, lower-bound + 2,... , upper-bound }
3851// / \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.
4255// / When the length is absent, it defaults to the size of the array dimension
4356// / minus the lower-bound.
57+ // / When the upper-bound is absent, it defaults to the size of the
58+ // / array dimension - 1
4459// / When the lower-bound is absent it defaults to 0.
4560class OSSArraySectionExpr : public Expr {
46- enum { BASE, LOWER_BOUND, LENGTH , END_EXPR };
61+ enum { BASE, LOWER_BOUND, LENGTH_UPPER , END_EXPR };
4762 Stmt *SubExprs[END_EXPR];
4863 SourceLocation ColonLoc;
4964 SourceLocation RBracketLoc;
65+ bool ColonForm;
5066
5167public:
52- OSSArraySectionExpr (Expr *Base, Expr *LowerBound, Expr *Length , QualType Type,
68+ OSSArraySectionExpr (Expr *Base, Expr *LowerBound, Expr *LengthUpper , QualType Type,
5369 ExprValueKind VK, ExprObjectKind OK,
54- SourceLocation ColonLoc, SourceLocation RBracketLoc)
70+ SourceLocation ColonLoc, SourceLocation RBracketLoc,
71+ bool ColonForm)
5572 : Expr(
5673 OSSArraySectionExprClass, Type, VK, OK,
5774 Base->isTypeDependent () ||
5875 (LowerBound && LowerBound->isTypeDependent ()) ||
59- (Length && Length ->isTypeDependent ()),
76+ (LengthUpper && LengthUpper ->isTypeDependent ()),
6077 Base->isValueDependent() ||
6178 (LowerBound && LowerBound->isValueDependent ()) ||
62- (Length && Length ->isValueDependent ()),
79+ (LengthUpper && LengthUpper ->isValueDependent ()),
6380 Base->isInstantiationDependent() ||
6481 (LowerBound && LowerBound->isInstantiationDependent ()) ||
65- (Length && Length ->isInstantiationDependent ()),
82+ (LengthUpper && LengthUpper ->isInstantiationDependent ()),
6683 Base->containsUnexpandedParameterPack() ||
6784 (LowerBound && LowerBound->containsUnexpandedParameterPack ()) ||
68- (Length && Length ->containsUnexpandedParameterPack ())),
69- ColonLoc(ColonLoc), RBracketLoc(RBracketLoc) {
85+ (LengthUpper && LengthUpper ->containsUnexpandedParameterPack ())),
86+ ColonLoc(ColonLoc), RBracketLoc(RBracketLoc), ColonForm(ColonForm) {
7087 SubExprs[BASE] = Base;
7188 SubExprs[LOWER_BOUND] = LowerBound;
72- SubExprs[LENGTH ] = Length ;
89+ SubExprs[LENGTH_UPPER ] = LengthUpper ;
7390 }
7491
7592 // / Create an empty array section expression.
7693 explicit OSSArraySectionExpr (EmptyShell Shell)
7794 : Expr(OSSArraySectionExprClass, Shell) {}
7895
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]
80100
81101 // / Get base of the array section.
82102 Expr *getBase () { return cast<Expr>(SubExprs[BASE]); }
@@ -95,11 +115,14 @@ class OSSArraySectionExpr : public Expr {
95115 // / Set lower bound of the array section.
96116 void setLowerBound (Expr *E) { SubExprs[LOWER_BOUND] = E; }
97117
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; }
103126
104127 SourceLocation getBeginLoc () const LLVM_READONLY {
105128 return getBase ()->getBeginLoc ();
0 commit comments