[cfe-commits] r50541 - in /cfe/trunk/lib/Analysis: CFRefCount.cpp ValueState.cpp
Ted Kremenek
kremenek at apple.com
Thu May 1 14:31:51 PDT 2008
Author: kremenek
Date: Thu May 1 16:31:50 2008
New Revision: 50541
URL: http://llvm.org/viewvc/llvm-project?rev=50541&view=rev
Log:
Correctly invalidate reference count state when passing objects by reference in message expressions we don't understand.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/lib/Analysis/ValueState.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=50541&r1=50540&r2=50541&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu May 1 16:31:50 2008
@@ -294,7 +294,7 @@
if (strcmp(FName, "Release") == 0)
return getUnaryCFSummary(FT, cfrelease);
-
+
if (strcmp(FName, "MakeCollectable") == 0)
return getUnaryCFSummary(FT, cfmakecollectable);
@@ -962,8 +962,43 @@
ObjCMessageExpr* ME,
ExplodedNode<ValueState>* Pred) {
- if (EvalObjCMessageExprAux(Dst, Eng, Builder, ME, Pred))
- GRSimpleVals::EvalObjCMessageExpr(Dst, Eng, Builder, ME, Pred);
+ if (!EvalObjCMessageExprAux(Dst, Eng, Builder, ME, Pred))
+ return;
+
+ // The basic transfer function logic for message expressions does nothing.
+ // We just invalidate all arguments passed in by references.
+
+ ValueStateManager& StateMgr = Eng.getStateManager();
+ ValueState* St = Builder.GetState(Pred);
+ RefBindings B = GetRefBindings(*St);
+
+ for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
+ I != E; ++I) {
+
+ RVal V = StateMgr.GetRVal(St, *I);
+
+ if (isa<LVal>(V)) {
+
+ LVal lv = cast<LVal>(V);
+
+ // Did the lval bind to a symbol?
+ RVal X = StateMgr.GetRVal(St, lv);
+
+ if (isa<lval::SymbolVal>(X)) {
+ SymbolID Sym = cast<lval::SymbolVal>(V).getSymbol();
+ B = Remove(B, Sym);
+
+ // Create a new state with the updated bindings.
+ ValueState StVals = *St;
+ SetRefBindings(StVals, B);
+ St = StateMgr.getPersistentState(StVals);
+ }
+
+ St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal());
+ }
+ }
+
+ Builder.MakeNode(Dst, ME, Pred, St);
}
bool CFRefCount::EvalObjCMessageExprAux(ExplodedNodeSet<ValueState>& Dst,
Modified: cfe/trunk/lib/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ValueState.cpp?rev=50541&r1=50540&r2=50541&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ValueState.cpp (original)
+++ cfe/trunk/lib/Analysis/ValueState.cpp Thu May 1 16:31:50 2008
@@ -203,6 +203,12 @@
return UnknownVal();
}
+
+ case lval::ConcreteIntKind:
+ // Some clients may call GetRVal with such an option simply because
+ // they are doing a quick scan through their LVals (potentially to
+ // invalidate their bindings). Just return Undefined.
+ return UndefinedVal();
case lval::ArrayOffsetKind:
case lval::FieldOffsetKind:
More information about the cfe-commits
mailing list