[lld] r336892 - [ELF] - Simplify code. NFC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 12 01:33:02 PDT 2018


Author: grimar
Date: Thu Jul 12 01:33:02 2018
New Revision: 336892

URL: http://llvm.org/viewvc/llvm-project?rev=336892&view=rev
Log:
[ELF] - Simplify code. NFC.

Just use getDataAs for taking sections contents.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=336892&r1=336891&r2=336892&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Jul 12 01:33:02 2018
@@ -1375,8 +1375,7 @@ static bool isDuplicateArmExidxSec(Input
   };
 
   // Get the last table Entry from the previous .ARM.exidx section.
-  const ExidxEntry &PrevEntry = *reinterpret_cast<const ExidxEntry *>(
-      Prev->Data.data() + Prev->getSize() - sizeof(ExidxEntry));
+  const ExidxEntry &PrevEntry = Prev->getDataAs<ExidxEntry>().back();
   if (IsExtabRef(PrevEntry.Unwind))
     return false;
 
@@ -1388,10 +1387,7 @@ static bool isDuplicateArmExidxSec(Input
   // consecutive identical entries are rare and the effort to check that they
   // are identical is high.
 
-  ArrayRef<const ExidxEntry> Entries(
-      reinterpret_cast<const ExidxEntry *>(Cur->Data.data()),
-      Cur->getSize() / sizeof(ExidxEntry));
-  for (const ExidxEntry &Entry : Entries)
+  for (const ExidxEntry Entry : Cur->getDataAs<ExidxEntry>())
     if (IsExtabRef(Entry.Unwind) || Entry.Unwind != PrevEntry.Unwind)
       return false;
   // All table entries in this .ARM.exidx Section can be merged into the




More information about the llvm-commits mailing list