[cfe-commits] r71647 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/NSString.m
Ted Kremenek
kremenek at apple.com
Wed May 13 00:12:34 PDT 2009
Author: kremenek
Date: Wed May 13 02:12:33 2009
New Revision: 71647
URL: http://llvm.org/viewvc/llvm-project?rev=71647&view=rev
Log:
Fix crasher in CFRefCount.cpp reported by Nikita Zhuk due to recently added autorelease tracking.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/test/Analysis/NSString.m
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=71647&r1=71646&r2=71647&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Wed May 13 02:12:33 2009
@@ -2154,6 +2154,9 @@
const ExplodedNode<GRState>* PrevN,
BugReporterContext& BRC) {
+ if (!isa<PostStmt>(N->getLocation()))
+ return NULL;
+
// Check if the type state has changed.
GRStateManager &StMgr = BRC.getStateManager();
GRStateRef PrevSt(PrevN->getState(), StMgr);
@@ -2373,8 +2376,8 @@
if (os.str().empty())
return 0; // We have nothing to say!
-
- Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
+
+ Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
PathDiagnosticLocation Pos(S, BRC.getSourceManager());
PathDiagnosticPiece* P = new PathDiagnosticEventPiece(Pos, os.str());
Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=71647&r1=71646&r2=71647&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Wed May 13 02:12:33 2009
@@ -183,6 +183,33 @@
NSString *str = [[NSString alloc] init];
return [str autorelease]; // no-warning
}
+- (void)m1
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+ [s autorelease];
+}
+- (void)m2
+{
+ NSString *s = [[[NSString alloc] init] autorelease]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m3
+{
+ NSString *s = [[[NSString alloc] init] autorelease];
+ [s retain];
+ [s autorelease];
+}
+- (void)m4
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m5
+{
+ NSString *s = [[NSString alloc] init];
+ [s autorelease];
+}
@end
@interface C1 : NSObject {}
@@ -298,8 +325,6 @@
return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
}
-
-
// Test @synchronized
void test_synchronized(id x) {
@synchronized(x) {
@@ -307,4 +332,4 @@
}
}
-// Test return from method starting with 'new' or 'copy'
+
More information about the cfe-commits
mailing list