[lld] r270341 - Use ArrayRef<uint8_t> for binary data instead of StringRef. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat May 21 17:17:11 PDT 2016


Author: ruiu
Date: Sat May 21 19:17:11 2016
New Revision: 270341

URL: http://llvm.org/viewvc/llvm-project?rev=270341&view=rev
Log:
Use ArrayRef<uint8_t> for binary data instead of StringRef. NFC.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=270341&r1=270340&r2=270341&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Sat May 21 19:17:11 2016
@@ -976,12 +976,12 @@ template <class ELFT>
 EHRegion<ELFT>::EHRegion(EHInputSection<ELFT> *S, unsigned Index)
     : S(S), Index(Index) {}
 
-template <class ELFT> StringRef EHRegion<ELFT>::data() const {
+template <class ELFT> ArrayRef<uint8_t> EHRegion<ELFT>::data() const {
   ArrayRef<uint8_t> SecData = S->getSectionData();
   size_t Start = S->Pieces[Index].InputOff;
   size_t End = (Index == S->Pieces.size() - 1) ? SecData.size()
                                                : S->Pieces[Index + 1].InputOff;
-  return StringRef((const char *)SecData.data() + Start, End - Start);
+  return SecData.slice(Start, End - Start);
 }
 
 template <class ELFT>
@@ -1211,12 +1211,12 @@ void EHOutputSection<ELFT>::addSection(I
 }
 
 template <class ELFT>
-static void writeCieFde(uint8_t *Buf, StringRef S) {
-  memcpy(Buf, S.data(), S.size());
+static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
+  memcpy(Buf, D.data(), D.size());
 
   // Fix the size field. -4 since size does not include the size field itself.
   const endianness E = ELFT::TargetEndianness;
-  write32<E>(Buf, alignTo(S.size(), sizeof(typename ELFT::uint)) - 4);
+  write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
 }
 
 template <class ELFT> void EHOutputSection<ELFT>::finalize() {

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=270341&r1=270340&r2=270341&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Sat May 21 19:17:11 2016
@@ -328,7 +328,7 @@ private:
 template <class ELFT> struct EHRegion {
   typedef typename ELFT::uint uintX_t;
   EHRegion(EHInputSection<ELFT> *S, unsigned Index);
-  StringRef data() const;
+  ArrayRef<uint8_t> data() const;
   EHInputSection<ELFT> *S;
   unsigned Index;
 };




More information about the llvm-commits mailing list