aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/RegionStore.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-10-22 13:44:38 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-10-22 13:44:38 +0000
commitc4bf72c544190123da4b4b6c4dc198e8f206227c (patch)
tree720158c68e7cdedb5ec0e47bbc05cf48ec2ea09a /lib/Analysis/RegionStore.cpp
parentc92e5feb73a99e0e44d00c3ce0275d32bc56d7c6 (diff)
Add a bunch of getLValue* methods to RegionStore.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r--lib/Analysis/RegionStore.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 9efcc48c51..9183fd782f 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -38,7 +38,14 @@ public:
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 @@ Loc RegionStoreManager::getElementLoc(const VarDecl* VD, SVal Idx) {
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");