[llvm] [Transforms] Use range-based for loops (NFC) (PR #97195)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 30 11:37:48 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:
I just tried to drop `&`, but that resulted in:
```
llvm/lib/Transforms/IPO/ConstantMerge.cpp:229:21: error: loop variable '[Old, New]'
creates a copy from type 'std::pair<llvm::GlobalVariable *, llvm::GlobalVariable *>
const' [-Werror,-Wrange-loop-construct]
```
https://github.com/llvm/llvm-project/pull/97195
More information about the llvm-commits
mailing list