[PATCH] D135877: [lld/mac] Make two local variables const

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 07:39:33 PDT 2022


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added projects: lld-macho, All.
thakis requested review of this revision.

While reading this code, I was wondering if we change these variables in the
loop. We don't, so make them const to make this easier to see next time.

No behavior change.


https://reviews.llvm.org/D135877

Files:
  lld/MachO/InputFiles.cpp


Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -807,7 +807,7 @@
     // subsection here.
     if (sections[i]->doneSplitting) {
       for (size_t j = 0; j < symbolIndices.size(); ++j) {
-        uint32_t symIndex = symbolIndices[j];
+        const uint32_t symIndex = symbolIndices[j];
         const NList &sym = nList[symIndex];
         StringRef name = strtab + sym.n_strx;
         uint64_t symbolOffset = sym.n_value - sectionAddr;
@@ -833,7 +833,7 @@
       return nList[lhs].n_value < nList[rhs].n_value;
     });
     for (size_t j = 0; j < symbolIndices.size(); ++j) {
-      uint32_t symIndex = symbolIndices[j];
+      const uint32_t symIndex = symbolIndices[j];
       const NList &sym = nList[symIndex];
       StringRef name = strtab + sym.n_strx;
       Subsection &subsec = subsections.back();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135877.467467.patch
Type: text/x-patch
Size: 926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221013/19b2a508/attachment.bin>


More information about the llvm-commits mailing list