[cfe-commits] r47645 - in /cfe/trunk: Analysis/GRExprEngine.cpp Analysis/ValueState.cpp Analysis/ValueState.h include/clang/Analysis/PathSensitive/GRExprEngine.h
Ted Kremenek
kremenek at apple.com
Tue Feb 26 15:37:02 PST 2008
Author: kremenek
Date: Tue Feb 26 17:37:01 2008
New Revision: 47645
URL: http://llvm.org/viewvc/llvm-project?rev=47645&view=rev
Log:
Fix bug when processing '?' operator: invalidate the old "Uninitialized" value of the block-level expression for ?.
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
cfe/trunk/Analysis/ValueState.cpp
cfe/trunk/Analysis/ValueState.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47645&r1=47644&r2=47645&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Tue Feb 26 17:37:01 2008
@@ -40,7 +40,7 @@
return St;
}
- return StateMgr.SetRVal(St, Ex, isBlkExpr, V);
+ return StateMgr.SetRVal(St, Ex, V, isBlkExpr, false);
}
const GRExprEngine::StateTy::BufferTy&
@@ -606,7 +606,9 @@
assert (SE);
X = GetBlkExprRVal(St, SE);
- Nodify(Dst, Ex, Pred, SetBlkExprRVal(St, Ex, X));
+
+ // Make sure that we invalidate the previous binding.
+ Nodify(Dst, Ex, Pred, StateMgr.SetRVal(St, Ex, X, true, true));
}
/// VisitSizeOfAlignOfTypeExpr - Transfer function for sizeof(type).
Modified: cfe/trunk/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.cpp?rev=47645&r1=47644&r2=47645&view=diff
==============================================================================
--- cfe/trunk/Analysis/ValueState.cpp (original)
+++ cfe/trunk/Analysis/ValueState.cpp Tue Feb 26 17:37:01 2008
@@ -387,12 +387,27 @@
}
ValueState
-ValueStateManager::SetRVal(ValueState St, Expr* E, bool isBlkExpr, RVal V) {
+ValueStateManager::SetRVal(ValueState St, Expr* E, RVal V,
+ bool isBlkExpr, bool Invalidate) {
assert (E);
- if (V.isUnknown())
+ if (V.isUnknown()) {
+
+ if (Invalidate) {
+
+ ValueStateImpl NewSt = *St;
+
+ if (isBlkExpr)
+ NewSt.BlockExprBindings = EXFactory.Remove(NewSt.BlockExprBindings, E);
+ else
+ NewSt.SubExprBindings = EXFactory.Remove(NewSt.SubExprBindings, E);
+
+ return getPersistentState(NewSt);
+ }
+
return St;
+ }
ValueStateImpl NewSt = *St;
@@ -406,8 +421,8 @@
return getPersistentState(NewSt);
}
-ValueState
-ValueStateManager::SetRVal(ValueState St, LVal LV, RVal V) {
+
+ValueState ValueStateManager::SetRVal(ValueState St, LVal LV, RVal V) {
switch (LV.getSubKind()) {
Modified: cfe/trunk/Analysis/ValueState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.h?rev=47645&r1=47644&r2=47645&view=diff
==============================================================================
--- cfe/trunk/Analysis/ValueState.h (original)
+++ cfe/trunk/Analysis/ValueState.h Tue Feb 26 17:37:01 2008
@@ -255,7 +255,9 @@
return getPersistentState(NewSt);
}
- ValueState SetRVal(ValueState St, Expr* E, bool isBlkExpr, RVal V);
+ ValueState SetRVal(ValueState St, Expr* E, RVal V,
+ bool isBlkExpr, bool Invalidate);
+
ValueState SetRVal(ValueState St, LVal LV, RVal V);
RVal GetRVal(ValueState St, Expr* E);
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=47645&r1=47644&r2=47645&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Feb 26 17:37:01 2008
@@ -243,7 +243,7 @@
}
StateTy SetBlkExprRVal(StateTy St, Expr* Ex, const RVal& V) {
- return StateMgr.SetRVal(St, Ex, true, V);
+ return StateMgr.SetRVal(St, Ex, V, true, false);
}
/// SetRVal - This version of SetRVal is used to batch process a set
More information about the cfe-commits
mailing list