@@ -166,11 +166,6 @@ class OpenACCComputeConstruct final
166166 }
167167
168168 void setStructuredBlock (Stmt *S) { setAssociatedStmt (S); }
169- // Serialization helper function that searches the structured block for 'loop'
170- // constructs that should be associated with this, and sets their parent
171- // compute construct to this one. This isn't necessary normally, since we have
172- // the ability to record the state during parsing.
173- void findAndSetChildLoops ();
174169
175170public:
176171 static bool classof (const Stmt *T) {
@@ -204,6 +199,8 @@ class OpenACCLoopConstruct final
204199 friend class ASTStmtWriter ;
205200 friend class ASTStmtReader ;
206201 friend class ASTContext ;
202+ friend class OpenACCAssociatedStmtConstruct ;
203+ friend class OpenACCCombinedConstruct ;
207204 friend class OpenACCComputeConstruct ;
208205
209206 OpenACCLoopConstruct (unsigned NumClauses);
@@ -243,5 +240,57 @@ class OpenACCLoopConstruct final
243240 return ParentComputeConstructKind;
244241 }
245242};
243+
244+ // This class represents a 'combined' construct, which has a bunch of rules
245+ // shared with both loop and compute constructs.
246+ class OpenACCCombinedConstruct final
247+ : public OpenACCAssociatedStmtConstruct,
248+ public llvm::TrailingObjects<OpenACCCombinedConstruct,
249+ const OpenACCClause *> {
250+ OpenACCCombinedConstruct (unsigned NumClauses)
251+ : OpenACCAssociatedStmtConstruct(
252+ OpenACCCombinedConstructClass, OpenACCDirectiveKind::Invalid,
253+ SourceLocation{}, SourceLocation{}, SourceLocation{},
254+ /* AssociatedStmt=*/ nullptr ) {
255+ std::uninitialized_value_construct (
256+ getTrailingObjects<const OpenACCClause *>(),
257+ getTrailingObjects<const OpenACCClause *>() + NumClauses);
258+ setClauseList (MutableArrayRef (getTrailingObjects<const OpenACCClause *>(),
259+ NumClauses));
260+ }
261+
262+ OpenACCCombinedConstruct (OpenACCDirectiveKind K, SourceLocation Start,
263+ SourceLocation DirectiveLoc, SourceLocation End,
264+ ArrayRef<const OpenACCClause *> Clauses,
265+ Stmt *StructuredBlock)
266+ : OpenACCAssociatedStmtConstruct(OpenACCCombinedConstructClass, K, Start,
267+ DirectiveLoc, End, StructuredBlock) {
268+ assert (isOpenACCCombinedDirectiveKind (K) &&
269+ " Only parallel loop, serial loop, and kernels loop constructs "
270+ " should be represented by this type" );
271+
272+ std::uninitialized_copy (Clauses.begin (), Clauses.end (),
273+ getTrailingObjects<const OpenACCClause *>());
274+ setClauseList (MutableArrayRef (getTrailingObjects<const OpenACCClause *>(),
275+ Clauses.size ()));
276+ }
277+ void setStructuredBlock (Stmt *S) { setAssociatedStmt (S); }
278+
279+ public:
280+ static bool classof (const Stmt *T) {
281+ return T->getStmtClass () == OpenACCCombinedConstructClass;
282+ }
283+
284+ static OpenACCCombinedConstruct *CreateEmpty (const ASTContext &C,
285+ unsigned NumClauses);
286+ static OpenACCCombinedConstruct *
287+ Create (const ASTContext &C, OpenACCDirectiveKind K, SourceLocation Start,
288+ SourceLocation DirectiveLoc, SourceLocation End,
289+ ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock);
290+ Stmt *getLoop () { return getAssociatedStmt (); }
291+ const Stmt *getLoop () const {
292+ return const_cast <OpenACCCombinedConstruct *>(this )->getLoop ();
293+ }
294+ };
246295} // namespace clang
247296#endif // LLVM_CLANG_AST_STMTOPENACC_H
0 commit comments