[Lldb-commits] [PATCH] Force iteration over FieldDecls and RecordDecls in deterministic order.

Adrian McCarthy amccarth at google.com
Mon Mar 23 08:03:30 PDT 2015


Nice find.


================
Comment at: source/Expression/ClangASTSource.cpp:1543
@@ -1546,5 +1542,3 @@
 
-    for (typename MapType::iterator fi = source_map.begin(), fe = source_map.end();
-         fi != fe;
-         ++fi)
+    for (const auto &fi : source_list)
     {
----------------
zturner wrote:
> Since I didn't call it out specifically in the CL, this is the line that was introducing the non-determinism when a DenseMap is used.
> 
> It would be possible to fix this by only copying the elements of the DenseMap<> out to a temporary list and sorting the list, but since iterating in a non-deterministic order is perilous, I will propose this change first.
Nit:  I assume `fi` was and abbreviation for "field iterator".  Since this is no longer and iterator and just (a reference to) the field, perhaps rename it.

http://reviews.llvm.org/D8512

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list