Author: zaks
Date: Fri Feb 24 10:49:46 2012
New Revision: 151369
URL: http://llvm.org/viewvc/llvm-project?rev=151369&view=rev
Log:
[analyzer] Run remove dead bindings before each call.
This ensures that we report the bugs associated with symbols going
out of scope in the correct function context.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/keychainAPI.m
cfe/trunk/test/Analysis/malloc-interprocedural.c
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=151369&r1=151368&r2=151369&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Feb 24 10:49:46 2012
@@ -230,7 +230,11 @@
// Is this on a non-expression?
if (!isa<Expr>(S.getStmt()))
return true;
-
+
+ // Run before processing a call.
+ if (isa<CallExpr>(S.getStmt()))
+ return true;
+
// Is this an expression that is consumed by another expression? If so,
// postpone cleaning out the state.
ParentMap &PM = LC->getAnalysisDeclContext()->getParentMap();
Modified: cfe/trunk/test/Analysis/keychainAPI.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/keychainAPI.m?rev=151369&r1=151368&r2=151369&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/keychainAPI.m (original)
+++ cfe/trunk/test/Analysis/keychainAPI.m Fri Feb 24 10:49:46 2012
@@ -274,8 +274,8 @@
char * x;
st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
if (st == noErr) {
- CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length,
5, 0, kCFAllocatorNull); // expected-warning{{Allocated data is not released}}
- CFRelease(userStr);
+ CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length,
5, 0, kCFAllocatorNull);
+ CFRelease(userStr); // expected-warning{{Allocated data is not released}}
}
}
Modified: cfe/trunk/test/Analysis/malloc-interprocedural.c
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-interprocedural.c?rev=151369&r1=151368&r2=151369&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/malloc-interprocedural.c (original)
+++ cfe/trunk/test/Analysis/malloc-interprocedural.c Fri Feb 24 10:49:46 2012
@@ -70,6 +70,16 @@
my_free1((int*)data);
}
+static char *reshape(char *in) {
+ return 0;
+}
+
+void testThatRemoveDeadBindingsRunBeforeEachCall() {
+ char *v = malloc(12);
+ v = reshape(v);
+ v = reshape(v);// expected-warning {{Memory is never released; potential
memory leak}}
+}
+
// Test that we keep processing after 'return;'
void fooWithEmptyReturn(int x) {
if (x)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits