`OperandPass` sometimes manipulate the set while iteration, this
workaround forces the `iterate` method to iterate only elements that
has been existed from the beginning of the iteration.
Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
void Set::iterate(const std::function<void(const Index &, Object &)> &fn)
{
+ // TODO Remove this workaround
+ // This implementation is a workaround in case of adding operands while iteration
+ //
+ // // Original Implementation (We probably should be back to this)
+ // for (auto &e : _objects)
+ // {
+ // fn(e.first, *e.second);
+ // }
+
+ std::list<Index> l;
+
for (auto &e : _objects)
{
- fn(e.first, *e.second);
+ l.push_back(e.first);
+ }
+
+ for (auto index : l)
+ {
+ fn(index, *_objects[index]);
}
}