[cfe-commits] r57755 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Fri Oct 17 20:49:53 PDT 2008
Author: kremenek
Date: Fri Oct 17 22:49:51 2008
New Revision: 57755
URL: http://llvm.org/viewvc/llvm-project?rev=57755&view=rev
Log:
retain/release checker: Check if a tracked value escapes if we also try binding it to the store and the store doesn't support that binding (i.e., it cannot track it). This has the nice feature that the checker will automatically get more powerful if we use a more powerful store model.
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=57755&r1=57754&r2=57755&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Oct 17 22:49:51 2008
@@ -1727,20 +1727,36 @@
bool escapes = false;
+ // A value escapes in three possible cases (this may change):
+ //
+ // (1) we are binding to something that is not a memory region.
+ // (2) we are binding to a memregion that does not have stack storage
+ // (3) we are binding to a memregion with stack storage that the store
+ // does not understand.
+
+ SymbolID Sym = cast<loc::SymbolVal>(Val).getSymbol();
+ GRStateRef state(St, Eng.getStateManager());
+
if (!isa<loc::MemRegionVal>(TargetLV))
escapes = true;
else {
const MemRegion* R = cast<loc::MemRegionVal>(TargetLV).getRegion();
escapes = !Eng.getStateManager().hasStackStorage(R);
+
+ if (!escapes) {
+ // To test (3), generate a new state with the binding removed. If it is
+ // the same state, then it escapes (since the store cannot represent
+ // the binding).
+ GRStateRef stateNew = state.SetSVal(cast<Loc>(TargetLV), Val);
+ escapes = (stateNew == state);
+ }
}
if (!escapes)
return;
-
- SymbolID Sym = cast<loc::SymbolVal>(Val).getSymbol();
-
- GRStateRef state(St, Eng.getStateManager());
-
+
+ // Do we have a reference count binding?
+ // FIXME: Is this step even needed? We do blow away the binding anyway.
if (!state.get<RefBindings>(Sym))
return;
More information about the cfe-commits
mailing list