diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-05-29 06:23:24 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-05-29 06:23:24 +0000 |
commit | bdfa85fd5351d24bc42ce21a97d2fb8486df22b1 (patch) | |
tree | 424f3cf03a288c887f625d16abf4199b3108bf0a /lib/Checker/RegionStore.cpp | |
parent | 616d4362f01a8f819f9351372c3c4368777d4480 (diff) |
Fix PR7218. Patch by Jordy Rose.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105097 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/RegionStore.cpp')
-rw-r--r-- | lib/Checker/RegionStore.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index c4072fd803..c25d2095b1 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -213,6 +213,11 @@ 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 @@ -944,11 +949,20 @@ 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 (const SVal *V = Lookup(B, R, BindingKey::Direct)) - return *V; + const MemRegion *R) { + if (canHaveDirectBinding(R)) + if (const SVal *V = Lookup(B, R, BindingKey::Direct)) + return *V; return Optional<SVal>(); } |