@@ -6131,60 +6131,77 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
61316131// / \endcode
61326132// / In this example directive '#pragma omp teams' has clause 'num_teams'
61336133// / with single expression 'n'.
6134- class OMPNumTeamsClause : public OMPClause , public OMPClauseWithPreInit {
6135- friend class OMPClauseReader ;
6134+ // /
6135+ // / When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6136+ // / can accept up to three expressions.
6137+ // /
6138+ // / \code
6139+ // / #pragma omp target teams ompx_bare num_teams(x, y, z)
6140+ // / \endcode
6141+ class OMPNumTeamsClause final
6142+ : public OMPVarListClause<OMPNumTeamsClause>,
6143+ public OMPClauseWithPreInit,
6144+ private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6145+ friend OMPVarListClause;
6146+ friend TrailingObjects;
61366147
61376148 // / Location of '('.
61386149 SourceLocation LParenLoc;
61396150
6140- // / NumTeams number.
6141- Stmt *NumTeams = nullptr ;
6151+ OMPNumTeamsClause (const ASTContext &C, SourceLocation StartLoc,
6152+ SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6153+ : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6154+ N),
6155+ OMPClauseWithPreInit (this ) {}
61426156
6143- // / Set the NumTeams number.
6144- // /
6145- // / \param E NumTeams number.
6146- void setNumTeams (Expr *E) { NumTeams = E; }
6157+ // / Build an empty clause.
6158+ OMPNumTeamsClause (unsigned N)
6159+ : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6160+ SourceLocation(), SourceLocation(), N),
6161+ OMPClauseWithPreInit(this ) {}
61476162
61486163public:
6149- // / Build 'num_teams' clause.
6164+ // / Creates clause with a list of variables \a VL .
61506165 // /
6151- // / \param E Expression associated with this clause.
6152- // / \param HelperE Helper Expression associated with this clause.
6153- // / \param CaptureRegion Innermost OpenMP region where expressions in this
6154- // / clause must be captured.
6166+ // / \param C AST context.
61556167 // / \param StartLoc Starting location of the clause.
61566168 // / \param LParenLoc Location of '('.
61576169 // / \param EndLoc Ending location of the clause.
6158- OMPNumTeamsClause (Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
6159- SourceLocation StartLoc, SourceLocation LParenLoc,
6160- SourceLocation EndLoc)
6161- : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc),
6162- OMPClauseWithPreInit (this ), LParenLoc(LParenLoc), NumTeams(E) {
6163- setPreInitStmt (HelperE, CaptureRegion);
6164- }
6170+ // / \param VL List of references to the variables.
6171+ // / \param PreInit
6172+ static OMPNumTeamsClause *
6173+ Create (const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6174+ SourceLocation StartLoc, SourceLocation LParenLoc,
6175+ SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
61656176
6166- // / Build an empty clause.
6167- OMPNumTeamsClause ()
6168- : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6169- SourceLocation()),
6170- OMPClauseWithPreInit( this ) {}
6177+ // / Creates an empty clause with \a N variables .
6178+ // /
6179+ // / \param C AST context.
6180+ // / \param N The number of variables.
6181+ static OMPNumTeamsClause * CreateEmpty ( const ASTContext &C, unsigned N);
61716182
61726183 // / Sets the location of '('.
61736184 void setLParenLoc (SourceLocation Loc) { LParenLoc = Loc; }
61746185
61756186 // / Returns the location of '('.
61766187 SourceLocation getLParenLoc () const { return LParenLoc; }
61776188
6178- // / Return NumTeams number .
6179- Expr *getNumTeams () { return cast<Expr>(NumTeams ); }
6189+ // / Return NumTeams expressions .
6190+ ArrayRef< Expr *> getNumTeams () { return getVarRefs ( ); }
61806191
6181- // / Return NumTeams number.
6182- Expr *getNumTeams () const { return cast<Expr>(NumTeams); }
6192+ // / Return NumTeams expressions.
6193+ ArrayRef<Expr *> getNumTeams () const {
6194+ return const_cast <OMPNumTeamsClause *>(this )->getNumTeams ();
6195+ }
61836196
6184- child_range children () { return child_range (&NumTeams, &NumTeams + 1 ); }
6197+ child_range children () {
6198+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
6199+ reinterpret_cast <Stmt **>(varlist_end ()));
6200+ }
61856201
61866202 const_child_range children () const {
6187- return const_child_range (&NumTeams, &NumTeams + 1 );
6203+ auto Children = const_cast <OMPNumTeamsClause *>(this )->children ();
6204+ return const_child_range (Children.begin (), Children.end ());
61886205 }
61896206
61906207 child_range used_children () {
0 commit comments