[cfe-commits] r60795 - /cfe/trunk/lib/Analysis/BasicStore.cpp
Ted Kremenek
kremenek at apple.com
Tue Dec 9 13:20:27 PST 2008
Author: kremenek
Date: Tue Dec 9 15:20:27 2008
New Revision: 60795
URL: http://llvm.org/viewvc/llvm-project?rev=60795&view=rev
Log:
Have BasicStoreManager::getLValueElement() have logic similar to BasicStoreManager::getLValueField() (i.e., don't just return the 'base' as the SVal)
Modified:
cfe/trunk/lib/Analysis/BasicStore.cpp
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=60795&r1=60794&r2=60795&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Tue Dec 9 15:20:27 2008
@@ -165,8 +165,43 @@
SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base,
SVal Offset) {
- // Total hack: Just return "Base" for now.
- return Base;
+
+
+ if (Base.isUnknownOrUndef())
+ return Base;
+
+ Loc BaseL = cast<Loc>(Base);
+ const MemRegion* BaseR = 0;
+
+ switch(BaseL.getSubKind()) {
+ case loc::SymbolValKind:
+ BaseR = MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(&BaseL)->getSymbol());
+ break;
+
+ case loc::GotoLabelKind:
+ case loc::FuncValKind:
+ // Technically we can get here if people do funny things with casts.
+ return UndefinedVal();
+
+ case loc::MemRegionKind:
+ BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
+ break;
+
+ case loc::ConcreteIntKind:
+ // While these seem funny, this can happen through casts.
+ // FIXME: What we should return is the field offset. For example,
+ // add the field offset to the integer value. That way funny things
+ // like this work properly: &(((struct foo *) 0xa)->f)
+ return Base;
+
+ default:
+ assert ("Unhandled Base.");
+ return Base;
+ }
+
+ // We return an "unknown" index because we aren't reasoning about indices
+ // at all.
+ return loc::MemRegionVal(MRMgr.getElementRegion(UnknownVal(), BaseR));
}
SVal BasicStoreManager::Retrieve(const GRState* state, Loc LV, QualType T) {
More information about the cfe-commits
mailing list