@@ -6369,60 +6369,77 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
63696369// / \endcode
63706370// / In this example directive '#pragma omp teams' has clause 'num_teams'
63716371// / with single expression 'n'.
6372- class OMPNumTeamsClause : public OMPClause , public OMPClauseWithPreInit {
6373- friend class OMPClauseReader ;
6372+ // /
6373+ // / When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6374+ // / can accept up to three expressions.
6375+ // /
6376+ // / \code
6377+ // / #pragma omp target teams ompx_bare num_teams(x, y, z)
6378+ // / \endcode
6379+ class OMPNumTeamsClause final
6380+ : public OMPVarListClause<OMPNumTeamsClause>,
6381+ public OMPClauseWithPreInit,
6382+ private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6383+ friend OMPVarListClause;
6384+ friend TrailingObjects;
63746385
63756386 // / Location of '('.
63766387 SourceLocation LParenLoc;
63776388
6378- // / NumTeams number.
6379- Stmt *NumTeams = nullptr ;
6389+ OMPNumTeamsClause (const ASTContext &C, SourceLocation StartLoc,
6390+ SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6391+ : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6392+ N),
6393+ OMPClauseWithPreInit (this ) {}
63806394
6381- // / Set the NumTeams number.
6382- // /
6383- // / \param E NumTeams number.
6384- void setNumTeams (Expr *E) { NumTeams = E; }
6395+ // / Build an empty clause.
6396+ OMPNumTeamsClause (unsigned N)
6397+ : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6398+ SourceLocation(), SourceLocation(), N),
6399+ OMPClauseWithPreInit(this ) {}
63856400
63866401public:
6387- // / Build 'num_teams' clause.
6402+ // / Creates clause with a list of variables \a VL .
63886403 // /
6389- // / \param E Expression associated with this clause.
6390- // / \param HelperE Helper Expression associated with this clause.
6391- // / \param CaptureRegion Innermost OpenMP region where expressions in this
6392- // / clause must be captured.
6404+ // / \param C AST context.
63936405 // / \param StartLoc Starting location of the clause.
63946406 // / \param LParenLoc Location of '('.
63956407 // / \param EndLoc Ending location of the clause.
6396- OMPNumTeamsClause (Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
6397- SourceLocation StartLoc, SourceLocation LParenLoc,
6398- SourceLocation EndLoc)
6399- : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc),
6400- OMPClauseWithPreInit (this ), LParenLoc(LParenLoc), NumTeams(E) {
6401- setPreInitStmt (HelperE, CaptureRegion);
6402- }
6408+ // / \param VL List of references to the variables.
6409+ // / \param PreInit
6410+ static OMPNumTeamsClause *
6411+ Create (const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6412+ SourceLocation StartLoc, SourceLocation LParenLoc,
6413+ SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
64036414
6404- // / Build an empty clause.
6405- OMPNumTeamsClause ()
6406- : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6407- SourceLocation()),
6408- OMPClauseWithPreInit( this ) {}
6415+ // / Creates an empty clause with \a N variables .
6416+ // /
6417+ // / \param C AST context.
6418+ // / \param N The number of variables.
6419+ static OMPNumTeamsClause * CreateEmpty ( const ASTContext &C, unsigned N);
64096420
64106421 // / Sets the location of '('.
64116422 void setLParenLoc (SourceLocation Loc) { LParenLoc = Loc; }
64126423
64136424 // / Returns the location of '('.
64146425 SourceLocation getLParenLoc () const { return LParenLoc; }
64156426
6416- // / Return NumTeams number .
6417- Expr *getNumTeams () { return cast<Expr>(NumTeams ); }
6427+ // / Return NumTeams expressions .
6428+ ArrayRef< Expr *> getNumTeams () { return getVarRefs ( ); }
64186429
6419- // / Return NumTeams number.
6420- Expr *getNumTeams () const { return cast<Expr>(NumTeams); }
6430+ // / Return NumTeams expressions.
6431+ ArrayRef<Expr *> getNumTeams () const {
6432+ return const_cast <OMPNumTeamsClause *>(this )->getNumTeams ();
6433+ }
64216434
6422- child_range children () { return child_range (&NumTeams, &NumTeams + 1 ); }
6435+ child_range children () {
6436+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
6437+ reinterpret_cast <Stmt **>(varlist_end ()));
6438+ }
64236439
64246440 const_child_range children () const {
6425- return const_child_range (&NumTeams, &NumTeams + 1 );
6441+ auto Children = const_cast <OMPNumTeamsClause *>(this )->children ();
6442+ return const_child_range (Children.begin (), Children.end ());
64266443 }
64276444
64286445 child_range used_children () {
0 commit comments