aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/RegionStore.cpp
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-08-16 01:15:17 +0000
committerJordy Rose <jediknil@belkadan.com>2010-08-16 01:15:17 +0000
commite701117b21356d3c60133315b5bdd50232ec6cca (patch)
tree73eee84d6aeb34c7ff8e34b9121638e333a13b16 /lib/Checker/RegionStore.cpp
parentc736377543edcfbb00a4150fae79b4d9d9f66849 (diff)
- Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking.
- Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path. - Remove ConstraintManager::AssumeInBound. - Teach RegionStore and FlatStore to ignore those regions for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/RegionStore.cpp')
-rw-r--r--lib/Checker/RegionStore.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp
index b6ea696c4e..1c74c3f3a3 100644
--- a/lib/Checker/RegionStore.cpp
+++ b/lib/Checker/RegionStore.cpp
@@ -44,7 +44,7 @@ private:
uint64_t Offset;
explicit BindingKey(const MemRegion *r, uint64_t offset, Kind k)
- : P(r, (unsigned) k), Offset(offset) { assert(r); }
+ : P(r, (unsigned) k), Offset(offset) {}
public:
bool isDefault() const { return P.getInt() == Default; }
@@ -72,6 +72,10 @@ public:
return P.getOpaqueValue() == X.P.getOpaqueValue() &&
Offset == X.Offset;
}
+
+ operator bool() const {
+ return getRegion() != NULL;
+ }
};
} // end anonymous namespace
@@ -1604,17 +1608,18 @@ BindingKey BindingKey::Make(const MemRegion *R, Kind k) {
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
const RegionRawOffset &O = ER->getAsArrayOffset();
- if (O.getRegion())
- return BindingKey(O.getRegion(), O.getByteOffset(), k);
-
// FIXME: There are some ElementRegions for which we cannot compute
- // raw offsets yet, including regions with symbolic offsets.
+ // raw offsets yet, including regions with symbolic offsets. These will be
+ // ignored by the store.
+ return BindingKey(O.getRegion(), O.getByteOffset(), k);
}
return BindingKey(R, 0, k);
}
RegionBindings RegionStoreManager::Add(RegionBindings B, BindingKey K, SVal V) {
+ if (!K)
+ return B;
return RBFactory.Add(B, K, V);
}
@@ -1624,6 +1629,8 @@ RegionBindings RegionStoreManager::Add(RegionBindings B, const MemRegion *R,
}
const SVal *RegionStoreManager::Lookup(RegionBindings B, BindingKey K) {
+ if (!K)
+ return NULL;
return B.lookup(K);
}
@@ -1634,6 +1641,8 @@ const SVal *RegionStoreManager::Lookup(RegionBindings B,
}
RegionBindings RegionStoreManager::Remove(RegionBindings B, BindingKey K) {
+ if (!K)
+ return B;
return RBFactory.Remove(B, K);
}