diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-02-16 11:18:12 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-02-16 11:18:12 +0000 |
commit | 3392d760816d869c9589c81275c7c98ecefc226d (patch) | |
tree | 24f9d08060c382bdd33d45b1fb34d2ac56c0ef7c /clang/lib/AST/StmtPrinter.cpp | |
parent | 6b4c0b5b663841f3c6702e5c1999b599bf1687ca (diff) | |
download | bcm5719-llvm-3392d760816d869c9589c81275c7c98ecefc226d.tar.gz bcm5719-llvm-3392d760816d869c9589c81275c7c98ecefc226d.zip |
[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
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 3ee63e020ae..5013fa620eb 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -664,9 +664,16 @@ void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) { OS << ": "; } OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind()); - if (Node->getChunkSize()) { + if (auto *E = Node->getChunkSize()) { OS << ", "; - Node->getChunkSize()->printPretty(OS, nullptr, Policy); + if (Node->getPreInitStmt()) { + cast<OMPCapturedExprDecl>( + cast<DeclRefExpr>(E->IgnoreImpCasts())->getDecl()) + ->getInit() + ->IgnoreImpCasts() + ->printPretty(OS, nullptr, Policy); + } else + E->printPretty(OS, nullptr, Policy); } OS << ")"; } @@ -769,7 +776,7 @@ void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { OS << (I == Node->varlist_begin() ? StartSym : ','); if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) { if (auto *CED = dyn_cast<OMPCapturedExprDecl>(DRE->getDecl())) - CED->getInit()->printPretty(OS, nullptr, Policy, 0); + CED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy, 0); else DRE->getDecl()->printQualifiedName(OS); } else @@ -915,9 +922,16 @@ void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) { void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) { OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName( OMPC_dist_schedule, Node->getDistScheduleKind()); - if (Node->getChunkSize()) { + if (auto *E = Node->getChunkSize()) { OS << ", "; - Node->getChunkSize()->printPretty(OS, nullptr, Policy); + if (Node->getPreInitStmt()) { + cast<OMPCapturedExprDecl>( + cast<DeclRefExpr>(E->IgnoreImpCasts())->getDecl()) + ->getInit() + ->IgnoreImpCasts() + ->printPretty(OS, nullptr, Policy); + } else + E->printPretty(OS, nullptr, Policy); } OS << ")"; } |