From 3392d760816d869c9589c81275c7c98ecefc226d Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 16 Feb 2016 11:18:12 +0000 Subject: [OPENMP] Improved handling of pseudo-captured expressions in OpenMP. Expressions inside 'schedule'|'dist_schedule' clause must be captured in combined directives to avoid possible crash during codegen. Patch improves handling of such constructs llvm-svn: 260954 --- clang/lib/AST/StmtProfile.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'clang/lib/AST/StmtProfile.cpp') diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index d2f241c312a..02b59756e3d 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -268,8 +268,15 @@ public: #define OPENMP_CLAUSE(Name, Class) \ void Visit##Class(const Class *C); #include "clang/Basic/OpenMPKinds.def" + void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); }; +void OMPClauseProfiler::VistOMPClauseWithPreInit( + const OMPClauseWithPreInit *C) { + if (auto *S = C->getPreInitStmt()) + Profiler->VisitStmt(S); +} + void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) { if (C->getCondition()) Profiler->VisitStmt(C->getCondition()); @@ -305,12 +312,9 @@ void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { - if (C->getChunkSize()) { - Profiler->VisitStmt(C->getChunkSize()); - if (C->getHelperChunkSize()) { - Profiler->VisitStmt(C->getChunkSize()); - } - } + VistOMPClauseWithPreInit(C); + if (auto *S = C->getChunkSize()) + Profiler->VisitStmt(S); } void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { @@ -633,12 +637,9 @@ void StmtProfiler::VisitOMPDistributeDirective( void OMPClauseProfiler::VisitOMPDistScheduleClause( const OMPDistScheduleClause *C) { - if (C->getChunkSize()) { - Profiler->VisitStmt(C->getChunkSize()); - if (C->getHelperChunkSize()) { - Profiler->VisitStmt(C->getChunkSize()); - } - } + VistOMPClauseWithPreInit(C); + if (auto *S = C->getChunkSize()) + Profiler->VisitStmt(S); } void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {} -- cgit v1.2.3