aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-08-25 23:29:04 +0000
committerTed Kremenek <kremenek@apple.com>2009-08-25 23:29:04 +0000
commitab2f43cfe7272d77374d8dec8f9df625bf525468 (patch)
tree16502643b4a7d1b4eb18d4046639d583f68f1d1a
parentbcf62a9f5b9baf4b02fce08144465e6b306af543 (diff)
Fix regression in BasicStoreManager caused by implicitly casting loaded values and trying to load/store from arrays. RegionStoreManager already properly handles these cases well; we just need to gracefully not handle this case in BasicStoreManager. This fixes PR 4781.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80051 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/BasicStore.cpp14
-rw-r--r--test/Analysis/misc-ps.m12
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index e211339658..682feb50d8 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -340,6 +340,13 @@ Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
return store;
+ const TypedRegion *TyR = cast<TypedRegion>(R);
+
+ // Do not bind to arrays. We need to explicitly check for this so that
+ // we do not encounter any weirdness of trying to load/store from arrays.
+ if (TyR->isBoundable() && TyR->getValueType(C)->isArrayType())
+ return store;
+
if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(&V)) {
// Only convert 'V' to a location iff the underlying region type
// is a location as well.
@@ -347,11 +354,8 @@ Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
// a pointer. We may wish to flag a type error here if the types
// are incompatible. This may also cause lots of breakage
// elsewhere. Food for thought.
- if (const TypedRegion *TyR = dyn_cast<TypedRegion>(R)) {
- if (TyR->isBoundable() &&
- Loc::IsLocType(TyR->getValueType(C)))
- V = X->getLoc();
- }
+ if (TyR->isBoundable() && Loc::IsLocType(TyR->getValueType(C)))
+ V = X->getLoc();
}
BindingsTy B = GetBindings(store);
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index e74877748b..cbfb5b1d46 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -542,3 +542,15 @@ int rdar_7124210(unsigned int x) {
return compare ? 0 : 1; // Forces the evaluation of the symbolic constraint.
}
+void pr4781(unsigned long *raw1) {
+ unsigned long *cook, *raw0;
+ unsigned long dough[32];
+ int i;
+ cook = dough;
+ for( i = 0; i < 16; i++, raw1++ ) {
+ raw0 = raw1++;
+ *cook = (*raw0 & 0x00fc0000L) << 6;
+ *cook |= (*raw0 & 0x00000fc0L) << 10;
+ }
+}
+