Simplify. NFC.

llvm-svn: 296619
This commit is contained in:
Rafael Espindola 2017-03-01 14:12:21 +00:00
parent 90573e49c9
commit bd12e2a0ce
1 changed files with 5 additions and 9 deletions

View File

@ -434,7 +434,8 @@ template <class ELFT> void LinkerScript<ELFT>::output(InputSection *S) {
}
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<ELFT>::switchTo(OutputSection *Sec) {
if (AlreadyOutputOS.count(Sec))
return;
flush();
CurOutSec = Sec;
Dot = alignTo(Dot, CurOutSec->Addralign);
@ -484,23 +484,19 @@ template <class ELFT> void LinkerScript<ELFT>::process(BaseCommand &Base) {
// 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));
}
}