aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-05-29 06:49:04 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-05-29 06:49:04 +0000
commit42c67bfedb0b3a998d46d3868208bdd9a4da520a (patch)
treeec7dd4c65dc8435009e3ea26930fd2f378840550
parentbdfa85fd5351d24bc42ce21a97d2fb8486df22b1 (diff)
Revert r105097. Thinking about a better fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105099 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Checker/RegionStore.cpp23
-rw-r--r--test/Analysis/PR7218.c1
2 files changed, 6 insertions, 18 deletions
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp
index c25d2095b1..2200ef1002 100644
--- a/lib/Checker/RegionStore.cpp
+++ b/lib/Checker/RegionStore.cpp
@@ -213,11 +213,6 @@ public:
RegionStoreSubRegionMap *getRegionStoreSubRegionMap(Store store);
- /// canHaveDirectBinding - Disallow direct bindings for certain types,
- /// like arrays. This lets us distinguish between x and x[0], which was
- /// causing PR7218 "Assigning to buf[0] makes buf[1] valid".
- bool canHaveDirectBinding (const MemRegion *R);
-
Optional<SVal> getBinding(RegionBindings B, const MemRegion *R);
Optional<SVal> getDirectBinding(RegionBindings B, const MemRegion *R);
/// getDefaultBinding - Returns an SVal* representing an optional default
@@ -949,20 +944,12 @@ SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R,
//===----------------------------------------------------------------------===//
// Loading values from regions.
//===----------------------------------------------------------------------===//
-bool RegionStoreManager::canHaveDirectBinding (const MemRegion *R) {
- // Arrays can't have direct binding -- must bind to elements
- if (const TypedRegion *TR = dyn_cast<TypedRegion>(R))
- if (TR->getValueType(getContext())->isArrayType())
- return false;
-
- return true;
-}
Optional<SVal> RegionStoreManager::getDirectBinding(RegionBindings B,
const MemRegion *R) {
- if (canHaveDirectBinding(R))
- if (const SVal *V = Lookup(B, R, BindingKey::Direct))
- return *V;
+
+ if (const SVal *V = Lookup(B, R, BindingKey::Direct))
+ return *V;
return Optional<SVal>();
}
@@ -1188,8 +1175,9 @@ SVal RegionStoreManager::RetrieveElement(Store store,
// Check if the immediate super region has a direct binding.
if (const Optional<SVal> &V = getDirectBinding(B, superR)) {
- if (SymbolRef parentSym = V->getAsSymbol())
+ if (SymbolRef parentSym = V->getAsSymbol()) {
return ValMgr.getDerivedRegionValueSymbolVal(parentSym, R);
+ }
if (V->isUnknownOrUndef())
return *V;
@@ -1198,7 +1186,6 @@ SVal RegionStoreManager::RetrieveElement(Store store,
// are handled in 'RetrieveFieldOrElementCommon'.
if (const nonloc::LazyCompoundVal *LCV =
dyn_cast<nonloc::LazyCompoundVal>(V)) {
-
R = MRMgr.getElementRegionWithSuper(R, LCV->getRegion());
return RetrieveElement(LCV->getStore(), R);
}
diff --git a/test/Analysis/PR7218.c b/test/Analysis/PR7218.c
index 635e56f053..bda30a7f72 100644
--- a/test/Analysis/PR7218.c
+++ b/test/Analysis/PR7218.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s
+// XFAIL: *
char PR7218(char a) {
char buf[2];
buf[0] = a;