From 2688e5894f901b98369460f563614d2a4ee4bb0e 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366357 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ParentMap.cpp | 12 ++++++++++++ test/Analysis/openmp-unsupported.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp index e09b5bbe75..2ff5c9d8ae 100644 --- a/lib/AST/ParentMap.cpp +++ b/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/test/Analysis/openmp-unsupported.c b/test/Analysis/openmp-unsupported.c index 7e363eecba..b2e1a1b021 100644 --- a/test/Analysis/openmp-unsupported.c +++ b/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.50.1