From: Ted Kremenek Date: Fri, 17 Oct 2008 22:52:40 +0000 (+0000) Subject: Hack: have BasicStore::getLValueElement return the "Base" lvalue. This restores... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=134e74910bd17a17805f9c343c21a4e2e2311309;p=clang 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 --- 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 Marked; while (!RegionRoots.empty()) { - const VarRegion* R = cast(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(MR)) { + LSymbols.insert(SymR->getSymbol()); + break; + } + else if (const VarRegion* R = dyn_cast(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(X)) - continue; + if (!isa(X)) + break; - const loc::MemRegionVal& LVD = cast(X); - RegionRoots.push_back(cast(LVD.getRegion())); + const loc::MemRegionVal& LVD = cast(X); + RegionRoots.push_back(LVD.getRegion()); + break; + } + else if (const SubRegion* R = dyn_cast(MR)) + MR = R->getSuperRegion(); + else + break; + } } // Remove dead variable bindings.