Get RegionStore to work with the retain/release checker and its test cases.
Because the RegionStore can reason about values beyond the reasoning power of BasicStore, this patch splits some of the test cases for the retain/release checker to have versions that are handled by RegionStore (more warnings) and BasicStore (less warnings).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62667 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 20cf38f..0c6fb80 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -652,37 +652,33 @@
}
Store RegionStoreManager::Remove(Store store, Loc L) {
- RegionBindingsTy B = GetRegionBindings(store);
-
- const MemRegion* R = cast<loc::MemRegionVal>(L).getRegion();
- assert(R);
-
- return RBFactory.Remove(B, R).getRoot();
+ const MemRegion* R = 0;
+
+ if (isa<loc::MemRegionVal>(L))
+ R = cast<loc::MemRegionVal>(L).getRegion();
+ else if (isa<loc::SymbolVal>(L))
+ R = MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(L).getSymbol());
+
+ if (R) {
+ RegionBindingsTy B = GetRegionBindings(store);
+ return RBFactory.Remove(B, R).getRoot();
+ }
+
+ return store;
}
const GRState* RegionStoreManager::BindDecl(const GRState* St,
const VarDecl* VD, SVal InitVal) {
- // All static variables are treated as symbolic values.
- if (VD->hasGlobalStorage())
- return St;
-
- // Process local variables.
QualType T = VD->getType();
-
VarRegion* VR = MRMgr.getVarRegion(VD);
-
- if (Loc::IsLocType(T) || T->isIntegerType())
- return Bind(St, Loc::MakeVal(VR), InitVal);
- else if (T->isArrayType())
+ if (T->isArrayType())
return BindArray(St, VR, InitVal);
-
- else if (T->isStructureType())
+ if (T->isStructureType())
return BindStruct(St, VR, InitVal);
- // Other types of variable are not supported yet.
- return St;
+ return Bind(St, Loc::MakeVal(VR), InitVal);
}
// FIXME: this method should be merged into Bind().