[lld] 085898d - [ELF] Drop const qualifier to fix -Wrange-loop-analysis. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 4 12:24:53 PST 2020


Author: Fangrui Song
Date: 2020-01-04T12:24:39-08:00
New Revision: 085898d469ab782f0a26f119b109aa8eb5d37745

URL: https://github.com/llvm/llvm-project/commit/085898d469ab782f0a26f119b109aa8eb5d37745
DIFF: https://github.com/llvm/llvm-project/commit/085898d469ab782f0a26f119b109aa8eb5d37745.diff

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

```
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 (DiagnoseForRangeConstVariableCopies) 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.

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D72211

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index c57585e187ef..894fe2eb93b2 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1619,7 +1619,7 @@ void ThunkCreator::mergeThunks(ArrayRef<OutputSection *> outputSections) {
         // 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,


        


More information about the llvm-commits mailing list