[lld] ad03074 - [lld/mac] Make two local variables const

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 09:03:06 PDT 2022


Author: Nico Weber
Date: 2022-10-13T12:02:51-04:00
New Revision: ad030740b2db6135880376a38259195c65ce2110

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

LOG: [lld/mac] Make two local variables const

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.

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

Added: 
    

Modified: 
    lld/MachO/InputFiles.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index ee382a5aeabc..9c2051e49495 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -807,7 +807,7 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
     // 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 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
       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();


        


More information about the llvm-commits mailing list