From 7482cce8b874cc5b3b44720f7e9fcd34e98f38d4 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Mon, 14 Oct 2019 19:29:52 +0000 Subject: [OPNEMP]Allow grainsize clause in combined task-based directives. The expression of the grainsize 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@374810 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 6c504c7701..db780f7ed3 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -5268,7 +5268,7 @@ public: /// \endcode /// In this example directive '#pragma omp taskloop' has clause 'grainsize' /// with single expression '4'. -class OMPGrainsizeClause : public OMPClause { +class OMPGrainsizeClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// Location of '('. @@ -5284,16 +5284,23 @@ public: /// Build 'grainsize' 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. - OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc, + OMPGrainsizeClause(Expr *Size, Stmt *HelperSize, + OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) - : OMPClause(OMPC_grainsize, StartLoc, EndLoc), LParenLoc(LParenLoc), - Grainsize(Size) {} + : OMPClause(OMPC_grainsize, StartLoc, EndLoc), OMPClauseWithPreInit(this), + LParenLoc(LParenLoc), Grainsize(Size) { + setPreInitStmt(HelperSize, CaptureRegion); + } /// Build an empty clause. explicit OMPGrainsizeClause() - : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()) {} + : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()), + OMPClauseWithPreInit(this) {} /// Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } @@ -5310,11 +5317,10 @@ public: return const_child_range(&Grainsize, &Grainsize + 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 cfeaec46c7..ba5232a2f4 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -3275,6 +3275,7 @@ bool RecursiveASTVisitor::VisitOMPPriorityClause( template bool RecursiveASTVisitor::VisitOMPGrainsizeClause( OMPGrainsizeClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getGrainsize())); return true; } -- cgit v1.2.1