Make CommonInputSection singleton class.
All other singleton instances are accessible globally.
CommonInputSection shouldn't be an exception.
Differential Revision: https://reviews.llvm.org/D22935
llvm-svn: 277034
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 36c8689..8642153 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -95,8 +95,7 @@
// Returns input sections filtered by given glob patterns.
template <class ELFT>
std::vector<InputSectionBase<ELFT> *>
-LinkerScript<ELFT>::getInputSections(const InputSectionDescription *I,
- CommonInputSection<ELFT> *Common) {
+LinkerScript<ELFT>::getInputSections(const InputSectionDescription *I) {
ArrayRef<StringRef> Patterns = I->Patterns;
ArrayRef<StringRef> ExcludedFiles = I->ExcludedFiles;
std::vector<InputSectionBase<ELFT> *> Ret;
@@ -109,15 +108,14 @@
Ret.push_back(S);
if ((llvm::find(Patterns, "COMMON") != Patterns.end()))
- Ret.push_back(Common);
+ Ret.push_back(CommonInputSection<ELFT>::X);
return Ret;
}
template <class ELFT>
std::vector<OutputSectionBase<ELFT> *>
-LinkerScript<ELFT>::createSections(OutputSectionFactory<ELFT> &Factory,
- CommonInputSection<ELFT> *Common) {
+LinkerScript<ELFT>::createSections(OutputSectionFactory<ELFT> &Factory) {
std::vector<OutputSectionBase<ELFT> *> Ret;
// Add input section to output section. If there is no output section yet,
@@ -134,7 +132,7 @@
for (auto &P : getSectionMap()) {
StringRef OutputName = P.first;
const InputSectionDescription *I = P.second;
- for (InputSectionBase<ELFT> *S : getInputSections(I, Common)) {
+ for (InputSectionBase<ELFT> *S : getInputSections(I)) {
if (OutputName == "/DISCARD/") {
S->Live = false;
reportDiscarded(S);