[cfe-commits] r65984 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 3 16:14:35 PST 2009
Author: kremenek
Date: Tue Mar 3 18:14:35 2009
New Revision: 65984
URL: http://llvm.org/viewvc/llvm-project?rev=65984&view=rev
Log:
Create "TypedViewRegions" that layer on top of SymbolicRegions when handling
pointer-to-pointer casts involving symbolic locations.
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=65984&r1=65983&r2=65984&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Mar 3 18:14:35 2009
@@ -162,7 +162,6 @@
// Set up our simple checks.
if (BatchAuditor)
Builder->setAuditor(BatchAuditor.get());
-
// Create the cleaned state.
SymbolReaper SymReaper(Liveness, SymMgr);
@@ -1743,8 +1742,7 @@
Visit(Ex, Pred, S1);
// Check for casting to "void".
- if (T->isVoidType()) {
-
+ if (T->isVoidType()) {
for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
Dst.Add(*I1);
@@ -1761,14 +1759,12 @@
SVal V = GetSVal(state, Ex);
// Unknown?
-
if (V.isUnknown()) {
Dst.Add(N);
continue;
}
// Undefined?
-
if (V.isUndef()) {
MakeNode(Dst, CastE, N, BindExpr(state, CastE, V));
continue;
@@ -1841,6 +1837,28 @@
continue;
}
+ // If we are casting a symbolic value, make a symbolic region and a
+ // TypedViewRegion subregion.
+ if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V)) {
+ SymbolRef Sym = SV->getSymbol();
+ StoreManager& StoreMgr = getStoreManager();
+ const MemRegion* R =
+ StoreMgr.getRegionManager().getSymbolicRegion(Sym, getSymbolManager());
+
+ // Delegate to store manager to get the result of casting a region
+ // to a different type.
+ const StoreManager::CastResult& Res = StoreMgr.CastRegion(state, R, T);
+
+ // Inspect the result. If the MemRegion* returned is NULL, this
+ // expression evaluates to UnknownVal.
+ R = Res.getRegion();
+ if (R) { V = loc::MemRegionVal(R); } else { V = UnknownVal(); }
+
+ // Generate the new node in the ExplodedGraph.
+ MakeNode(Dst, CastE, N, BindExpr(Res.getState(), CastE, V));
+ continue;
+ }
+
// All other cases.
MakeNode(Dst, CastE, N, BindExpr(state, CastE,
EvalCast(V, CastE->getType())));
More information about the cfe-commits
mailing list