[lld] r296619 - Simplify. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 06:12:21 PST 2017


Author: rafael
Date: Wed Mar  1 08:12:21 2017
New Revision: 296619

URL: http://llvm.org/viewvc/llvm-project?rev=296619&view=rev
Log:
Simplify. NFC.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296619&r1=296618&r2=296619&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Mar  1 08:12:21 2017
@@ -434,7 +434,8 @@ template <class ELFT> void LinkerScript<
 }
 
 template <class ELFT> void LinkerScript<ELFT>::flush() {
-  if (!CurOutSec || !AlreadyOutputOS.insert(CurOutSec).second)
+  assert(CurOutSec);
+  if (!AlreadyOutputOS.insert(CurOutSec).second)
     return;
   for (InputSection *I : CurOutSec->Sections)
     output(I);
@@ -446,7 +447,6 @@ template <class ELFT> void LinkerScript<
   if (AlreadyOutputOS.count(Sec))
     return;
 
-  flush();
   CurOutSec = Sec;
 
   Dot = alignTo(Dot, CurOutSec->Addralign);
@@ -484,23 +484,19 @@ template <class ELFT> void LinkerScript<
   // calculates and assigns the offsets for each section and also
   // updates the output section size.
   auto &ICmd = cast<InputSectionDescription>(Base);
-  for (InputSectionBase *ID : ICmd.Sections) {
+  for (InputSectionBase *IB : ICmd.Sections) {
     // We tentatively added all synthetic sections at the beginning and removed
     // empty ones afterwards (because there is no way to know whether they were
     // going be empty or not other than actually running linker scripts.)
     // We need to ignore remains of empty sections.
-    if (auto *Sec = dyn_cast<SyntheticSection>(ID))
+    if (auto *Sec = dyn_cast<SyntheticSection>(IB))
       if (Sec->empty())
         continue;
 
-    auto *IB = static_cast<InputSectionBase *>(ID);
     if (!IB->Live)
       continue;
     switchTo(IB->OutSec);
-    if (auto *I = dyn_cast<InputSection>(IB))
-      output(I);
-    else
-      flush();
+    output(cast<InputSection>(IB));
   }
 }
 




More information about the llvm-commits mailing list