[clang] [NFC][Clang] Use range for loops in ClangDiagnosticsEmitter (PR #115573)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 11 14:27:51 PST 2024


================
@@ -185,10 +174,8 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
   }
 
   // Assign unique ID numbers to the groups.
-  unsigned IDNo = 0;
-  for (std::map<std::string, GroupInfo>::iterator
-       I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I, ++IDNo)
-    I->second.IDNo = IDNo;
+  for (auto [IdNo, Iter] : enumerate(DiagsInGroup))
+    Iter.second.IDNo = IdNo;
----------------
kazutakahirata wrote:

If you are taking each element by value (as as opposed to reference), does `Iter.second.IDNo = Idno;` actually update the original?  Or does it just update the copy?

https://github.com/llvm/llvm-project/pull/115573


More information about the cfe-commits mailing list