forked from OSchip/llvm-project
Fix crasher in CFRefCount.cpp reported by Nikita Zhuk due to recently added autorelease tracking.
llvm-svn: 71647
This commit is contained in:
parent
fce7bc924e
commit
051a03d698
|
|
@ -2154,6 +2154,9 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode<GRState>* N,
|
||||||
const ExplodedNode<GRState>* PrevN,
|
const ExplodedNode<GRState>* PrevN,
|
||||||
BugReporterContext& BRC) {
|
BugReporterContext& BRC) {
|
||||||
|
|
||||||
|
if (!isa<PostStmt>(N->getLocation()))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Check if the type state has changed.
|
// Check if the type state has changed.
|
||||||
GRStateManager &StMgr = BRC.getStateManager();
|
GRStateManager &StMgr = BRC.getStateManager();
|
||||||
GRStateRef PrevSt(PrevN->getState(), StMgr);
|
GRStateRef PrevSt(PrevN->getState(), StMgr);
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,33 @@ void f13(void) {
|
||||||
NSString *str = [[NSString alloc] init];
|
NSString *str = [[NSString alloc] init];
|
||||||
return [str autorelease]; // no-warning
|
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
|
@end
|
||||||
|
|
||||||
@interface C1 : NSObject {}
|
@interface C1 : NSObject {}
|
||||||
|
|
@ -298,8 +325,6 @@ void test_isTrackedObjectType(void) {
|
||||||
return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
|
return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Test @synchronized
|
// Test @synchronized
|
||||||
void test_synchronized(id x) {
|
void test_synchronized(id x) {
|
||||||
@synchronized(x) {
|
@synchronized(x) {
|
||||||
|
|
@ -307,4 +332,4 @@ void test_synchronized(id x) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test return from method starting with 'new' or 'copy'
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue