[lld] r277720 - Remove redundant argument.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 05:13:06 PDT 2016


Author: rafael
Date: Thu Aug  4 07:13:05 2016
New Revision: 277720

URL: http://llvm.org/viewvc/llvm-project?rev=277720&view=rev
Log:
Remove redundant argument.

But always set Script<ELFT>::X->OutputSections.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.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=277720&r1=277719&r2=277720&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Aug  4 07:13:05 2016
@@ -159,10 +159,7 @@ template <class ELFT> struct SectionsSor
 
 template <class ELFT>
 void LinkerScript<ELFT>::createSections(
-    std::vector<OutputSectionBase<ELFT> *> *Out,
     OutputSectionFactory<ELFT> &Factory) {
-  OutputSections = Out;
-
   for (auto &P : getSectionMap()) {
     StringRef OutputName = P.first;
     const InputSectionDescription *Cmd = P.second;
@@ -181,7 +178,7 @@ void LinkerScript<ELFT>::createSections(
                        SectionsSorter<ELFT>(Cmd->Sort));
 
     for (InputSectionBase<ELFT> *S : Sections)
-      addSection(Factory, *Out, S, OutputName);
+      addSection(Factory, *OutputSections, S, OutputName);
   }
 
   // Add all other input sections, which are not listed in script.
@@ -189,7 +186,7 @@ void LinkerScript<ELFT>::createSections(
        Symtab<ELFT>::X->getObjectFiles())
     for (InputSectionBase<ELFT> *S : F->getSections())
       if (!isDiscarded(S) && !S->OutSec)
-        addSection(Factory, *Out, S, getOutputSectionName(S));
+        addSection(Factory, *OutputSections, S, getOutputSectionName(S));
 
   // Remove from the output all the sections which did not meet
   // the optional constraints.
@@ -224,9 +221,8 @@ template <class ELFT> void LinkerScript<
   }
 }
 
-template <class ELFT>
-void LinkerScript<ELFT>::assignAddresses(
-    ArrayRef<OutputSectionBase<ELFT> *> Sections) {
+template <class ELFT> void LinkerScript<ELFT>::assignAddresses() {
+  ArrayRef<OutputSectionBase<ELFT> *> Sections = *OutputSections;
   // Orphan sections are sections present in the input files which
   // are not explicitly placed into the output file by the linker script.
   // We place orphan sections at end of file.
@@ -300,8 +296,8 @@ void LinkerScript<ELFT>::assignAddresses
 }
 
 template <class ELFT>
-std::vector<PhdrEntry<ELFT>>
-LinkerScript<ELFT>::createPhdrs(ArrayRef<OutputSectionBase<ELFT> *> Sections) {
+std::vector<PhdrEntry<ELFT>> LinkerScript<ELFT>::createPhdrs() {
+  ArrayRef<OutputSectionBase<ELFT> *> Sections = *OutputSections;
   std::vector<PhdrEntry<ELFT>> Ret;
 
   for (const PhdrsCommand &Cmd : Opt.PhdrsCommands) {

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=277720&r1=277719&r2=277720&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Aug  4 07:13:05 2016
@@ -137,20 +137,20 @@ template <class ELFT> class LinkerScript
   typedef typename ELFT::uint uintX_t;
 
 public:
-  void createSections(std::vector<OutputSectionBase<ELFT> *> *Out,
-                      OutputSectionFactory<ELFT> &Factory);
+  void createSections(OutputSectionFactory<ELFT> &Factory);
 
-  std::vector<PhdrEntry<ELFT>>
-  createPhdrs(ArrayRef<OutputSectionBase<ELFT> *> S);
+  std::vector<PhdrEntry<ELFT>> createPhdrs();
 
   ArrayRef<uint8_t> getFiller(StringRef Name);
   bool shouldKeep(InputSectionBase<ELFT> *S);
-  void assignAddresses(ArrayRef<OutputSectionBase<ELFT> *> S);
+  void assignAddresses();
   int compareSections(StringRef A, StringRef B);
   void addScriptedSymbols();
   bool hasPhdrsCommands();
   uintX_t getOutputSectionSize(StringRef Name);
 
+  std::vector<OutputSectionBase<ELFT> *> *OutputSections;
+
 private:
   std::vector<std::pair<StringRef, const InputSectionDescription *>>
   getSectionMap();
@@ -167,7 +167,6 @@ private:
   std::vector<size_t> getPhdrIndices(StringRef SectionName);
   size_t getPhdrIndex(StringRef PhdrName);
 
-  std::vector<OutputSectionBase<ELFT> *> *OutputSections;
   uintX_t Dot;
 };
 

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=277720&r1=277719&r2=277720&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Aug  4 07:13:05 2016
@@ -233,8 +233,9 @@ template <class ELFT> void Writer<ELFT>:
   CommonInputSection<ELFT> Common(getCommonSymbols<ELFT>());
   CommonInputSection<ELFT>::X = &Common;
 
+  Script<ELFT>::X->OutputSections = &OutputSections;
   if (ScriptConfig->HasContents)
-    Script<ELFT>::X->createSections(&OutputSections, Factory);
+    Script<ELFT>::X->createSections(Factory);
   else
     createSections();
 
@@ -245,12 +246,11 @@ template <class ELFT> void Writer<ELFT>:
   if (Config->Relocatable) {
     assignFileOffsets();
   } else {
-    Phdrs = Script<ELFT>::X->hasPhdrsCommands()
-                ? Script<ELFT>::X->createPhdrs(OutputSections)
-                : createPhdrs();
+    Phdrs = Script<ELFT>::X->hasPhdrsCommands() ? Script<ELFT>::X->createPhdrs()
+                                                : createPhdrs();
     fixHeaders();
     if (ScriptConfig->HasContents) {
-      Script<ELFT>::X->assignAddresses(OutputSections);
+      Script<ELFT>::X->assignAddresses();
     } else {
       fixSectionAlignments();
       assignAddresses();




More information about the llvm-commits mailing list