[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 01:44:35 PST 2018


a.sidorin added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1256
+    if (Cond(Reg.second)) {
+      State = setIteratorPosition(State, Reg.first, Proc(Reg.second));
+    }
----------------
baloghadamsoftware wrote:
> a.sidorin wrote:
> > Updating ProgramState is usually considered as an expensive operation. Instead, we can update maps (RegionMap and SymbolMap) and then, if they have any updates, create a state containing these maps. What do you think?
> How to update ImmutableMap?
You can create a new Immutable map from existing with factory methods:
```
auto Factory = State->get_context<IteratorRegionMap>();
auto Map = State->get<RegionMap>();
Map = Factory.add(Map, Key, Value);
Map = Factory.add(Map, Key2, Value2);
State = State->set<IteratorRegionMap>(Map);
```


https://reviews.llvm.org/D32747





More information about the cfe-commits mailing list