From: Rafael Espindola Date: Mon, 12 Sep 2016 16:05:16 +0000 (+0000) Subject: Simplify handling of /DISCARD/. NFC. X-Git-Tag: llvmorg-4.0.0-rc1~10056 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7bd37870bc2c501e4587cf5ca2b69b77346df95a;p=platform%2Fupstream%2Fllvm.git Simplify handling of /DISCARD/. NFC. llvm-svn: 281222 --- diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index ef8ccb9..e3f3051 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -149,14 +149,10 @@ getComparator(SortKind K) { } template -void LinkerScript::discard(OutputSectionCommand &Cmd) { - for (const std::unique_ptr &Base : Cmd.Commands) { - if (auto *Cmd = dyn_cast(Base.get())) { - for (InputSectionBase *S : getInputSections(Cmd)) { - S->Live = false; - reportDiscarded(S); - } - } +void LinkerScript::discard(ArrayRef *> V) { + for (InputSectionBase *S : V) { + S->Live = false; + reportDiscarded(S); } } @@ -228,12 +224,13 @@ void LinkerScript::createSections(OutputSectionFactory &Factory) { } if (auto *Cmd = dyn_cast(Base1.get())) { + std::vector *> V = createInputSectionList(*Cmd); + if (Cmd->Name == "/DISCARD/") { - discard(*Cmd); + discard(V); continue; } - std::vector *> V = createInputSectionList(*Cmd); if (V.empty()) continue; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index ea57ee9..9232715 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -188,7 +188,7 @@ private: std::vector *> getInputSections(const InputSectionDescription *); - void discard(OutputSectionCommand &Cmd); + void discard(ArrayRef *> V); std::vector *> createInputSectionList(OutputSectionCommand &Cmd);