Convert InputSectionBase to a class.

Removing this template is not a big win by itself, but opens the way
for removing more templates.

llvm-svn: 295923
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 15d467a..3b3cb80 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -92,8 +92,8 @@
   if (A->kind() == InputSectionData::Synthetic ||
       B->kind() == InputSectionData::Synthetic)
     return false;
-  auto *LA = cast<InputSection<ELFT>>(A->getLinkOrderDep());
-  auto *LB = cast<InputSection<ELFT>>(B->getLinkOrderDep());
+  auto *LA = cast<InputSection<ELFT>>(A->template getLinkOrderDep<ELFT>());
+  auto *LB = cast<InputSection<ELFT>>(B->template getLinkOrderDep<ELFT>());
   OutputSectionBase *AOut = LA->OutSec;
   OutputSectionBase *BOut = LB->OutSec;
   if (AOut != BOut)
@@ -111,7 +111,7 @@
     // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
     // need to translate the InputSection sh_link to the OutputSection sh_link,
     // all InputSections in the OutputSection have the same dependency.
-    if (auto *D = this->Sections.front()->getLinkOrderDep())
+    if (auto *D = this->Sections.front()->template getLinkOrderDep<ELFT>())
       this->Link = D->OutSec->SectionIndex;
   }
 
@@ -126,7 +126,7 @@
   this->Link = In<ELFT>::SymTab->OutSec->SectionIndex;
   // sh_info for SHT_REL[A] sections should contain the section header index of
   // the section to which the relocation applies.
-  InputSectionBase<ELFT> *S = First->getRelocatedSection();
+  InputSectionBase *S = First->getRelocatedSection();
   this->Info = S->OutSec->SectionIndex;
 }
 
@@ -157,7 +157,7 @@
   for (InputSection<ELFT> *S : Sections) {
     Off = alignTo(Off, S->Alignment);
     S->OutSecOff = Off;
-    Off += S->getSize();
+    Off += S->template getSize<ELFT>();
   }
   this->Size = Off;
 }
@@ -221,12 +221,12 @@
 template <class ELFT>
 static bool compCtors(const InputSection<ELFT> *A,
                       const InputSection<ELFT> *B) {
-  bool BeginA = isCrtbegin(A->getFile()->getName());
-  bool BeginB = isCrtbegin(B->getFile()->getName());
+  bool BeginA = isCrtbegin(A->template getFile<ELFT>()->getName());
+  bool BeginB = isCrtbegin(B->template getFile<ELFT>()->getName());
   if (BeginA != BeginB)
     return BeginA;
-  bool EndA = isCrtend(A->getFile()->getName());
-  bool EndB = isCrtend(B->getFile()->getName());
+  bool EndA = isCrtend(A->template getFile<ELFT>()->getName());
+  bool EndB = isCrtend(B->template getFile<ELFT>()->getName());
   if (EndA != EndB)
     return EndB;
   StringRef X = A->Name;
@@ -297,7 +297,8 @@
   SymbolBody *Personality = nullptr;
   unsigned FirstRelI = Piece.FirstRelocation;
   if (FirstRelI != (unsigned)-1)
-    Personality = &Sec->getFile()->getRelocTargetSym(Rels[FirstRelI]);
+    Personality =
+        &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
 
   // Search for an existing CIE by CIE contents/relocation target pair.
   CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
@@ -321,11 +322,11 @@
   if (FirstRelI == (unsigned)-1)
     return false;
   const RelTy &Rel = Rels[FirstRelI];
-  SymbolBody &B = Sec->getFile()->getRelocTargetSym(Rel);
+  SymbolBody &B = Sec->template getFile<ELFT>()->getRelocTargetSym(Rel);
   auto *D = dyn_cast<DefinedRegular<ELFT>>(&B);
   if (!D || !D->Section)
     return false;
-  InputSectionBase<ELFT> *Target = D->Section->Repl;
+  InputSectionBase *Target = D->Section->Repl;
   return Target && Target->Live;
 }
 
@@ -380,9 +381,9 @@
 
   if (Sec->NumRelocations) {
     if (Sec->AreRelocsRela)
-      addSectionAux(Sec, Sec->relas());
+      addSectionAux(Sec, Sec->template relas<ELFT>());
     else
-      addSectionAux(Sec, Sec->rels());
+      addSectionAux(Sec, Sec->template rels<ELFT>());
     return;
   }
   addSectionAux(Sec, makeArrayRef<Elf_Rela>(nullptr, nullptr));
@@ -464,7 +465,7 @@
   }
 
   for (EhInputSection<ELFT> *S : Sections)
-    S->relocate(Buf, nullptr);
+    S->template relocate<ELFT>(Buf, nullptr);
 
   // Construct .eh_frame_hdr. .eh_frame_hdr is a binary search table
   // to get a FDE from an address to which FDE is applied. So here
@@ -482,12 +483,12 @@
 }
 
 template <class ELFT>
-static typename ELFT::uint getOutFlags(InputSectionBase<ELFT> *S) {
+static typename ELFT::uint getOutFlags(InputSectionBase *S) {
   return S->Flags & ~SHF_GROUP & ~SHF_COMPRESSED;
 }
 
 template <class ELFT>
-static SectionKey createKey(InputSectionBase<ELFT> *C, StringRef OutsecName) {
+static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) {
   //  The ELF spec just says
   // ----------------------------------------------------------------
   // In the first phase, input sections that match in name, type and
@@ -564,23 +565,23 @@
          Type == SHT_NOTE;
 }
 
-template <class ELFT> static void reportDiscarded(InputSectionBase<ELFT> *IS) {
+template <class ELFT> static void reportDiscarded(InputSectionBase *IS) {
   if (!Config->PrintGcSections)
     return;
   message("removing unused section from '" + IS->Name + "' in file '" +
-          IS->getFile()->getName());
+          IS->getFile<ELFT>()->getName());
 }
 
 template <class ELFT>
-void OutputSectionFactory<ELFT>::addInputSec(InputSectionBase<ELFT> *IS,
+void OutputSectionFactory<ELFT>::addInputSec(InputSectionBase *IS,
                                              StringRef OutsecName) {
   if (!IS->Live) {
-    reportDiscarded(IS);
+    reportDiscarded<ELFT>(IS);
     return;
   }
 
-  SectionKey Key = createKey(IS, OutsecName);
-  uintX_t Flags = getOutFlags(IS);
+  SectionKey Key = createKey<ELFT>(IS, OutsecName);
+  uintX_t Flags = getOutFlags<ELFT>(IS);
   OutputSectionBase *&Sec = Map[Key];
   if (Sec) {
     if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
@@ -596,7 +597,7 @@
     Sec->Flags |= Flags;
   } else {
     uint32_t Type = IS->Type;
-    if (IS->kind() == InputSectionBase<ELFT>::EHFrame) {
+    if (IS->kind() == InputSectionBase::EHFrame) {
       Out<ELFT>::EhFrame->addSection(IS);
       return;
     }