[cfe-commits] r71290 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Fri May 8 16:32:51 PDT 2009
Author: kremenek
Date: Fri May 8 18:32:51 2009
New Revision: 71290
URL: http://llvm.org/viewvc/llvm-project?rev=71290&view=rev
Log:
retain/release checker: Add stub for HandleAutoreleaseCounts.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=71290&r1=71289&r2=71290&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri May 8 18:32:51 2009
@@ -1734,7 +1734,11 @@
ExplodedNode<GRState>* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper);
-
+
+ std::pair<ExplodedNode<GRState>*, GRStateRef>
+ HandleAutoreleaseCounts(GRStateRef state, GenericNodeBuilder Bd,
+ ExplodedNode<GRState>* Pred,
+ SymbolRef Sym, RefVal V);
// Return statements.
virtual void EvalReturn(ExplodedNodeSet<GRState>& Dst,
@@ -2359,7 +2363,7 @@
const MemRegion* FirstBinding = 0;
llvm::tie(AllocNode, FirstBinding) =
- GetAllocationSite(BRC.getStateManager(), EndN, Sym);
+ GetAllocationSite(BRC.getStateManager(), EndN, Sym);
// Get the allocate site.
assert(AllocNode);
@@ -2443,7 +2447,7 @@
const ExplodedNode<GRState>* AllocNode = 0;
llvm::tie(AllocNode, AllocBinding) = // Set AllocBinding.
- GetAllocationSite(Eng.getStateManager(), getEndNode(), getSymbol());
+ GetAllocationSite(Eng.getStateManager(), getEndNode(), getSymbol());
// Get the SourceLocation for the allocation site.
ProgramPoint P = AllocNode->getLocation();
@@ -2901,13 +2905,22 @@
if (!Sym)
return;
-
+
// Get the reference count binding (if any).
const RefVal* T = state.get<RefBindings>(Sym);
if (!T)
return;
+ // Update the autorelease counts.
+ static unsigned autoreleasetag = 0;
+ GenericNodeBuilder Bd(Builder, S, &autoreleasetag);
+ llvm::tie(Pred, state) = HandleAutoreleaseCounts(state , Bd, Pred, Sym, *T);
+
+ // Get the updated binding.
+ T = state.get<RefBindings>(Sym);
+ assert(T);
+
// Change the reference count.
RefVal X = *T;
@@ -3132,6 +3145,13 @@
// Handle dead symbols and end-of-path.
//===----------------------------------------------------------------------===//
+std::pair<ExplodedNode<GRState>*, GRStateRef>
+CFRefCount::HandleAutoreleaseCounts(GRStateRef state, GenericNodeBuilder Bd,
+ ExplodedNode<GRState>* Pred,
+ SymbolRef Sym, RefVal V) {
+
+ return std::make_pair(Pred, state);
+}
GRStateRef
CFRefCount::HandleSymbolDeath(GRStateRef state, SymbolRef sid, RefVal V,
@@ -3157,6 +3177,7 @@
if (Leaked.empty())
return Pred;
+ // Generate an intermediate node representing the leak point.
ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
if (N) {
@@ -3178,14 +3199,23 @@
GREndPathNodeBuilder<GRState>& Builder) {
GRStateRef state(Builder.getState(), Eng.getStateManager());
+ GenericNodeBuilder Bd(Builder);
RefBindings B = state.get<RefBindings>();
+ ExplodedNode<GRState> *Pred = 0;
+
+ for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) {
+ llvm::tie(Pred, state) = HandleAutoreleaseCounts(state, Bd, Pred,
+ (*I).first,
+ (*I).second);
+ }
+
+ B = state.get<RefBindings>();
llvm::SmallVector<SymbolRef, 10> Leaked;
for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I)
state = HandleSymbolDeath(state, (*I).first, (*I).second, Leaked);
- GenericNodeBuilder Bd(Builder);
- ProcessLeaks(state, Leaked, Bd, Eng, NULL);
+ ProcessLeaks(state, Leaked, Bd, Eng, Pred);
}
void CFRefCount::EvalDeadSymbols(ExplodedNodeSet<GRState>& Dst,
@@ -3197,7 +3227,22 @@
SymbolReaper& SymReaper) {
GRStateRef state(St, Eng.getStateManager());
- RefBindings B = St->get<RefBindings>();
+ RefBindings B = state.get<RefBindings>();
+
+ // Update counts from autorelease pools
+ for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
+ E = SymReaper.dead_end(); I != E; ++I) {
+ SymbolRef Sym = *I;
+ if (const RefVal* T = B.lookup(Sym)){
+ // Use the symbol as the tag.
+ // FIXME: This might not be as unique as we would like.
+ GenericNodeBuilder Bd(Builder, S, Sym);
+ llvm::tie(Pred, state) = HandleAutoreleaseCounts(state, Bd, Pred, Sym,
+ *T);
+ }
+ }
+
+ B = state.get<RefBindings>();
llvm::SmallVector<SymbolRef, 10> Leaked;
for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
@@ -3207,8 +3252,10 @@
}
static unsigned LeakPPTag = 0;
- GenericNodeBuilder Bd(Builder, S, &LeakPPTag);
- Pred = ProcessLeaks(state, Leaked, Bd, Eng, Pred);
+ {
+ GenericNodeBuilder Bd(Builder, S, &LeakPPTag);
+ Pred = ProcessLeaks(state, Leaked, Bd, Eng, Pred);
+ }
// Did we cache out?
if (!Pred)
More information about the cfe-commits
mailing list