[lld] r276144 - Use iterators to avoid dereferencing end().

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 10:41:18 PDT 2016


Author: rafael
Date: Wed Jul 20 12:41:18 2016
New Revision: 276144

URL: http://llvm.org/viewvc/llvm-project?rev=276144&view=rev
Log:
Use iterators to avoid dereferencing end().

Thanks to George Rimar for finding the problem.

Modified:
    lld/trunk/ELF/Relocations.cpp

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=276144&r1=276143&r2=276144&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Jul 20 12:41:18 2016
@@ -525,11 +525,11 @@ static void scanRelocs(InputSectionBase<
   ArrayRef<uint8_t> SectionData = C.getSectionData();
   const uint8_t *Buf = SectionData.begin();
 
-  SectionPiece *PieceI = nullptr;
-  SectionPiece *PieceE = nullptr;
+  std::vector<SectionPiece>::iterator PieceI;
+  std::vector<SectionPiece>::iterator PieceE;
   if (auto *Eh = dyn_cast<EhInputSection<ELFT>>(&C)) {
-    PieceI = &*Eh->Pieces.begin();
-    PieceE = &*Eh->Pieces.end();
+    PieceI = Eh->Pieces.begin();
+    PieceE = Eh->Pieces.end();
   }
 
   for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {




More information about the llvm-commits mailing list