r188682 - [analyzer] Don't run unreachable code checker on inlined functions.
Jordan Rose
jordan_rose at apple.com
Mon Aug 19 10:03:12 PDT 2013
Author: jrose
Date: Mon Aug 19 12:03:12 2013
New Revision: 188682
URL: http://llvm.org/viewvc/llvm-project?rev=188682&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
cfe/trunk/test/Analysis/unreachable-code-path.c
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp?rev=188682&r1=188681&r2=188682&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp Mon Aug 19 12:03:12 2013
@@ -67,9 +67,12 @@ void UnreachableCodeChecker::checkEndAna
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();
Modified: cfe/trunk/test/Analysis/unreachable-code-path.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unreachable-code-path.c?rev=188682&r1=188681&r2=188682&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/unreachable-code-path.c (original)
+++ cfe/trunk/test/Analysis/unreachable-code-path.c Mon Aug 19 12:03:12 2013
@@ -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}}
+ }
+ }
+}
More information about the cfe-commits
mailing list