[lld] r281222 - Simplify handling of /DISCARD/. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 09:05:16 PDT 2016


Author: rafael
Date: Mon Sep 12 11:05:16 2016
New Revision: 281222

URL: http://llvm.org/viewvc/llvm-project?rev=281222&view=rev
Log:
Simplify handling of /DISCARD/. NFC.

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

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=281222&r1=281221&r2=281222&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Sep 12 11:05:16 2016
@@ -149,14 +149,10 @@ getComparator(SortKind K) {
 }
 
 template <class ELFT>
-void LinkerScript<ELFT>::discard(OutputSectionCommand &Cmd) {
-  for (const std::unique_ptr<BaseCommand> &Base : Cmd.Commands) {
-    if (auto *Cmd = dyn_cast<InputSectionDescription>(Base.get())) {
-      for (InputSectionBase<ELFT> *S : getInputSections(Cmd)) {
-        S->Live = false;
-        reportDiscarded(S);
-      }
-    }
+void LinkerScript<ELFT>::discard(ArrayRef<InputSectionBase<ELFT> *> V) {
+  for (InputSectionBase<ELFT> *S : V) {
+    S->Live = false;
+    reportDiscarded(S);
   }
 }
 
@@ -228,12 +224,13 @@ void LinkerScript<ELFT>::createSections(
     }
 
     if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base1.get())) {
+      std::vector<InputSectionBase<ELFT> *> V = createInputSectionList(*Cmd);
+
       if (Cmd->Name == "/DISCARD/") {
-        discard(*Cmd);
+        discard(V);
         continue;
       }
 
-      std::vector<InputSectionBase<ELFT> *> V = createInputSectionList(*Cmd);
       if (V.empty())
         continue;
 

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=281222&r1=281221&r2=281222&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Mon Sep 12 11:05:16 2016
@@ -188,7 +188,7 @@ private:
   std::vector<InputSectionBase<ELFT> *>
   getInputSections(const InputSectionDescription *);
 
-  void discard(OutputSectionCommand &Cmd);
+  void discard(ArrayRef<InputSectionBase<ELFT> *> V);
 
   std::vector<InputSectionBase<ELFT> *>
   createInputSectionList(OutputSectionCommand &Cmd);




More information about the llvm-commits mailing list