]> granicus.if.org Git - clang/commitdiff
When creating lazy bindings in RegionStore, propagate existing lazy bindings instead...
authorTed Kremenek <kremenek@apple.com>
Tue, 8 May 2012 21:49:51 +0000 (21:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 8 May 2012 21:49:51 +0000 (21:49 +0000)
This is a functionality optimization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156427 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/RegionStore.cpp

index 1fec0206230c6245eb0a04d78e1b32e307dc83a8..bf79b9da0b760d4cdd9565957e538f592ee93e4d 100644 (file)
@@ -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);
 }