aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicStore.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-17 00:51:01 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-17 00:51:01 +0000
commitd9bc33efa195114d6f2a365c26e5b8dba4e1cc38 (patch)
tree3a505a4969fd630cb2034fa5b64e6e0e362de680 /lib/Analysis/BasicStore.cpp
parent97ed4f68f5dba3e21e7a490ef0f9ffd3bfead7f8 (diff)
Remove lval::FieldOffset, lval::ArrayOffset. These will be replaced with regions.
Remove GRExprEngine::getLVal and RValues::MakeVal. Enhance StoreManager "GetLValue" methods to dispatch for specific kinds of lvalue queries, as opposed to interogating the expression tree (GRExprEngine already does this). Added FIXMEs. In particular, we no longer "assume" that a base pointer in a field/array access is null (this logic was removed). Perhaps we should do this when fetching the lvalue for fields and array elements? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicStore.cpp')
-rw-r--r--lib/Analysis/BasicStore.cpp66
1 files changed, 25 insertions, 41 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index 15a20c843a..000ea1bef2 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -46,9 +46,11 @@ public:
virtual LVal getLVal(const VarDecl* VD) {
return lval::MemRegionVal(MRMgr.getVarRegion(VD));
}
-
- virtual RVal getLValue(const GRState* St, const Expr* Ex);
- virtual RVal getLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base);
+
+ RVal getLValueVar(const GRState* St, const VarDecl* VD);
+ RVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, RVal Base);
+ RVal getLValueField(const GRState* St, const FieldDecl* D, RVal Base);
+ RVal getLValueElement(const GRState* St, RVal Base, RVal Offset);
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
@@ -76,34 +78,26 @@ public:
StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) {
return new BasicStoreManager(StMgr);
}
+RVal BasicStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
+ QualType T = VD->getType();
+ assert(!T->isArrayType() && "Array and struct variable have no lvalue.");
+ return lval::MemRegionVal(MRMgr.getVarRegion(VD));
+}
+
+RVal BasicStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
+ RVal Base) {
+ return UnknownVal();
+}
+
+
+RVal BasicStoreManager::getLValueField(const GRState* St, const FieldDecl* D,
+ RVal Base) {
+ return UnknownVal();
+}
-// FIXME: replace ArrayOffset and FieldOffset with some region value.
-RVal BasicStoreManager::getLValue(const GRState* St, const Expr* Ex) {
- if (const DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(Ex)) {
- const VarDecl* VD = cast<VarDecl>(DRE->getDecl());
- QualType T = VD->getType();
-
- // Array and struct variable have no lvalue.
- assert(!T->isArrayType());
-
- return lval::MemRegionVal(MRMgr.getVarRegion(VD));
-
- } else if (const ArraySubscriptExpr* A = dyn_cast<ArraySubscriptExpr>(Ex)) {
- const Expr* Base = A->getBase()->IgnoreParens();
- const Expr* Idx = A->getIdx()->IgnoreParens();
- RVal BaseV = StateMgr.GetRVal(St, Base);
- RVal IdxV = StateMgr.GetRVal(St, Idx);
- return lval::ArrayOffset::Make(StateMgr.getBasicVals(), BaseV, IdxV);
-
- } else if (const MemberExpr* M = dyn_cast<MemberExpr>(Ex)) {
- Expr* Base = M->getBase()->IgnoreParens();
- RVal BaseV = StateMgr.GetRVal(St, Base);
- return lval::FieldOffset::Make(StateMgr.getBasicVals(), BaseV,
- M->getMemberDecl());
- } else {
- Ex->dump();
- assert(0);
- }
+RVal BasicStoreManager::getLValueElement(const GRState* St, RVal Base,
+ RVal Offset) {
+ return UnknownVal();
}
RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) {
@@ -134,12 +128,7 @@ RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) {
// Some clients may call GetRVal with such an option simply because
// they are doing a quick scan through their LVals (potentially to
// invalidate their bindings). Just return Undefined.
- return UndefinedVal();
-
- case lval::ArrayOffsetKind:
- case lval::FieldOffsetKind:
- return UnknownVal();
-
+ return UndefinedVal();
case lval::FuncValKind:
return LV;
@@ -154,11 +143,6 @@ RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) {
return UnknownVal();
}
-
-RVal BasicStoreManager::getLValue(const GRState* St, const ObjCIvarDecl* D,
- RVal Base) {
- return UnknownVal();
-}
Store BasicStoreManager::SetRVal(Store store, LVal LV, RVal V) {
switch (LV.getSubKind()) {