From: Jordan Rose Date: Mon, 19 Aug 2013 17:03:12 +0000 (+0000) Subject: [analyzer] Don't run unreachable code checker on inlined functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51718e3555404192040a5fad715367bc4cef22fb;p=clang [analyzer] Don't run unreachable code checker on inlined functions. This is still an alpha checker, but we use it in certain tests to make sure something is not being executed. This should fix the buildbots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188682 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 91c2ffb5aa..a40b5a3e83 100644 --- a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -67,9 +67,12 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, I != E; ++I) { const ProgramPoint &P = I->getLocation(); LC = P.getLocationContext(); + if (!LC->inTopFrame()) + continue; if (!D) D = LC->getAnalysisDeclContext()->getDecl(); + // Save the CFG if we don't have it already if (!C) C = LC->getAnalysisDeclContext()->getUnoptimizedCFG(); diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c index 61a4fd490e..08019d9cbe 100644 --- a/test/Analysis/unreachable-code-path.c +++ b/test/Analysis/unreachable-code-path.c @@ -139,3 +139,22 @@ void test11(enum foobar fb) { error(); // expected-warning {{never executed}} } } + +void inlined(int condition) { + if (condition) { + foo(5); // no-warning + } else { + foo(6); + } +} + +void testInlined() { + extern int coin(); + int cond = coin(); + if (!cond) { + inlined(0); + if (cond) { + foo(5); // expected-warning {{never executed}} + } + } +}