[cfe-commits] r57977 - /cfe/trunk/lib/Analysis/RegionStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Wed Oct 22 06:44:40 PDT 2008
Author: zhongxingxu
Date: Wed Oct 22 08:44:38 2008
New Revision: 57977
URL: http://llvm.org/viewvc/llvm-project?rev=57977&view=rev
Log:
Add a bunch of getLValue* methods to RegionStore.
Modified:
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=57977&r1=57976&r2=57977&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Wed Oct 22 08:44:38 2008
@@ -38,7 +38,14 @@
virtual ~RegionStoreManager() {}
+ SVal getLValueVar(const GRState* St, const VarDecl* VD);
+
+ SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
+
+ SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);
+
SVal Retrieve(Store S, Loc L, QualType T);
+
Store Bind(Store St, Loc LV, SVal V);
Store getInitialStore();
@@ -65,6 +72,53 @@
return loc::MemRegionVal(ER);
}
+SVal RegionStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
+ return loc::MemRegionVal(MRMgr.getVarRegion(VD));
+}
+
+SVal RegionStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
+ SVal Base) {
+ return UnknownVal();
+}
+
+SVal RegionStoreManager::getLValueField(const GRState* St, SVal Base,
+ const FieldDecl* D) {
+ if (Base.isUnknownOrUndef())
+ return Base;
+
+ Loc BaseL = cast<Loc>(Base);
+ const MemRegion* BaseR = 0;
+
+ switch (BaseL.getSubKind()) {
+ case loc::MemRegionKind:
+ BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
+ break;
+
+ case loc::SymbolValKind:
+ BaseR = MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(&BaseL)->getSymbol());
+ break;
+
+ case loc::GotoLabelKind:
+ case loc::FuncValKind:
+ // These are anormal cases. Flag an undefined value.
+ return UndefinedVal();
+
+ case loc::ConcreteIntKind:
+ case loc::StringLiteralValKind:
+ // 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;
+ }
+
+ return loc::MemRegionVal(MRMgr.getFieldRegion(D, BaseR));
+}
+
SVal RegionStoreManager::Retrieve(Store S, Loc L, QualType T) {
assert(!isa<UnknownVal>(L) && "location unknown");
assert(!isa<UndefinedVal>(L) && "location undefined");
More information about the cfe-commits
mailing list