diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-17 22:52:40 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-17 22:52:40 +0000 |
commit | 134e74910bd17a17805f9c343c21a4e2e2311309 (patch) | |
tree | 30bae9f48f3d35c818528ad85341d95fd46fd9b2 /lib/Analysis/BasicStore.cpp | |
parent | fd30194a78e8cb6f2cb1138783f7e9d504864884 (diff) |
Hack: have BasicStore::getLValueElement return the "Base" lvalue. This restores null dereference checking with array accesses.
BasicStore::RemoveDeadBindings: handle regions besides VarRegions (we now have FieldRegions).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicStore.cpp')
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index e1220ce674..8fc438d6a5 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -129,7 +129,8 @@ SVal BasicStoreManager::getLValueField(const GRState* St, const FieldDecl* D, SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base, SVal Offset) { - return UnknownVal(); + // Total hack: Just return "Base" for now. + return Base; } SVal BasicStoreManager::GetSVal(Store St, Loc LV, QualType T) { @@ -237,25 +238,37 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc, llvm::SmallPtrSet<const VarRegion*, 10> Marked; while (!RegionRoots.empty()) { - const VarRegion* R = cast<VarRegion>(RegionRoots.back()); + const MemRegion* MR = RegionRoots.back(); RegionRoots.pop_back(); - if (Marked.count(R)) - continue; - - Marked.insert(R); - // FIXME: Do we need the QualType here, since regions are partially - // typed? - SVal X = GetSVal(store, loc::MemRegionVal(R), QualType()); + while (MR) { + if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(MR)) { + LSymbols.insert(SymR->getSymbol()); + break; + } + else if (const VarRegion* R = dyn_cast<VarRegion>(MR)) { + if (Marked.count(R)) + break; + + Marked.insert(R); + SVal X = GetRegionSVal(store, R); - for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) - LSymbols.insert(*SI); + // FIXME: We need to handle symbols nested in region definitions. + for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) + LSymbols.insert(*SI); - if (!isa<loc::MemRegionVal>(X)) - continue; + if (!isa<loc::MemRegionVal>(X)) + break; - const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X); - RegionRoots.push_back(cast<VarRegion>(LVD.getRegion())); + const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X); + RegionRoots.push_back(LVD.getRegion()); + break; + } + else if (const SubRegion* R = dyn_cast<SubRegion>(MR)) + MR = R->getSuperRegion(); + else + break; + } } // Remove dead variable bindings. |