r175582 - [analyzer] Account for the "interesting values" hash table resizing.

Jordan Rose jordan_rose at apple.com
Tue Feb 19 16:27:26 PST 2013


Author: jrose
Date: Tue Feb 19 18:27:26 2013
New Revision: 175582

URL: http://llvm.org/viewvc/llvm-project?rev=175582&view=rev
Log:
[analyzer] Account for the "interesting values" hash table resizing.

RegionStoreManager::getInterestingValues() returns a pointer to a
std::vector that lives inside a DenseMap, which is constructed on demand.
However, constructing one such value can lead to constructing another
value, which will invalidate the reference created earlier.

Fixed by delaying the new entry creation until the function returns.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=175582&r1=175581&r2=175582&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Tue Feb 19 18:27:26 2013
@@ -1629,7 +1629,7 @@ RegionStoreManager::getInterestingValues
     return I->second;
 
   // If we don't have a list of values cached, start constructing it.
-  SValListTy &List = LazyBindingsMap[LCV.getCVData()];
+  SValListTy List;
 
   const SubRegion *LazyR = LCV.getRegion();
   RegionBindingsRef B = getRegionBindings(LCV.getStore());
@@ -1638,7 +1638,7 @@ RegionStoreManager::getInterestingValues
   // values to return.
   const ClusterBindings *Cluster = B.lookup(LazyR->getBaseRegion());
   if (!Cluster)
-    return List;
+    return (LazyBindingsMap[LCV.getCVData()] = llvm_move(List));
 
   SmallVector<BindingKey, 32> Keys;
   collectSubRegionKeys(Keys, svalBuilder, *Cluster, LazyR,
@@ -1661,7 +1661,7 @@ RegionStoreManager::getInterestingValues
     List.push_back(V);
   }
 
-  return List;
+  return (LazyBindingsMap[LCV.getCVData()] = llvm_move(List));
 }
 
 NonLoc RegionStoreManager::createLazyBinding(RegionBindingsConstRef B,





More information about the cfe-commits mailing list