@@ -608,6 +608,10 @@ class RegionStoreManager : public StoreManager {
608
608
// / The precise value of "interesting" is determined for the purposes of
609
609
// / RegionStore's internal analysis. It must always contain all regions and
610
610
// / symbols, but may omit constants and other kinds of SVal.
611
+ // /
612
+ // / In contrast to compound values, LazyCompoundVals are also added
613
+ // / to the 'interesting values' list in addition to the child interesting
614
+ // / values.
611
615
const SValListTy &getInterestingValues (nonloc::LazyCompoundVal LCV);
612
616
613
617
// ===------------------------------------------------------------------===//
@@ -1032,12 +1036,11 @@ void InvalidateRegionsWorker::VisitBinding(SVal V) {
1032
1036
if (Optional<nonloc::LazyCompoundVal> LCS =
1033
1037
V.getAs <nonloc::LazyCompoundVal>()) {
1034
1038
1035
- const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues (*LCS);
1036
-
1037
- for (RegionStoreManager::SValListTy::const_iterator I = Vals.begin (),
1038
- E = Vals.end ();
1039
- I != E; ++I)
1040
- VisitBinding (*I);
1039
+ // `getInterestingValues()` returns SVals contained within LazyCompoundVals,
1040
+ // so there is no need to visit them.
1041
+ for (SVal V : RM.getInterestingValues (*LCS))
1042
+ if (!isa<nonloc::LazyCompoundVal>(V))
1043
+ VisitBinding (V);
1041
1044
1042
1045
return ;
1043
1046
}
@@ -1290,15 +1293,10 @@ void RegionStoreManager::populateWorkList(InvalidateRegionsWorker &W,
1290
1293
if (Optional<nonloc::LazyCompoundVal> LCS =
1291
1294
V.getAs <nonloc::LazyCompoundVal>()) {
1292
1295
1293
- const SValListTy &Vals = getInterestingValues (*LCS);
1294
-
1295
- for (SValListTy::const_iterator I = Vals.begin (),
1296
- E = Vals.end (); I != E; ++I) {
1297
- // Note: the last argument is false here because these are
1298
- // non-top-level regions.
1299
- if (const MemRegion *R = (*I).getAsRegion ())
1296
+ for (SVal S : getInterestingValues (*LCS))
1297
+ if (const MemRegion *R = S.getAsRegion ())
1300
1298
W.AddToWorkList (R);
1301
- }
1299
+
1302
1300
continue ;
1303
1301
}
1304
1302
@@ -2283,11 +2281,9 @@ RegionStoreManager::getInterestingValues(nonloc::LazyCompoundVal LCV) {
2283
2281
if (V.isUnknownOrUndef () || V.isConstant ())
2284
2282
continue ;
2285
2283
2286
- if (Optional<nonloc::LazyCompoundVal> InnerLCV =
2287
- V.getAs <nonloc::LazyCompoundVal>()) {
2284
+ if (auto InnerLCV = V.getAs <nonloc::LazyCompoundVal>()) {
2288
2285
const SValListTy &InnerList = getInterestingValues (*InnerLCV);
2289
2286
List.insert (List.end (), InnerList.begin (), InnerList.end ());
2290
- continue ;
2291
2287
}
2292
2288
2293
2289
List.push_back (V);
@@ -2835,20 +2831,17 @@ void RemoveDeadBindingsWorker::VisitCluster(const MemRegion *baseR,
2835
2831
}
2836
2832
2837
2833
void RemoveDeadBindingsWorker::VisitBinding (SVal V) {
2838
- // Is it a LazyCompoundVal? All referenced regions are live as well.
2839
- if (Optional<nonloc::LazyCompoundVal> LCS =
2840
- V.getAs <nonloc::LazyCompoundVal>()) {
2841
- // TODO: Make regions referred to by `lazyCompoundVals` that are bound to
2842
- // subregions of the `LCS.getRegion()` also lazily copied.
2843
- if (const MemRegion *R = LCS->getRegion ())
2844
- SymReaper.markLazilyCopied (R);
2845
-
2846
- const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues (*LCS);
2847
-
2848
- for (RegionStoreManager::SValListTy::const_iterator I = Vals.begin (),
2849
- E = Vals.end ();
2850
- I != E; ++I)
2851
- VisitBinding (*I);
2834
+ // Is it a LazyCompoundVal? All referenced regions are live as well.
2835
+ // The LazyCompoundVal itself is not live but should be readable.
2836
+ if (auto LCS = V.getAs <nonloc::LazyCompoundVal>()) {
2837
+ SymReaper.markLazilyCopied (LCS->getRegion ());
2838
+
2839
+ for (SVal V : RM.getInterestingValues (*LCS)) {
2840
+ if (auto DepLCS = V.getAs <nonloc::LazyCompoundVal>())
2841
+ SymReaper.markLazilyCopied (DepLCS->getRegion ());
2842
+ else
2843
+ VisitBinding (V);
2844
+ }
2852
2845
2853
2846
return ;
2854
2847
}
0 commit comments