]> granicus.if.org Git - clang/commitdiff
[analyzer] Don't run unreachable code checker on inlined functions.
authorJordan Rose <jordan_rose@apple.com>
Mon, 19 Aug 2013 17:03:12 +0000 (17:03 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 19 Aug 2013 17:03:12 +0000 (17:03 +0000)
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

lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
test/Analysis/unreachable-code-path.c

index 91c2ffb5aabf8ab3f2bb1b70ae1f5994f43f5098..a40b5a3e8378ec37fb013fa3af07af21fda4d17b 100644 (file)
@@ -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();
index 61a4fd490e94e8e9f17e9b5e535f6f041b4d3648..08019d9cbe319e91ca1b6a605eac9756e7d5aee6 100644 (file)
@@ -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}}
+    }
+  }
+}