Author: abataev Date: Wed Jul 1 01:57:41 2015 New Revision: 241145 URL: http://llvm.org/viewvc/llvm-project?rev=241145&view=rev Log: [OPENMP 4.0] Initial support for 'omp cancellation point' construct.
Add parsing and sema analysis for 'omp cancellation point' directive. Added: cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp (with props) cfe/trunk/test/OpenMP/cancellation_point_messages.cpp (with props) Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/StmtOpenMP.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/OpenMPKinds.def cfe/trunk/include/clang/Basic/StmtNodes.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Basic/OpenMPKinds.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jul 1 01:57:41 2015 @@ -2225,12 +2225,15 @@ enum CXCursorKind { */ CXCursor_OMPTeamsDirective = 253, - /** \brief OpenMP taskwait directive. + /** \brief OpenMP taskgroup directive. */ CXCursor_OMPTaskgroupDirective = 254, + /** \brief OpenMP cancellation point directive. + */ + CXCursor_OMPCancellationPointDirective = 255, - CXCursor_LastStmt = CXCursor_OMPTaskgroupDirective, + CXCursor_LastStmt = CXCursor_OMPCancellationPointDirective, /** * \brief Cursor that represents the translation unit itself. Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Wed Jul 1 01:57:41 2015 @@ -2358,6 +2358,9 @@ DEF_TRAVERSE_STMT(OMPTaskwaitDirective, DEF_TRAVERSE_STMT(OMPTaskgroupDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPCancellationPointDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPFlushDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Jul 1 01:57:41 2015 @@ -2391,6 +2391,9 @@ DEF_TRAVERSE_STMT(OMPTaskwaitDirective, DEF_TRAVERSE_STMT(OMPTaskgroupDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPCancellationPointDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPFlushDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original) +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Jul 1 01:57:41 2015 @@ -1856,6 +1856,64 @@ public: } }; +/// \brief This represents '#pragma omp cancellation point' directive. +/// +/// \code +/// #pragma omp cancellation point for +/// \endcode +/// +/// In this example a cancellation point is created for innermost 'for' region. +class OMPCancellationPointDirective : public OMPExecutableDirective { + friend class ASTStmtReader; + OpenMPDirectiveKind CancelRegion; + /// \brief Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + OMPD_cancellation_point, StartLoc, EndLoc, 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Build an empty directive. + /// + explicit OMPCancellationPointDirective() + : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + OMPD_cancellation_point, SourceLocation(), + SourceLocation(), 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Set cancel region for current cancellation point. + /// \param CR Cancellation region. + void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; } + +public: + /// \brief Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// + static OMPCancellationPointDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); + + /// \brief Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPCancellationPointDirective *CreateEmpty(const ASTContext &C, + EmptyShell); + + /// \brief Get cancellation region for the current cancellation point. + OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPCancellationPointDirectiveClass; + } +}; + } // end namespace clang #endif Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 1 01:57:41 2015 @@ -7611,6 +7611,12 @@ def err_omp_single_copyprivate_with_nowa "the 'copyprivate' clause must not be used with the 'nowait' clause">; def note_omp_nowait_clause_here : Note< "'nowait' clause is here">; +def err_omp_wrong_cancel_region : Error< + "one of 'for', 'parallel', 'sections' or 'taskgroup' is expected">; +def err_omp_parent_cancel_region_nowait : Error< + "parent region for 'omp %select{cancellation point/cancel}0' construct cannot be nowait">; +def err_omp_parent_cancel_region_ordered : Error< + "parent region for 'omp %select{cancellation point/cancel}0' construct cannot be ordered">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original) +++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Jul 1 01:57:41 2015 @@ -97,6 +97,7 @@ OPENMP_DIRECTIVE_EXT(parallel_for, "para OPENMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd") OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections") OPENMP_DIRECTIVE_EXT(for_simd, "for simd") +OPENMP_DIRECTIVE_EXT(cancellation_point, "cancellation point") // OpenMP clauses. OPENMP_CLAUSE(if, OMPIfClause) Modified: cfe/trunk/include/clang/Basic/StmtNodes.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/StmtNodes.td (original) +++ cfe/trunk/include/clang/Basic/StmtNodes.td Wed Jul 1 01:57:41 2015 @@ -205,3 +205,4 @@ def OMPOrderedDirective : DStmt<OMPExecu def OMPAtomicDirective : DStmt<OMPExecutableDirective>; def OMPTargetDirective : DStmt<OMPExecutableDirective>; def OMPTeamsDirective : DStmt<OMPExecutableDirective>; +def OMPCancellationPointDirective : DStmt<OMPExecutableDirective>; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jul 1 01:57:41 2015 @@ -7664,12 +7664,10 @@ public: /// /// \returns Statement for finished OpenMP region. StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses); - StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, - const DeclarationNameInfo &DirName, - ArrayRef<OMPClause *> Clauses, - Stmt *AStmt, - SourceLocation StartLoc, - SourceLocation EndLoc); + StmtResult ActOnOpenMPExecutableDirective( + OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, + OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); /// \brief Called on well-formed '\#pragma omp parallel' after parsing /// of the associated statement. StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, @@ -7775,6 +7773,11 @@ public: StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp cancellation point'. + StmtResult + ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original) +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Jul 1 01:57:41 2015 @@ -1397,6 +1397,7 @@ namespace clang { STMT_OMP_TARGET_DIRECTIVE, STMT_OMP_TEAMS_DIRECTIVE, STMT_OMP_TASKGROUP_DIRECTIVE, + STMT_OMP_CANCELLATION_POINT_DIRECTIVE, // ARC EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr Modified: cfe/trunk/lib/AST/Stmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/AST/Stmt.cpp (original) +++ cfe/trunk/lib/AST/Stmt.cpp Wed Jul 1 01:57:41 2015 @@ -2086,6 +2086,26 @@ OMPTaskgroupDirective *OMPTaskgroupDirec return new (Mem) OMPTaskgroupDirective(); } +OMPCancellationPointDirective *OMPCancellationPointDirective::Create( + const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion) { + unsigned Size = llvm::RoundUpToAlignment( + sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>()); + void *Mem = C.Allocate(Size); + OMPCancellationPointDirective *Dir = + new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc); + Dir->setCancelRegion(CancelRegion); + return Dir; +} + +OMPCancellationPointDirective * +OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { + unsigned Size = llvm::RoundUpToAlignment( + sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>()); + void *Mem = C.Allocate(Size); + return new (Mem) OMPCancellationPointDirective(); +} + OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Modified: cfe/trunk/lib/AST/StmtPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtPrinter.cpp (original) +++ cfe/trunk/lib/AST/StmtPrinter.cpp Wed Jul 1 01:57:41 2015 @@ -951,6 +951,12 @@ void StmtPrinter::VisitOMPTeamsDirective PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPCancellationPointDirective( + OMPCancellationPointDirective *Node) { + Indent() << "#pragma omp cancellation point " + << getOpenMPDirectiveName(Node->getCancelRegion()); + PrintOMPExecutableDirective(Node); +} //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtProfile.cpp (original) +++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Jul 1 01:57:41 2015 @@ -537,6 +537,11 @@ void StmtProfiler::VisitOMPTeamsDirectiv VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPCancellationPointDirective( + const OMPCancellationPointDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitExpr(const Expr *S) { VisitStmt(S); } Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original) +++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Jul 1 01:57:41 2015 @@ -347,6 +347,7 @@ bool clang::isAllowedClauseForDirective( case OMPD_barrier: case OMPD_taskwait: case OMPD_taskgroup: + case OMPD_cancellation_point: case OMPD_ordered: break; } Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Jul 1 01:57:41 2015 @@ -240,6 +240,9 @@ void CodeGenFunction::EmitStmt(const Stm case Stmt::OMPTeamsDirectiveClass: EmitOMPTeamsDirective(cast<OMPTeamsDirective>(*S)); break; + case Stmt::OMPCancellationPointDirectiveClass: + EmitOMPCancellationPointDirective(cast<OMPCancellationPointDirective>(*S)); + break; } } Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Jul 1 01:57:41 2015 @@ -2097,3 +2097,10 @@ void CodeGenFunction::EmitOMPTargetDirec void CodeGenFunction::EmitOMPTeamsDirective(const OMPTeamsDirective &) { llvm_unreachable("CodeGen for 'omp teams' is not supported yet."); } + +void CodeGenFunction::EmitOMPCancellationPointDirective( + const OMPCancellationPointDirective &S) { + llvm_unreachable( + "CodeGen for 'omp cancellation point' is not supported yet."); +} + Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Jul 1 01:57:41 2015 @@ -2202,6 +2202,8 @@ public: void EmitOMPAtomicDirective(const OMPAtomicDirective &S); void EmitOMPTargetDirective(const OMPTargetDirective &S); void EmitOMPTeamsDirective(const OMPTeamsDirective &S); + void + EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S); /// \brief Emit inner loop of the worksharing/simd construct. /// Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original) +++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Jul 1 01:57:41 2015 @@ -30,24 +30,39 @@ static OpenMPDirectiveKind ParseOpenMPDi // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd // TODO: add other combined directives in topological order. const OpenMPDirectiveKind F[][3] = { - { OMPD_for, OMPD_simd, OMPD_for_simd }, - { OMPD_parallel, OMPD_for, OMPD_parallel_for }, - { OMPD_parallel_for, OMPD_simd, OMPD_parallel_for_simd }, - { OMPD_parallel, OMPD_sections, OMPD_parallel_sections } - }; + {OMPD_unknown /*cancellation*/, OMPD_unknown /*point*/, + OMPD_cancellation_point}, + {OMPD_for, OMPD_simd, OMPD_for_simd}, + {OMPD_parallel, OMPD_for, OMPD_parallel_for}, + {OMPD_parallel_for, OMPD_simd, OMPD_parallel_for_simd}, + {OMPD_parallel, OMPD_sections, OMPD_parallel_sections}}; auto Tok = P.getCurToken(); auto DKind = Tok.isAnnotation() ? OMPD_unknown : getOpenMPDirectiveKind(P.getPreprocessor().getSpelling(Tok)); + bool TokenMatched = false; for (unsigned i = 0; i < llvm::array_lengthof(F); ++i) { - if (DKind == F[i][0]) { + if (!Tok.isAnnotation() && DKind == OMPD_unknown) { + TokenMatched = + (i == 0) && + !P.getPreprocessor().getSpelling(Tok).compare("cancellation"); + } else { + TokenMatched = DKind == F[i][0] && DKind != OMPD_unknown; + } + if (TokenMatched) { Tok = P.getPreprocessor().LookAhead(0); auto SDKind = Tok.isAnnotation() ? OMPD_unknown : getOpenMPDirectiveKind(P.getPreprocessor().getSpelling(Tok)); - if (SDKind == F[i][1]) { + if (!Tok.isAnnotation() && DKind == OMPD_unknown) { + TokenMatched = + (i == 0) && !P.getPreprocessor().getSpelling(Tok).compare("point"); + } else { + TokenMatched = SDKind == F[i][1] && SDKind != OMPD_unknown; + } + if (TokenMatched) { P.ConsumeToken(); DKind = F[i][2]; } @@ -110,6 +125,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen case OMPD_atomic: case OMPD_target: case OMPD_teams: + case OMPD_cancellation_point: Diag(Tok, diag::err_omp_unexpected_directive) << getOpenMPDirectiveName(DKind); break; @@ -145,6 +161,7 @@ Parser::ParseOpenMPDeclarativeOrExecutab Scope::FnScope | Scope::DeclScope | Scope::OpenMPDirectiveScope; SourceLocation Loc = ConsumeToken(), EndLoc; auto DKind = ParseOpenMPDirectiveKind(*this); + OpenMPDirectiveKind CancelRegion = OMPD_unknown; // Name of critical directive. DeclarationNameInfo DirName; StmtResult Directive = StmtError(); @@ -178,6 +195,7 @@ Parser::ParseOpenMPDeclarativeOrExecutab case OMPD_taskyield: case OMPD_barrier: case OMPD_taskwait: + case OMPD_cancellation_point: if (!StandAloneAllowed) { Diag(Tok, diag::err_omp_immediate_directive) << getOpenMPDirectiveName(DKind); @@ -217,6 +235,10 @@ Parser::ParseOpenMPDeclarativeOrExecutab } T.consumeClose(); } + } else if (DKind == OMPD_cancellation_point) { + CancelRegion = ParseOpenMPDirectiveKind(*this); + if (Tok.isNot(tok::annot_pragma_openmp_end)) + ConsumeToken(); } if (isOpenMPLoopDirective(DKind)) @@ -267,7 +289,8 @@ Parser::ParseOpenMPDeclarativeOrExecutab } if (CreateDirective) Directive = Actions.ActOnOpenMPExecutableDirective( - DKind, DirName, Clauses, AssociatedStmt.get(), Loc, EndLoc); + DKind, DirName, CancelRegion, Clauses, AssociatedStmt.get(), Loc, + EndLoc); // Exit scope. Actions.EndOpenMPDSABlock(Directive.get()); Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Jul 1 01:57:41 2015 @@ -95,19 +95,20 @@ private: Scope *CurScope; SourceLocation ConstructLoc; bool OrderedRegion; + bool NowaitRegion; unsigned CollapseNumber; SourceLocation InnerTeamsRegionLoc; SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name, Scope *CurScope, SourceLocation Loc) : SharingMap(), AlignedMap(), LCVSet(), DefaultAttr(DSA_unspecified), Directive(DKind), DirectiveName(std::move(Name)), CurScope(CurScope), - ConstructLoc(Loc), OrderedRegion(false), CollapseNumber(1), - InnerTeamsRegionLoc() {} + ConstructLoc(Loc), OrderedRegion(false), NowaitRegion(false), + CollapseNumber(1), InnerTeamsRegionLoc() {} SharingMapTy() : SharingMap(), AlignedMap(), LCVSet(), DefaultAttr(DSA_unspecified), Directive(OMPD_unknown), DirectiveName(), CurScope(nullptr), - ConstructLoc(), OrderedRegion(false), CollapseNumber(1), - InnerTeamsRegionLoc() {} + ConstructLoc(), OrderedRegion(false), NowaitRegion(false), + CollapseNumber(1), InnerTeamsRegionLoc() {} }; typedef SmallVector<SharingMapTy, 64> StackTy; @@ -232,6 +233,17 @@ public: return Stack[Stack.size() - 2].OrderedRegion; return false; } + /// \brief Marks current region as nowait (it has a 'nowait' clause). + void setNowaitRegion(bool IsNowait = true) { + Stack.back().NowaitRegion = IsNowait; + } + /// \brief Returns true, if parent region is nowait (has associated + /// 'nowait' clause), false - otherwise. + bool isParentNowaitRegion() const { + if (Stack.size() > 2) + return Stack[Stack.size() - 2].NowaitRegion; + return false; + } /// \brief Set collapse value for the region. void setCollapseNumber(unsigned Val) { Stack.back().CollapseNumber = Val; } @@ -1312,6 +1324,7 @@ void Sema::ActOnOpenMPRegionStart(OpenMP case OMPD_taskyield: case OMPD_barrier: case OMPD_taskwait: + case OMPD_cancellation_point: case OMPD_flush: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: @@ -1352,6 +1365,7 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, OpenMPDirectiveKind CurrentRegion, const DeclarationNameInfo &CurrentName, + OpenMPDirectiveKind CancelRegion, SourceLocation StartLoc) { // Allowed nesting of constructs // +------------------+-----------------+------------------------------------+ @@ -1379,6 +1393,8 @@ static bool CheckNestingOfRegions(Sema & // | parallel | atomic | * | // | parallel | target | * | // | parallel | teams | + | + // | parallel | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | for | parallel | * | // | for | for | + | @@ -1402,6 +1418,8 @@ static bool CheckNestingOfRegions(Sema & // | for | atomic | * | // | for | target | * | // | for | teams | + | + // | for | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | master | parallel | * | // | master | for | + | @@ -1425,6 +1443,8 @@ static bool CheckNestingOfRegions(Sema & // | master | atomic | * | // | master | target | * | // | master | teams | + | + // | master | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | critical | parallel | * | // | critical | for | + | @@ -1447,6 +1467,8 @@ static bool CheckNestingOfRegions(Sema & // | critical | atomic | * | // | critical | target | * | // | critical | teams | + | + // | critical | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | simd | parallel | | // | simd | for | | @@ -1470,6 +1492,8 @@ static bool CheckNestingOfRegions(Sema & // | simd | atomic | | // | simd | target | | // | simd | teams | | + // | simd | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | for simd | parallel | | // | for simd | for | | @@ -1493,6 +1517,8 @@ static bool CheckNestingOfRegions(Sema & // | for simd | atomic | | // | for simd | target | | // | for simd | teams | | + // | for simd | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | parallel for simd| parallel | | // | parallel for simd| for | | @@ -1516,6 +1542,8 @@ static bool CheckNestingOfRegions(Sema & // | parallel for simd| atomic | | // | parallel for simd| target | | // | parallel for simd| teams | | + // | parallel for simd| cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | sections | parallel | * | // | sections | for | + | @@ -1539,6 +1567,8 @@ static bool CheckNestingOfRegions(Sema & // | sections | atomic | * | // | sections | target | * | // | sections | teams | + | + // | sections | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | section | parallel | * | // | section | for | + | @@ -1562,6 +1592,8 @@ static bool CheckNestingOfRegions(Sema & // | section | atomic | * | // | section | target | * | // | section | teams | + | + // | section | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | single | parallel | * | // | single | for | + | @@ -1585,6 +1617,8 @@ static bool CheckNestingOfRegions(Sema & // | single | atomic | * | // | single | target | * | // | single | teams | + | + // | single | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | parallel for | parallel | * | // | parallel for | for | + | @@ -1608,6 +1642,8 @@ static bool CheckNestingOfRegions(Sema & // | parallel for | atomic | * | // | parallel for | target | * | // | parallel for | teams | + | + // | parallel for | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | parallel sections| parallel | * | // | parallel sections| for | + | @@ -1631,6 +1667,8 @@ static bool CheckNestingOfRegions(Sema & // | parallel sections| atomic | * | // | parallel sections| target | * | // | parallel sections| teams | + | + // | parallel sections| cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | task | parallel | * | // | task | for | + | @@ -1654,6 +1692,8 @@ static bool CheckNestingOfRegions(Sema & // | task | atomic | * | // | task | target | * | // | task | teams | + | + // | task | cancellation | | + // | | point | ! | // +------------------+-----------------+------------------------------------+ // | ordered | parallel | * | // | ordered | for | + | @@ -1677,6 +1717,8 @@ static bool CheckNestingOfRegions(Sema & // | ordered | atomic | * | // | ordered | target | * | // | ordered | teams | + | + // | ordered | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | atomic | parallel | | // | atomic | for | | @@ -1700,6 +1742,8 @@ static bool CheckNestingOfRegions(Sema & // | atomic | atomic | | // | atomic | target | | // | atomic | teams | | + // | atomic | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | target | parallel | * | // | target | for | * | @@ -1723,6 +1767,8 @@ static bool CheckNestingOfRegions(Sema & // | target | atomic | * | // | target | target | * | // | target | teams | * | + // | target | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ // | teams | parallel | * | // | teams | for | + | @@ -1746,6 +1792,8 @@ static bool CheckNestingOfRegions(Sema & // | teams | atomic | + | // | teams | target | + | // | teams | teams | + | + // | teams | cancellation | | + // | | point | | // +------------------+-----------------+------------------------------------+ if (Stack->getCurScope()) { auto ParentRegion = Stack->getParentDirective(); @@ -1787,7 +1835,20 @@ static bool CheckNestingOfRegions(Sema & // called from OpenMP regions with the required preconditions). if (ParentRegion == OMPD_unknown) return false; - if (CurrentRegion == OMPD_master) { + if (CurrentRegion == OMPD_cancellation_point) { + // OpenMP [2.16, Nesting of Regions] + // A cancellation point construct for which construct-type-clause is + // taskgroup must be nested inside a task construct. A cancellation + // point construct for which construct-type-clause is not taskgroup must + // be closely nested inside an OpenMP construct that matches the type + // specified in construct-type-clause. + NestingProhibited = + !((CancelRegion == OMPD_parallel && ParentRegion == OMPD_parallel) || + (CancelRegion == OMPD_for && ParentRegion == OMPD_for) || + (CancelRegion == OMPD_taskgroup && ParentRegion == OMPD_task) || + (CancelRegion == OMPD_sections && + (ParentRegion == OMPD_section || ParentRegion == OMPD_sections))); + } else if (CurrentRegion == OMPD_master) { // OpenMP [2.16, Nesting of Regions] // A master region may not be closely nested inside a worksharing, // atomic, or explicit task region. @@ -1877,14 +1938,13 @@ static bool CheckNestingOfRegions(Sema & return false; } -StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, - const DeclarationNameInfo &DirName, - ArrayRef<OMPClause *> Clauses, - Stmt *AStmt, - SourceLocation StartLoc, - SourceLocation EndLoc) { +StmtResult Sema::ActOnOpenMPExecutableDirective( + OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, + OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) { StmtResult Res = StmtError(); - if (CheckNestingOfRegions(*this, DSAStack, Kind, DirName, StartLoc)) + if (CheckNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion, + StartLoc)) return StmtError(); llvm::SmallVector<OMPClause *, 8> ClausesWithImplicit; @@ -2018,6 +2078,13 @@ StmtResult Sema::ActOnOpenMPExecutableDi Res = ActOnOpenMPTargetDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); break; + case OMPD_cancellation_point: + assert(ClausesWithImplicit.empty() && + "No clauses are allowed for 'omp cancellation point' directive"); + assert(AStmt == nullptr && "No associated statement allowed for 'omp " + "cancellation point' directive"); + Res = ActOnOpenMPCancellationPointDirective(StartLoc, EndLoc, CancelRegion); + break; case OMPD_threadprivate: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: @@ -4204,6 +4271,28 @@ StmtResult Sema::ActOnOpenMPTeamsDirecti return OMPTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt); } +StmtResult +Sema::ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion) { + if (CancelRegion != OMPD_parallel && CancelRegion != OMPD_for && + CancelRegion != OMPD_sections && CancelRegion != OMPD_taskgroup) { + Diag(StartLoc, diag::err_omp_wrong_cancel_region) + << getOpenMPDirectiveName(CancelRegion); + return StmtError(); + } + if (DSAStack->isParentNowaitRegion()) { + Diag(StartLoc, diag::err_omp_parent_cancel_region_nowait) << 0; + return StmtError(); + } + if (DSAStack->isParentOrderedRegion()) { + Diag(StartLoc, diag::err_omp_parent_cancel_region_ordered) << 0; + return StmtError(); + } + return OMPCancellationPointDirective::Create(Context, StartLoc, EndLoc, + CancelRegion); +} + OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -4722,6 +4811,7 @@ OMPClause *Sema::ActOnOpenMPOrderedClaus OMPClause *Sema::ActOnOpenMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc) { + DSAStack->setNowaitRegion(); return new (Context) OMPNowaitClause(StartLoc, EndLoc); } Modified: cfe/trunk/lib/Sema/TreeTransform.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Sema/TreeTransform.h (original) +++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jul 1 01:57:41 2015 @@ -1321,11 +1321,12 @@ public: /// Subclasses may override this routine to provide different behavior. StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, + OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) { - return getSema().ActOnOpenMPExecutableDirective(Kind, DirName, Clauses, - AStmt, StartLoc, EndLoc); + return getSema().ActOnOpenMPExecutableDirective( + Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc); } /// \brief Build a new OpenMP 'if' clause. @@ -6715,10 +6716,14 @@ StmtResult TreeTransform<Derived>::Trans DirName = cast<OMPCriticalDirective>(D)->getDirectiveName(); DirName = getDerived().TransformDeclarationNameInfo(DirName); } + OpenMPDirectiveKind CancelRegion = OMPD_unknown; + if (D->getDirectiveKind() == OMPD_cancellation_point) { + CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion(); + } return getDerived().RebuildOMPExecutableDirective( - D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(), - D->getLocStart(), D->getLocEnd()); + D->getDirectiveKind(), DirName, CancelRegion, TClauses, + AssociatedStmt.get(), D->getLocStart(), D->getLocEnd()); } template <typename Derived> @@ -6960,6 +6965,17 @@ TreeTransform<Derived>::TransformOMPTeam StmtResult Res = getDerived().TransformOMPExecutableDirective(D); getDerived().getSema().EndOpenMPDSABlock(Res.get()); return Res; +} + +template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPCancellationPointDirective( + OMPCancellationPointDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName, + nullptr, D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; } //===----------------------------------------------------------------------===// Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Wed Jul 1 01:57:41 2015 @@ -2249,6 +2249,13 @@ void ASTStmtReader::VisitOMPTeamsDirecti VisitOMPExecutableDirective(D); } +void ASTStmtReader::VisitOMPCancellationPointDirective( + OMPCancellationPointDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); + D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record[Idx++])); +} + //===----------------------------------------------------------------------===// // ASTReader Implementation //===----------------------------------------------------------------------===// @@ -2852,6 +2859,10 @@ Stmt *ASTReader::ReadStmtFromStream(Modu Context, Record[ASTStmtReader::NumStmtFields], Empty); break; + case STMT_OMP_CANCELLATION_POINT_DIRECTIVE: + S = OMPCancellationPointDirective::CreateEmpty(Context, Empty); + break; + case EXPR_CXX_OPERATOR_CALL: S = new (Context) CXXOperatorCallExpr(Context, Empty); break; Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original) +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Wed Jul 1 01:57:41 2015 @@ -2107,6 +2107,14 @@ void ASTStmtWriter::VisitOMPTeamsDirecti Code = serialization::STMT_OMP_TEAMS_DIRECTIVE; } +void ASTStmtWriter::VisitOMPCancellationPointDirective( + OMPCancellationPointDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); + Record.push_back(D->getCancelRegion()); + Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE; +} + //===----------------------------------------------------------------------===// // ASTWriter Implementation //===----------------------------------------------------------------------===// Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Jul 1 01:57:41 2015 @@ -822,6 +822,7 @@ void ExprEngine::Visit(const Stmt *S, Ex case Stmt::OMPAtomicDirectiveClass: case Stmt::OMPTargetDirectiveClass: case Stmt::OMPTeamsDirectiveClass: + case Stmt::OMPCancellationPointDirectiveClass: llvm_unreachable("Stmt should not be in analyzer evaluation loop"); case Stmt::ObjCSubscriptRefExprClass: Added: cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp?rev=241145&view=auto ============================================================================== --- cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp (added) +++ cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp Wed Jul 1 01:57:41 2015 @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +int main (int argc, char **argv) { +// CHECK: int main(int argc, char **argv) { +#pragma omp parallel +{ +#pragma omp cancellation point parallel +} +// CHECK: #pragma omp parallel +// CHECK-NEXT: { +// CHECK-NEXT: #pragma omp cancellation point parallel +// CHECK-NEXT: } +#pragma omp sections +{ +#pragma omp cancellation point sections +} +// CHECK-NEXT: #pragma omp sections +// CHECK: { +// CHECK: #pragma omp cancellation point sections +// CHECK: } +#pragma omp for +for (int i = 0; i < argc; ++i) { +#pragma omp cancellation point for +} +// CHECK: #pragma omp for +// CHECK-NEXT: for (int i = 0; i < argc; ++i) { +// CHECK-NEXT: #pragma omp cancellation point for +// CHECK-NEXT: } +#pragma omp task +{ +#pragma omp cancellation point taskgroup +} +// CHECK: #pragma omp task +// CHECK: { +// CHECK: #pragma omp cancellation point taskgroup +// CHECK: } +// CHECK: return argc; + return argc; +} + +#endif Propchange: cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: cfe/trunk/test/OpenMP/cancellation_point_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation_point_messages.cpp?rev=241145&view=auto ============================================================================== --- cfe/trunk/test/OpenMP/cancellation_point_messages.cpp (added) +++ cfe/trunk/test/OpenMP/cancellation_point_messages.cpp Wed Jul 1 01:57:41 2015 @@ -0,0 +1,83 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +int main(int argc, char **argv) { +#pragma omp cancellation // expected-error {{expected an OpenMP directive}} +#pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} + ; +#pragma omp cancellation point parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancellation point'}} +#pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} +#pragma omp cancellation point sections( // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} +#pragma omp cancellation point for, ) // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} +#pragma omp cancellation point taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} +#pragma omp cancellation point parallel, if // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} + if (argc) +#pragma omp cancellation point for // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + if (argc) { +#pragma omp taskgroup +#pragma omp task +#pragma omp parallel + { +#pragma omp cancellation point taskgroup // expected-error {{region cannot be closely nested inside 'parallel' region}} + } + } +#pragma omp parallel +#pragma omp taskgroup + { +#pragma omp cancellation point taskgroup // expected-error {{region cannot be closely nested inside 'taskgroup' region}} + } +#pragma omp parallel + { +#pragma omp cancellation point for // expected-error {{region cannot be closely nested inside 'parallel' region}} + } +#pragma omp task + { +#pragma omp cancellation point sections // expected-error {{region cannot be closely nested inside 'task' region}} + } +#pragma omp sections + { +#pragma omp cancellation point parallel // expected-error {{region cannot be closely nested inside 'sections' region}} + } + while (argc) +#pragma omp cancellation point for // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + while (argc) { +#pragma omp cancellation point sections + } + do +#pragma omp cancellation point parallel // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + while (argc) + ; + do { +#pragma omp cancellation point taskgroup + } while (argc); + switch (argc) +#pragma omp cancellation point parallel // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + switch (argc) + case 1: +#pragma omp cancellation point sections // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + switch (argc) + case 1: { +#pragma omp cancellation point for + } + switch (argc) { +#pragma omp cancellation point taskgroup + case 1: +#pragma omp cancellation point parallel // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + break; + default: { +#pragma omp cancellation point sections + } break; + } + for (;;) +#pragma omp cancellation point for // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} + for (;;) { +#pragma omp cancellation point taskgroup + } +label: +#pragma omp cancellation point parallel // expected-error {{'#pragma omp cancellation point' cannot be an immediate substatement}} +label1 : { +#pragma omp cancellation point sections +} + + return 0; +} + Propchange: cfe/trunk/test/OpenMP/cancellation_point_messages.cpp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cfe/trunk/test/OpenMP/cancellation_point_messages.cpp ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: cfe/trunk/test/OpenMP/cancellation_point_messages.cpp ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jul 1 01:57:41 2015 @@ -1880,6 +1880,8 @@ public: void VisitOMPBarrierDirective(const OMPBarrierDirective *D); void VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *D); void VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *D); + void + VisitOMPCancellationPointDirective(const OMPCancellationPointDirective *D); void VisitOMPFlushDirective(const OMPFlushDirective *D); void VisitOMPOrderedDirective(const OMPOrderedDirective *D); void VisitOMPAtomicDirective(const OMPAtomicDirective *D); @@ -2507,6 +2509,11 @@ void EnqueueVisitor::VisitOMPTeamsDirect VisitOMPExecutableDirective(D); } +void EnqueueVisitor::VisitOMPCancellationPointDirective( + const OMPCancellationPointDirective *D) { + VisitOMPExecutableDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4283,6 +4290,8 @@ CXString clang_getCursorKindSpelling(enu return cxstring::createRef("OMPTargetDirective"); case CXCursor_OMPTeamsDirective: return cxstring::createRef("OMPTeamsDirective"); + case CXCursor_OMPCancellationPointDirective: + return cxstring::createRef("OMPCancellationPointDirective"); case CXCursor_OverloadCandidate: return cxstring::createRef("OverloadCandidate"); } Modified: cfe/trunk/tools/libclang/CXCursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=241145&r1=241144&r2=241145&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CXCursor.cpp (original) +++ cfe/trunk/tools/libclang/CXCursor.cpp Wed Jul 1 01:57:41 2015 @@ -588,6 +588,9 @@ CXCursor cxcursor::MakeCXCursor(const St case Stmt::OMPTeamsDirectiveClass: K = CXCursor_OMPTeamsDirective; break; + case Stmt::OMPCancellationPointDirectiveClass: + K = CXCursor_OMPCancellationPointDirective; + break; } CXCursor C = { K, 0, { Parent, S, TU } }; _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits