[all-commits] [llvm/llvm-project] 085898: [ELF] Drop const qualifier to fix -Wrange-loop-ana...

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


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 085898d469ab782f0a26f119b109aa8eb5d37745
      https://github.com/llvm/llvm-project/commit/085898d469ab782f0a26f119b109aa8eb5d37745
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M lld/ELF/Relocations.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list