[lld] r277150 - [ELF] - Linkerscript: make addSection() global function instead lambda. NFC.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 08:12:49 PDT 2016
Author: grimar
Date: Fri Jul 29 10:12:48 2016
New Revision: 277150
URL: http://llvm.org/viewvc/llvm-project?rev=277150&view=rev
Log:
[ELF] - Linkerscript: make addSection() global function instead lambda. 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=277150&r1=277149&r2=277150&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Jul 29 10:12:48 2016
@@ -117,22 +117,25 @@ LinkerScript<ELFT>::getInputSections(con
return Ret;
}
+// Add input section to output section. If there is no output section yet,
+// then create it and add to output section list.
+template <class ELFT>
+static void addSection(OutputSectionFactory<ELFT> &Factory,
+ std::vector<OutputSectionBase<ELFT> *> &Out,
+ InputSectionBase<ELFT> *C, StringRef Name) {
+ OutputSectionBase<ELFT> *Sec;
+ bool IsNew;
+ std::tie(Sec, IsNew) = Factory.create(C, Name);
+ if (IsNew)
+ Out.push_back(Sec);
+ Sec->addSection(C);
+}
+
template <class ELFT>
std::vector<OutputSectionBase<ELFT> *>
LinkerScript<ELFT>::createSections(OutputSectionFactory<ELFT> &Factory) {
std::vector<OutputSectionBase<ELFT> *> Ret;
- // Add input section to output section. If there is no output section yet,
- // then create it and add to output section list.
- auto Add = [&](InputSectionBase<ELFT> *C, StringRef Name) {
- OutputSectionBase<ELFT> *Sec;
- bool IsNew;
- std::tie(Sec, IsNew) = Factory.create(C, Name);
- if (IsNew)
- Ret.push_back(Sec);
- Sec->addSection(C);
- };
-
for (auto &P : getSectionMap()) {
StringRef OutputName = P.first;
const InputSectionDescription *I = P.second;
@@ -142,7 +145,7 @@ LinkerScript<ELFT>::createSections(Outpu
reportDiscarded(S);
continue;
}
- Add(S, OutputName);
+ addSection(Factory, Ret, S, OutputName);
}
}
@@ -151,7 +154,7 @@ LinkerScript<ELFT>::createSections(Outpu
Symtab<ELFT>::X->getObjectFiles())
for (InputSectionBase<ELFT> *S : F->getSections())
if (!isDiscarded(S) && !S->OutSec)
- Add(S, getOutputSectionName(S));
+ addSection(Factory, Ret, S, getOutputSectionName(S));
// Remove from the output all the sections which did not meet
// the optional constraints.
More information about the llvm-commits
mailing list