[lld] r275803 - Pass section by reference. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 09:05:09 PDT 2016


Author: rafael
Date: Mon Jul 18 11:05:09 2016
New Revision: 275803

URL: http://llvm.org/viewvc/llvm-project?rev=275803&view=rev
Log:
Pass section by reference. NFC.

Modified:
    lld/trunk/ELF/MarkLive.cpp

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=275803&r1=275802&r2=275803&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Mon Jul 18 11:05:09 2016
@@ -49,22 +49,22 @@ struct ResolvedReloc {
 };
 
 template <class ELFT>
-static typename ELFT::uint getAddend(InputSectionBase<ELFT> *Sec,
+static typename ELFT::uint getAddend(InputSectionBase<ELFT> &Sec,
                                      const typename ELFT::Rel &Rel) {
-  return Target->getImplicitAddend(Sec->getSectionData().begin(),
+  return Target->getImplicitAddend(Sec.getSectionData().begin(),
                                    Rel.getType(Config->Mips64EL));
 }
 
 template <class ELFT>
-static typename ELFT::uint getAddend(InputSectionBase<ELFT> *Sec,
+static typename ELFT::uint getAddend(InputSectionBase<ELFT> &Sec,
                                      const typename ELFT::Rela &Rel) {
   return Rel.r_addend;
 }
 
 template <class ELFT, class RelT>
-static ResolvedReloc<ELFT> resolveReloc(InputSectionBase<ELFT> *Sec,
+static ResolvedReloc<ELFT> resolveReloc(InputSectionBase<ELFT> &Sec,
                                         RelT &Rel) {
-  SymbolBody &B = Sec->getFile()->getRelocTargetSym(Rel);
+  SymbolBody &B = Sec.getFile()->getRelocTargetSym(Rel);
   auto *D = dyn_cast<DefinedRegular<ELFT>>(&B);
   if (!D || !D->Section)
     return {nullptr, 0};
@@ -75,7 +75,7 @@ static ResolvedReloc<ELFT> resolveReloc(
 }
 
 template <class ELFT, class Elf_Shdr>
-static void run(ELFFile<ELFT> &Obj, InputSectionBase<ELFT> *Sec,
+static void run(ELFFile<ELFT> &Obj, InputSectionBase<ELFT> &Sec,
                 Elf_Shdr *RelSec, std::function<void(ResolvedReloc<ELFT>)> Fn) {
   if (RelSec->sh_type == SHT_RELA) {
     for (const typename ELFT::Rela &RI : Obj.relas(RelSec))
@@ -88,10 +88,10 @@ static void run(ELFFile<ELFT> &Obj, Inpu
 
 // Calls Fn for each section that Sec refers to via relocations.
 template <class ELFT>
-static void forEachSuccessor(InputSection<ELFT> *Sec,
+static void forEachSuccessor(InputSection<ELFT> &Sec,
                              std::function<void(ResolvedReloc<ELFT>)> Fn) {
-  ELFFile<ELFT> &Obj = Sec->getFile()->getObj();
-  for (const typename ELFT::Shdr *RelSec : Sec->RelocSections)
+  ELFFile<ELFT> &Obj = Sec.getFile()->getObj();
+  for (const typename ELFT::Shdr *RelSec : Sec.RelocSections)
     run(Obj, Sec, RelSec, Fn);
 }
 
@@ -101,7 +101,7 @@ static void scanEhFrameSection(EhInputSe
   if (!EH.RelocSection)
     return;
   ELFFile<ELFT> &EObj = EH.getFile()->getObj();
-  run<ELFT>(EObj, &EH, EH.RelocSection, [&](ResolvedReloc<ELFT> R) {
+  run<ELFT>(EObj, EH, EH.RelocSection, [&](ResolvedReloc<ELFT> R) {
     if (!R.Sec || R.Sec == &InputSection<ELFT>::Discarded)
       return;
     if (R.Sec->getSectionHdr()->sh_flags & SHF_EXECINSTR)
@@ -192,7 +192,7 @@ template <class ELFT> void elf::markLive
 
   // Mark all reachable sections.
   while (!Q.empty())
-    forEachSuccessor<ELFT>(Q.pop_back_val(), Enqueue);
+    forEachSuccessor<ELFT>(*Q.pop_back_val(), Enqueue);
 }
 
 template void elf::markLive<ELF32LE>();




More information about the llvm-commits mailing list