[llvm] [Transforms] Use range-based for loops (NFC) (PR #97195)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 18:34:05 PDT 2024


================
@@ -226,9 +226,7 @@ static bool mergeConstants(Module &M) {
     // Now that we have figured out which replacements must be made, do them all
     // now.  This avoid invalidating the pointers in CMap, which are unneeded
     // now.
-    for (unsigned i = 0, e = SameContentReplacements.size(); i != e; ++i) {
-      GlobalVariable *Old = SameContentReplacements[i].first;
-      GlobalVariable *New = SameContentReplacements[i].second;
+    for (const auto &[Old, New] : SameContentReplacements) {
----------------
kazutakahirata wrote:

@dwblaikie I see the warning with clang-16.0.6.

Here is a reduced testcase: https://godbolt.org/z/4Eo43hb81

I tried clang-18.1.0, clang-17.0.1, and clang-16.0.0 on Compiler Explorer.  clang-16 and clang-17 issue the warning while clang-18 doesn't.  Probably, the compiler was fixed sometime between clang-17 and clang-18.

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


More information about the llvm-commits mailing list