@@ -6462,61 +6462,78 @@ class OMPNumTeamsClause final
64626462// / \endcode
64636463// / In this example directive '#pragma omp teams' has clause 'thread_limit'
64646464// / with single expression 'n'.
6465- class OMPThreadLimitClause : public OMPClause , public OMPClauseWithPreInit {
6466- friend class OMPClauseReader ;
6465+ // /
6466+ // / When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6467+ // / clause can accept up to three expressions.
6468+ // /
6469+ // / \code
6470+ // / #pragma omp target teams ompx_bare thread_limit(x, y, z)
6471+ // / \endcode
6472+ class OMPThreadLimitClause final
6473+ : public OMPVarListClause<OMPThreadLimitClause>,
6474+ public OMPClauseWithPreInit,
6475+ private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6476+ friend OMPVarListClause;
6477+ friend TrailingObjects;
64676478
64686479 // / Location of '('.
64696480 SourceLocation LParenLoc;
64706481
6471- // / ThreadLimit number.
6472- Stmt *ThreadLimit = nullptr ;
6482+ OMPThreadLimitClause (const ASTContext &C, SourceLocation StartLoc,
6483+ SourceLocation LParenLoc, SourceLocation EndLoc,
6484+ unsigned N)
6485+ : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6486+ EndLoc, N),
6487+ OMPClauseWithPreInit (this ) {}
64736488
6474- // / Set the ThreadLimit number.
6475- // /
6476- // / \param E ThreadLimit number.
6477- void setThreadLimit (Expr *E) { ThreadLimit = E; }
6489+ // / Build an empty clause.
6490+ OMPThreadLimitClause (unsigned N)
6491+ : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6492+ SourceLocation(), SourceLocation(), N),
6493+ OMPClauseWithPreInit(this ) {}
64786494
64796495public:
6480- // / Build 'thread_limit' clause.
6496+ // / Creates clause with a list of variables \a VL .
64816497 // /
6482- // / \param E Expression associated with this clause.
6483- // / \param HelperE Helper Expression associated with this clause.
6484- // / \param CaptureRegion Innermost OpenMP region where expressions in this
6485- // / clause must be captured.
6498+ // / \param C AST context.
64866499 // / \param StartLoc Starting location of the clause.
64876500 // / \param LParenLoc Location of '('.
64886501 // / \param EndLoc Ending location of the clause.
6489- OMPThreadLimitClause (Expr *E, Stmt *HelperE,
6490- OpenMPDirectiveKind CaptureRegion,
6491- SourceLocation StartLoc, SourceLocation LParenLoc,
6492- SourceLocation EndLoc)
6493- : OMPClause(llvm::omp::OMPC_thread_limit, StartLoc, EndLoc),
6494- OMPClauseWithPreInit (this ), LParenLoc(LParenLoc), ThreadLimit(E) {
6495- setPreInitStmt (HelperE, CaptureRegion);
6496- }
6502+ // / \param VL List of references to the variables.
6503+ // / \param PreInit
6504+ static OMPThreadLimitClause *
6505+ Create (const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6506+ SourceLocation StartLoc, SourceLocation LParenLoc,
6507+ SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
64976508
6498- // / Build an empty clause.
6499- OMPThreadLimitClause ()
6500- : OMPClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6501- SourceLocation()),
6502- OMPClauseWithPreInit( this ) {}
6509+ // / Creates an empty clause with \a N variables .
6510+ // /
6511+ // / \param C AST context.
6512+ // / \param N The number of variables.
6513+ static OMPThreadLimitClause * CreateEmpty ( const ASTContext &C, unsigned N);
65036514
65046515 // / Sets the location of '('.
65056516 void setLParenLoc (SourceLocation Loc) { LParenLoc = Loc; }
65066517
65076518 // / Returns the location of '('.
65086519 SourceLocation getLParenLoc () const { return LParenLoc; }
65096520
6510- // / Return ThreadLimit number .
6511- Expr *getThreadLimit () { return cast<Expr>(ThreadLimit ); }
6521+ // / Return ThreadLimit expressions .
6522+ ArrayRef< Expr *> getThreadLimit () { return getVarRefs ( ); }
65126523
6513- // / Return ThreadLimit number.
6514- Expr *getThreadLimit () const { return cast<Expr>(ThreadLimit); }
6524+ // / Return ThreadLimit expressions.
6525+ ArrayRef<Expr *> getThreadLimit () const {
6526+ return const_cast <OMPThreadLimitClause *>(this )->getThreadLimit ();
6527+ }
65156528
6516- child_range children () { return child_range (&ThreadLimit, &ThreadLimit + 1 ); }
6529+ child_range children () {
6530+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
6531+ reinterpret_cast <Stmt **>(varlist_end ()));
6532+ }
65176533
65186534 const_child_range children () const {
6519- return const_child_range (&ThreadLimit, &ThreadLimit + 1 );
6535+ auto Children = const_cast <OMPThreadLimitClause *>(this )->children ();
6536+ return const_child_range (Children.begin (), Children.end ());
65206537 }
65216538
65226539 child_range used_children () {
0 commit comments