[lld] r296308 - De-template OutputSectionFactory.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 18:31:48 PST 2017


Author: ruiu
Date: Sun Feb 26 20:31:48 2017
New Revision: 296308

URL: http://llvm.org/viewvc/llvm-project?rev=296308&view=rev
Log:
De-template OutputSectionFactory.

Since OutputSection is no longer a template, it doesn't make much
sense to tempalte its factory class.

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

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296308&r1=296307&r2=296308&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sun Feb 26 20:31:48 2017
@@ -321,7 +321,7 @@ LinkerScript<ELFT>::createInputSectionLi
 }
 
 template <class ELFT>
-void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
+void LinkerScript<ELFT>::processCommands(OutputSectionFactory &Factory) {
   for (unsigned I = 0; I < Opt.Commands.size(); ++I) {
     auto Iter = Opt.Commands.begin() + I;
     const std::unique_ptr<BaseCommand> &Base1 = *Iter;
@@ -383,18 +383,17 @@ void LinkerScript<ELFT>::processCommands
 
       // Add input sections to an output section.
       for (InputSectionBase *S : V)
-        Factory.addInputSec(S, Cmd->Name);
+        Factory.addInputSec<ELFT>(S, Cmd->Name);
     }
   }
 }
 
 // Add sections that didn't match any sections command.
 template <class ELFT>
-void LinkerScript<ELFT>::addOrphanSections(
-    OutputSectionFactory<ELFT> &Factory) {
+void LinkerScript<ELFT>::addOrphanSections(OutputSectionFactory &Factory) {
   for (InputSectionBase *S : Symtab<ELFT>::X->Sections)
     if (S->Live && !S->OutSec)
-      Factory.addInputSec(S, getOutputSectionName(S->Name));
+      Factory.addInputSec<ELFT>(S, getOutputSectionName(S->Name));
 }
 
 template <class ELFT> static bool isTbss(OutputSection *Sec) {

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=296308&r1=296307&r2=296308&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Sun Feb 26 20:31:48 2017
@@ -34,7 +34,7 @@ class SymbolBody;
 class InputSectionBase;
 class InputSection;
 class OutputSection;
-template <class ELFT> class OutputSectionFactory;
+class OutputSectionFactory;
 class InputSectionBase;
 
 // This represents an expression in the linker script.
@@ -247,8 +247,8 @@ public:
   LinkerScript();
   ~LinkerScript();
 
-  void processCommands(OutputSectionFactory<ELFT> &Factory);
-  void addOrphanSections(OutputSectionFactory<ELFT> &Factory);
+  void processCommands(OutputSectionFactory &Factory);
+  void addOrphanSections(OutputSectionFactory &Factory);
   void removeEmptyCommands();
   void adjustSectionsBeforeSorting();
   void adjustSectionsAfterSorting();

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=296308&r1=296307&r2=296308&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Sun Feb 26 20:31:48 2017
@@ -339,8 +339,7 @@ static SectionKey createKey(InputSection
   return SectionKey{OutsecName, Flags, Alignment};
 }
 
-template <class ELFT>
-OutputSectionFactory<ELFT>::OutputSectionFactory(
+OutputSectionFactory::OutputSectionFactory(
     std::vector<OutputSection *> &OutputSections)
     : OutputSections(OutputSections) {}
 
@@ -368,15 +367,15 @@ template <class ELFT> static void report
 }
 
 template <class ELFT>
-void OutputSectionFactory<ELFT>::addInputSec(InputSectionBase *IS,
-                                             StringRef OutsecName) {
+void OutputSectionFactory::addInputSec(InputSectionBase *IS,
+                                       StringRef OutsecName) {
   if (!IS->Live) {
     reportDiscarded<ELFT>(IS);
     return;
   }
 
   SectionKey Key = createKey<ELFT>(IS, OutsecName);
-  uintX_t Flags = getOutFlags<ELFT>(IS);
+  uint64_t Flags = getOutFlags<ELFT>(IS);
   OutputSection *&Sec = Map[Key];
   if (Sec) {
     if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
@@ -403,7 +402,7 @@ void OutputSectionFactory<ELFT>::addInpu
   Sec->addSection(IS);
 }
 
-template <class ELFT> OutputSectionFactory<ELFT>::~OutputSectionFactory() {}
+OutputSectionFactory::~OutputSectionFactory() {}
 
 SectionKey DenseMapInfo<SectionKey>::getEmptyKey() {
   return SectionKey{DenseMapInfo<StringRef>::getEmptyKey(), 0, 0};
@@ -446,9 +445,13 @@ template void OutputSection::writeTo<ELF
 template void OutputSection::writeTo<ELF64LE>(uint8_t *Buf);
 template void OutputSection::writeTo<ELF64BE>(uint8_t *Buf);
 
-template class OutputSectionFactory<ELF32LE>;
-template class OutputSectionFactory<ELF32BE>;
-template class OutputSectionFactory<ELF64LE>;
-template class OutputSectionFactory<ELF64BE>;
+template void OutputSectionFactory::addInputSec<ELF32LE>(InputSectionBase *,
+                                                         StringRef);
+template void OutputSectionFactory::addInputSec<ELF32BE>(InputSectionBase *,
+                                                         StringRef);
+template void OutputSectionFactory::addInputSec<ELF64LE>(InputSectionBase *,
+                                                         StringRef);
+template void OutputSectionFactory::addInputSec<ELF64BE>(InputSectionBase *,
+                                                         StringRef);
 }
 }

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=296308&r1=296307&r2=296308&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Sun Feb 26 20:31:48 2017
@@ -134,13 +134,12 @@ namespace elf {
 // input section. Output section type is determined by various
 // factors, including input section's sh_flags, sh_type and
 // linker scripts.
-template <class ELFT> class OutputSectionFactory {
-  typedef typename ELFT::Shdr Elf_Shdr;
-  typedef typename ELFT::uint uintX_t;
-
+class OutputSectionFactory {
 public:
   OutputSectionFactory(std::vector<OutputSection *> &OutputSections);
   ~OutputSectionFactory();
+
+  template <class ELFT>
   void addInputSec(InputSectionBase *IS, StringRef OutsecName);
 
 private:

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296308&r1=296307&r2=296308&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Feb 26 20:31:48 2017
@@ -78,7 +78,7 @@ private:
   std::unique_ptr<FileOutputBuffer> Buffer;
 
   std::vector<OutputSection *> OutputSections;
-  OutputSectionFactory<ELFT> Factory{OutputSections};
+  OutputSectionFactory Factory{OutputSections};
 
   void addRelIpltSymbols();
   void addStartEndSymbols();
@@ -920,7 +920,7 @@ void Writer<ELFT>::forEachRelSec(std::fu
 template <class ELFT> void Writer<ELFT>::createSections() {
   for (InputSectionBase *IS : Symtab<ELFT>::X->Sections)
     if (IS)
-      Factory.addInputSec(IS, getOutputSectionName(IS->Name));
+      Factory.addInputSec<ELFT>(IS, getOutputSectionName(IS->Name));
 
   sortBySymbolsOrder<ELFT>(OutputSections);
   sortInitFini<ELFT>(findSection(".init_array"));




More information about the llvm-commits mailing list