[PATCH] D72211: [ELF] Drop const qualifier to fix -Wrange-loop-analysis. NFC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 4 12:06:29 PST 2020


MaskRay created this revision.
MaskRay added a reviewer: Mordante.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

  lld/ELF/Relocations.cpp:1622:56: warning: loop variable 'ts' of type 'const std::pair<ThunkSection *, uint32_t>' (aka 'const pair<lld::elf::ThunkSection *, unsigned int>') creates a copy from type 'const std::pair<ThunkSection *, uint32_t>' [-Wrange-loop-analysis]
          for (const std::pair<ThunkSection *, uint32_t> ts : isd->thunkSections)

Drop const qualifier to fix -Wrange-loop-analysis.
We can make -Wrange-loop-analysis warnings on `const A` more permissive on more
types (e.g. POD -> trivially copyable), unfortunately it will not make std::pair good,
because `constexpr pair& operator=(const pair& p);` is unfortunately user-defined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72211

Files:
  lld/ELF/Relocations.cpp


Index: lld/ELF/Relocations.cpp
===================================================================
--- lld/ELF/Relocations.cpp
+++ lld/ELF/Relocations.cpp
@@ -1619,7 +1619,7 @@
         // those inserted in previous passes. Extract the Thunks created this
         // pass and order them in ascending outSecOff.
         std::vector<ThunkSection *> newThunks;
-        for (const std::pair<ThunkSection *, uint32_t> ts : isd->thunkSections)
+        for (std::pair<ThunkSection *, uint32_t> ts : isd->thunkSections)
           if (ts.second == pass)
             newThunks.push_back(ts.first);
         llvm::stable_sort(newThunks,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72211.236194.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200104/676e102a/attachment.bin>


More information about the llvm-commits mailing list