From 19c95a313cbc80767602410b60d7e7d48ae90d18 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Mon, 14 Oct 2019 20:44:34 +0000 Subject: [OPNEMP]Allow num_tasks clause in combined task-based directives. The expression of the num_tasks clause must be captured in the combined task-based directives, like 'parallel master taskloop' directive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374819 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/OpenMPClause.h | 24 +++++++++++++++--------- include/clang/AST/RecursiveASTVisitor.h | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index db780f7ed3..911c1cfb77 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -5375,7 +5375,7 @@ public: /// \endcode /// In this example directive '#pragma omp taskloop' has clause 'num_tasks' /// with single expression '4'. -class OMPNumTasksClause : public OMPClause { +class OMPNumTasksClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// Location of '('. @@ -5391,16 +5391,23 @@ public: /// Build 'num_tasks' clause. /// /// \param Size Expression associated with this clause. + /// \param HelperSize Helper grainsize for the construct. + /// \param CaptureRegion Innermost OpenMP region where expressions in this + /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param EndLoc Ending location of the clause. - OMPNumTasksClause(Expr *Size, SourceLocation StartLoc, + OMPNumTasksClause(Expr *Size, Stmt *HelperSize, + OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc), - NumTasks(Size) {} + : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), OMPClauseWithPreInit(this), + LParenLoc(LParenLoc), NumTasks(Size) { + setPreInitStmt(HelperSize, CaptureRegion); + } /// Build an empty clause. explicit OMPNumTasksClause() - : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()) {} + : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()), + OMPClauseWithPreInit(this) {} /// Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } @@ -5417,11 +5424,10 @@ public: return const_child_range(&NumTasks, &NumTasks + 1); } - child_range used_children() { - return child_range(child_iterator(), child_iterator()); - } + child_range used_children(); const_child_range used_children() const { - return const_child_range(const_child_iterator(), const_child_iterator()); + auto Children = const_cast(this)->used_children(); + return const_child_range(Children.begin(), Children.end()); } static bool classof(const OMPClause *T) { diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index ba5232a2f4..09a6f7840d 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -3283,6 +3283,7 @@ bool RecursiveASTVisitor::VisitOMPGrainsizeClause( template bool RecursiveASTVisitor::VisitOMPNumTasksClause( OMPNumTasksClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getNumTasks())); return true; } -- cgit v1.2.1