From 48f5a43bcc3b128aca54b99b565595a5fa6ad166 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 17 Jul 2019 18:03:39 +0000 Subject: [PATCH] [OPENMP]Fix PR42632: crash on the analysis of the OpenMP constructs. Fixed processing of the CapturedStmt children to fix the crash of the OpenMP constructs during analysis. llvm-svn: 366357 --- clang/lib/AST/ParentMap.cpp | 12 ++++++++++++ clang/test/Analysis/openmp-unsupported.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp index e09b5bb..2ff5c9d 100644 --- a/clang/lib/AST/ParentMap.cpp +++ b/clang/lib/AST/ParentMap.cpp @@ -83,6 +83,18 @@ static void BuildParentMap(MapTy& M, Stmt* S, } break; } + case Stmt::CapturedStmtClass: + for (Stmt *SubStmt : S->children()) { + if (SubStmt) { + M[SubStmt] = S; + BuildParentMap(M, SubStmt, OVMode); + } + } + if (Stmt *SubStmt = cast(S)->getCapturedStmt()) { + M[SubStmt] = S; + BuildParentMap(M, SubStmt, OVMode); + } + break; default: for (Stmt *SubStmt : S->children()) { if (SubStmt) { diff --git a/clang/test/Analysis/openmp-unsupported.c b/clang/test/Analysis/openmp-unsupported.c index 7e363ee..b2e1a1b 100644 --- a/clang/test/Analysis/openmp-unsupported.c +++ b/clang/test/Analysis/openmp-unsupported.c @@ -4,4 +4,8 @@ void openmp_parallel_crash_test() { #pragma omp parallel ; +#pragma omp parallel for + for (int i = 0; i < 8; ++i) + for (int j = 0, k = 0; j < 8; ++j) + ; } -- 2.7.4