It lives! The retain/release checker now tracks objects that are sent

'autorelease'.

llvm-svn: 71307
This commit is contained in:
Ted Kremenek 2009-05-09 01:50:57 +00:00
parent 8326c2fdfc
commit 2d0ff62a0d
2 changed files with 28 additions and 5 deletions

View File

@ -175,8 +175,7 @@ public:
ExplodedNode<GRState> *MakeNode(const GRState *state,
ExplodedNode<GRState> *Pred) {
if (SNB)
return SNB->generateNode(PostStmt(S, tag), state,
Pred);
return SNB->generateNode(PostStmt(S, tag), state, Pred);
assert(ENB);
return ENB->generateNode(state, Pred);
@ -3111,6 +3110,7 @@ GRStateRef CFRefCount::Update(GRStateRef state, SymbolRef sym,
// Update the autorelease counts.
state = SendAutorelease(state, ARCountFactory, sym);
V = V.autorelease();
break;
case StopTracking:
return state.remove<RefBindings>(sym);
@ -3245,7 +3245,7 @@ CFRefCount::ProcessLeaks(GRStateRef state,
return Pred;
// Generate an intermediate node representing the leak point.
ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
if (N) {
for (llvm::SmallVectorImpl<SymbolRef>::iterator
@ -3354,7 +3354,8 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet<GRState>& Dst,
Builder.BuildSinks = true;
GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
if (!N) return;
if (!N)
return;
CFRefBug *BT = 0;

View File

@ -284,10 +284,32 @@ void f12() {
}
void f13_autorelease() {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
[(id) A autorelease]; // no-warning
}
void f13_autorelease_b() {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease]; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
}
CFMutableArrayRef f13_autorelease_c() {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease];
return A; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
}
CFMutableArrayRef f13_autorelease_d() {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease];
CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object will be sent more -release messages}}
CFRelease(B); // no-warning
}
// This case exercises the logic where the leak site is the same as the allocation site.
void f14_leakimmediately() {
CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}