@@ -156,51 +156,50 @@ class OpenACCSelfClause : public OpenACCClauseWithCondition {
156156 Expr *ConditionExpr, SourceLocation EndLoc);
157157};
158158
159- // / Represents a clause that has one or more IntExprs. It does not own the
160- // / IntExprs, but provides 'children' and other accessors.
161- class OpenACCClauseWithIntExprs : public OpenACCClauseWithParams {
162- MutableArrayRef<Expr *> IntExprs;
159+ // / Represents a clause that has one or more expressions associated with it.
160+ class OpenACCClauseWithExprs : public OpenACCClauseWithParams {
161+ MutableArrayRef<Expr *> Exprs;
163162
164163protected:
165- OpenACCClauseWithIntExprs (OpenACCClauseKind K, SourceLocation BeginLoc,
166- SourceLocation LParenLoc, SourceLocation EndLoc)
164+ OpenACCClauseWithExprs (OpenACCClauseKind K, SourceLocation BeginLoc,
165+ SourceLocation LParenLoc, SourceLocation EndLoc)
167166 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc) {}
168167
169168 // / Used only for initialization, the leaf class can initialize this to
170169 // / trailing storage.
171- void setIntExprs (MutableArrayRef<Expr *> NewIntExprs ) {
172- assert (IntExprs .empty () && " Cannot change IntExprs list" );
173- IntExprs = NewIntExprs ;
170+ void setExprs (MutableArrayRef<Expr *> NewExprs ) {
171+ assert (Exprs .empty () && " Cannot change Exprs list" );
172+ Exprs = NewExprs ;
174173 }
175174
176- // / Gets the entire list of integer expressions, but leave it to the
175+ // / Gets the entire list of expressions, but leave it to the
177176 // / individual clauses to expose this how they'd like.
178- llvm::ArrayRef<Expr *> getIntExprs () const { return IntExprs ; }
177+ llvm::ArrayRef<Expr *> getExprs () const { return Exprs ; }
179178
180179public:
181180 child_range children () {
182- return child_range (reinterpret_cast <Stmt **>(IntExprs .begin ()),
183- reinterpret_cast <Stmt **>(IntExprs .end ()));
181+ return child_range (reinterpret_cast <Stmt **>(Exprs .begin ()),
182+ reinterpret_cast <Stmt **>(Exprs .end ()));
184183 }
185184
186185 const_child_range children () const {
187186 child_range Children =
188- const_cast <OpenACCClauseWithIntExprs *>(this )->children ();
187+ const_cast <OpenACCClauseWithExprs *>(this )->children ();
189188 return const_child_range (Children.begin (), Children.end ());
190189 }
191190};
192191
193192class OpenACCNumGangsClause final
194- : public OpenACCClauseWithIntExprs ,
193+ : public OpenACCClauseWithExprs ,
195194 public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
196195
197196 OpenACCNumGangsClause (SourceLocation BeginLoc, SourceLocation LParenLoc,
198197 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
199- : OpenACCClauseWithIntExprs (OpenACCClauseKind::NumGangs, BeginLoc,
200- LParenLoc, EndLoc) {
198+ : OpenACCClauseWithExprs (OpenACCClauseKind::NumGangs, BeginLoc, LParenLoc ,
199+ EndLoc) {
201200 std::uninitialized_copy (IntExprs.begin (), IntExprs.end (),
202201 getTrailingObjects<Expr *>());
203- setIntExprs (MutableArrayRef (getTrailingObjects<Expr *>(), IntExprs.size ()));
202+ setExprs (MutableArrayRef (getTrailingObjects<Expr *>(), IntExprs.size ()));
204203 }
205204
206205public:
@@ -209,35 +208,35 @@ class OpenACCNumGangsClause final
209208 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
210209
211210 llvm::ArrayRef<Expr *> getIntExprs () {
212- return OpenACCClauseWithIntExprs::getIntExprs ();
211+ return OpenACCClauseWithExprs::getExprs ();
213212 }
214213
215214 llvm::ArrayRef<Expr *> getIntExprs () const {
216- return OpenACCClauseWithIntExprs::getIntExprs ();
215+ return OpenACCClauseWithExprs::getExprs ();
217216 }
218217};
219218
220219// / Represents one of a handful of clauses that have a single integer
221220// / expression.
222- class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithIntExprs {
221+ class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithExprs {
223222 Expr *IntExpr;
224223
225224protected:
226225 OpenACCClauseWithSingleIntExpr (OpenACCClauseKind K, SourceLocation BeginLoc,
227226 SourceLocation LParenLoc, Expr *IntExpr,
228227 SourceLocation EndLoc)
229- : OpenACCClauseWithIntExprs (K, BeginLoc, LParenLoc, EndLoc),
228+ : OpenACCClauseWithExprs (K, BeginLoc, LParenLoc, EndLoc),
230229 IntExpr (IntExpr) {
231- setIntExprs (MutableArrayRef<Expr *>{&this ->IntExpr , 1 });
230+ setExprs (MutableArrayRef<Expr *>{&this ->IntExpr , 1 });
232231 }
233232
234233public:
235- bool hasIntExpr () const { return !getIntExprs ().empty (); }
234+ bool hasIntExpr () const { return !getExprs ().empty (); }
236235 const Expr *getIntExpr () const {
237- return hasIntExpr () ? getIntExprs ()[0 ] : nullptr ;
236+ return hasIntExpr () ? getExprs ()[0 ] : nullptr ;
238237 }
239238
240- Expr *getIntExpr () { return hasIntExpr () ? getIntExprs ()[0 ] : nullptr ; };
239+ Expr *getIntExpr () { return hasIntExpr () ? getExprs ()[0 ] : nullptr ; };
241240};
242241
243242class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
@@ -261,6 +260,40 @@ class OpenACCVectorLengthClause : public OpenACCClauseWithSingleIntExpr {
261260 Expr *IntExpr, SourceLocation EndLoc);
262261};
263262
263+ // / Represents a clause with one or more 'var' objects, represented as an expr,
264+ // / as its arguments. Var-list is expected to be stored in trailing storage.
265+ // / For now, we're just storing the original expression in its entirety, unlike
266+ // / OMP which has to do a bunch of work to create a private.
267+ class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {
268+ protected:
269+ OpenACCClauseWithVarList (OpenACCClauseKind K, SourceLocation BeginLoc,
270+ SourceLocation LParenLoc, SourceLocation EndLoc)
271+ : OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc) {}
272+
273+ public:
274+ ArrayRef<Expr *> getVarList () { return getExprs (); }
275+ ArrayRef<Expr *> getVarList () const { return getExprs (); }
276+ };
277+
278+ class OpenACCPrivateClause final
279+ : public OpenACCClauseWithVarList,
280+ public llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
281+
282+ OpenACCPrivateClause (SourceLocation BeginLoc, SourceLocation LParenLoc,
283+ ArrayRef<Expr *> VarList, SourceLocation EndLoc)
284+ : OpenACCClauseWithVarList(OpenACCClauseKind::Private, BeginLoc,
285+ LParenLoc, EndLoc) {
286+ std::uninitialized_copy (VarList.begin (), VarList.end (),
287+ getTrailingObjects<Expr *>());
288+ setExprs (MutableArrayRef (getTrailingObjects<Expr *>(), VarList.size ()));
289+ }
290+
291+ public:
292+ static OpenACCPrivateClause *
293+ Create (const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
294+ ArrayRef<Expr *> VarList, SourceLocation EndLoc);
295+ };
296+
264297template <class Impl > class OpenACCClauseVisitor {
265298 Impl &getDerived () { return static_cast <Impl &>(*this ); }
266299
0 commit comments