diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-05-08 21:49:51 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-05-08 21:49:51 +0000 |
commit | b4235b48ca4d92d1fce0efa97b36c0ee794de3dd (patch) | |
tree | d5b5852fa2d9452020424f67eaac68203dcc1acb | |
parent | 228571b69b3ef4a4a622c2d10b08ceafda6ca1e9 (diff) | |
download | bcm5719-llvm-b4235b48ca4d92d1fce0efa97b36c0ee794de3dd.tar.gz bcm5719-llvm-b4235b48ca4d92d1fce0efa97b36c0ee794de3dd.zip |
When creating lazy bindings in RegionStore, propagate existing lazy bindings instead of creating new ones.
This is a functionality optimization.
llvm-svn: 156427
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 1fec0206230..bf79b9da0b7 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1427,12 +1427,30 @@ SVal RegionStoreManager::getBindingForLazySymbol(const TypedValueRegion *R) { SVal RegionStoreManager::getBindingForStruct(Store store, const TypedValueRegion* R) { assert(R->getValueType()->isStructureOrClassType()); + + // If we already have a lazy binding, don't create a new one. + RegionBindings B = GetRegionBindings(store); + BindingKey K = BindingKey::Make(R, BindingKey::Default); + if (const nonloc::LazyCompoundVal *V = + dyn_cast_or_null<nonloc::LazyCompoundVal>(lookup(B, K))) { + return *V; + } + return svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), R); } -SVal RegionStoreManager::getBindingForArray(Store store, +SVal RegionStoreManager::getBindingForArray(Store store, const TypedValueRegion * R) { assert(Ctx.getAsConstantArrayType(R->getValueType())); + + // If we already have a lazy binding, don't create a new one. + RegionBindings B = GetRegionBindings(store); + BindingKey K = BindingKey::Make(R, BindingKey::Default); + if (const nonloc::LazyCompoundVal *V = + dyn_cast_or_null<nonloc::LazyCompoundVal>(lookup(B, K))) { + return *V; + } + return svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), R); } |