From bc869de349227707a07ccc783344d255cf37ec16 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 10 May 2011 18:42:15 +0000 Subject: [PATCH] Elide __label__ declarations from the CFG. This resolves a crash in CFGRecStmtDeclVisitor (crash in static analyzer). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131141 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFG.cpp | 5 +++++ test/Analysis/misc-ps.m | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index de16334ce1..a247a9d194 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -1314,6 +1314,11 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(AbstractConditionalOperator *C, } CFGBlock *CFGBuilder::VisitDeclStmt(DeclStmt *DS) { + // Check if the Decl is for an __label__. If so, elide it from the + // CFG entirely. + if (isa(*DS->decl_begin())) + return Block; + if (DS->isSingleDecl()) return VisitDeclSubExpr(DS); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 9de4afb0ae..30532a8225 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1301,3 +1301,14 @@ static void test(unsigned int bit_mask) } } } + +// Don't crash on code containing __label__. +int radar9414427_aux(); +void radar9414427() { + __label__ mylabel; + if (radar9414427_aux()) { + mylabel: do {} + while (0); + } +} + -- 2.40.0