Simplify. NFC.

llvm-svn: 287514
This commit is contained in:
Rui Ueyama 2016-11-21 02:10:12 +00:00
parent 43b5523069
commit e0be2901cd
1 changed files with 18 additions and 21 deletions

View File

@ -128,17 +128,19 @@ bool BytesDataCommand::classof(const BaseCommand *C) {
template <class ELFT> LinkerScript<ELFT>::LinkerScript() = default; template <class ELFT> LinkerScript<ELFT>::LinkerScript() = default;
template <class ELFT> LinkerScript<ELFT>::~LinkerScript() = default; template <class ELFT> LinkerScript<ELFT>::~LinkerScript() = default;
template <class ELFT> static StringRef basename(InputSectionBase<ELFT> *S) {
if (S->getFile())
return sys::path::filename(S->getFile()->getName());
return "";
}
template <class ELFT> template <class ELFT>
bool LinkerScript<ELFT>::shouldKeep(InputSectionBase<ELFT> *S) { bool LinkerScript<ELFT>::shouldKeep(InputSectionBase<ELFT> *S) {
for (InputSectionDescription *ID : Opt.KeptSections) { for (InputSectionDescription *ID : Opt.KeptSections)
StringRef Filename = S->getFile()->getName(); if (ID->FilePat.match(basename(S)))
if (!ID->FilePat.match(sys::path::filename(Filename)))
continue;
for (SectionPattern &P : ID->SectionPatterns) for (SectionPattern &P : ID->SectionPatterns)
if (P.SectionPat.match(S->Name)) if (P.SectionPat.match(S->Name))
return true; return true;
}
return false; return false;
} }
@ -202,16 +204,14 @@ void LinkerScript<ELFT>::computeInputSections(InputSectionDescription *I) {
if (!S->Live || S->Assigned) if (!S->Live || S->Assigned)
continue; continue;
StringRef Filename; StringRef Filename = basename(S);
if (elf::ObjectFile<ELFT> *F = S->getFile()) if (!I->FilePat.match(Filename) || Pat.ExcludedFilePat.match(Filename))
Filename = sys::path::filename(F->getName()); continue;
if (!Pat.SectionPat.match(S->Name))
if (I->FilePat.match(Filename) && !Pat.ExcludedFilePat.match(Filename) && continue;
Pat.SectionPat.match(S->Name)) {
I->Sections.push_back(S); I->Sections.push_back(S);
S->Assigned = true; S->Assigned = true;
} }
}
// Sort sections as instructed by SORT-family commands and --sort-section // Sort sections as instructed by SORT-family commands and --sort-section
// option. Because SORT-family commands can be nested at most two depth // option. Because SORT-family commands can be nested at most two depth
@ -343,9 +343,6 @@ void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
if (shouldDefine<ELFT>(OutCmd)) if (shouldDefine<ELFT>(OutCmd))
addSymbol<ELFT>(OutCmd); addSymbol<ELFT>(OutCmd);
if (V.empty())
continue;
for (InputSectionBase<ELFT> *Sec : V) { for (InputSectionBase<ELFT> *Sec : V) {
addSection(Factory, Sec, Cmd->Name); addSection(Factory, Sec, Cmd->Name);
if (uint32_t Subalign = Cmd->SubalignExpr ? Cmd->SubalignExpr(0) : 0) if (uint32_t Subalign = Cmd->SubalignExpr ? Cmd->SubalignExpr(0) : 0)