From 40849419e2cb8379b178912bf26fa2e70a39341f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 24 Feb 2017 14:28:00 +0000 Subject: [PATCH] Delete trivial getter. llvm-svn: 296123 --- lld/ELF/LinkerScript.cpp | 10 +++++----- lld/ELF/MapFile.cpp | 3 +-- lld/ELF/OutputSections.h | 1 - lld/ELF/Writer.cpp | 33 ++++++++++++++++----------------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 5f9b71e22da1..700be0f5f848 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -515,7 +515,7 @@ template static OutputSectionBase * findSection(StringRef Name, const std::vector &Sections) { auto End = Sections.end(); - auto HasName = [=](OutputSectionBase *Sec) { return Sec->getName() == Name; }; + auto HasName = [=](OutputSectionBase *Sec) { return Sec->Name == Name; }; auto I = std::find_if(Sections.begin(), End, HasName); std::vector Ret; if (I == End) @@ -752,7 +752,7 @@ template void LinkerScript::placeOrphanSections() { } for (OutputSectionBase *Sec : *OutputSections) { - StringRef Name = Sec->getName(); + StringRef Name = Sec->Name; // Find the last spot where we can insert a command and still get the // correct result. @@ -851,7 +851,7 @@ template std::vector LinkerScript::createPhdrs() { break; // Assign headers specified by linker script - for (size_t Id : getPhdrIndices(Sec->getName())) { + for (size_t Id : getPhdrIndices(Sec->Name)) { Ret[Id].add(Sec); if (Opt.PhdrsCommands[Id].Flags == UINT_MAX) Ret[Id].p_flags |= Sec->getPhdrFlags(); @@ -941,7 +941,7 @@ const OutputSectionBase *LinkerScript::getOutputSection(const Twine &Loc, static OutputSectionBase FakeSec("", 0, 0); for (OutputSectionBase *Sec : *OutputSections) - if (Sec->getName() == Name) + if (Sec->Name == Name) return Sec; error(Loc + ": undefined section " + Name); @@ -957,7 +957,7 @@ const OutputSectionBase *LinkerScript::getOutputSection(const Twine &Loc, template uint64_t LinkerScript::getOutputSectionSize(StringRef Name) { for (OutputSectionBase *Sec : *OutputSections) - if (Sec->getName() == Name) + if (Sec->Name == Name) return Sec->Size; return 0; } diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index 4e28fabfa041..9fb58d95cc82 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/ELF/MapFile.cpp @@ -102,8 +102,7 @@ static void writeMapFile2(raw_fd_ostream &OS, << " Align Out In File Symbol\n"; for (OutputSectionBase *Sec : OutputSections) { - writeOutSecLine(OS, Width, Sec->Addr, Sec->Size, Sec->Addralign, - Sec->getName()); + writeOutSecLine(OS, Width, Sec->Addr, Sec->Size, Sec->Addralign, Sec->Name); OS << '\n'; StringRef PrevName = ""; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 142309bf9ae0..9e7973a54b1c 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -49,7 +49,6 @@ public: void setLMAOffset(uint64_t LMAOff) { LMAOffset = LMAOff; } uint64_t getLMA() const { return Addr + LMAOffset; } template void writeHeaderTo(typename ELFT::Shdr *SHdr); - StringRef getName() const { return Name; } virtual void addSection(InputSectionBase *C) {} virtual Kind getKind() const { return Base; } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 910277528422..1fc7e389826f 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -568,7 +568,7 @@ static int getPPC64SectionRank(StringRef SectionName) { static int getMipsSectionRank(const OutputSectionBase *S) { if ((S->Flags & SHF_MIPS_GPREL) == 0) return 0; - if (S->getName() == ".got") + if (S->Name == ".got") return 1; return 2; } @@ -603,7 +603,7 @@ template bool elf::isRelroSection(const OutputSectionBase *Sec) { if (Sec == Out::BssRelRo) return true; - StringRef S = Sec->getName(); + StringRef S = Sec->Name; return S == ".data.rel.ro" || S == ".ctors" || S == ".dtors" || S == ".jcr" || S == ".eh_frame" || S == ".openbsd.randomdata"; } @@ -613,8 +613,8 @@ static bool compareSectionsNonScript(const OutputSectionBase *A, const OutputSectionBase *B) { // Put .interp first because some loaders want to see that section // on the first page of the executable file when loaded into memory. - bool AIsInterp = A->getName() == ".interp"; - bool BIsInterp = B->getName() == ".interp"; + bool AIsInterp = A->Name == ".interp"; + bool BIsInterp = B->Name == ".interp"; if (AIsInterp != BIsInterp) return AIsInterp; @@ -632,8 +632,8 @@ static bool compareSectionsNonScript(const OutputSectionBase *A, // We want to put section specified by -T option first, so we // can start assigning VA starting from them later. - auto AAddrSetI = Config->SectionStartMap.find(A->getName()); - auto BAddrSetI = Config->SectionStartMap.find(B->getName()); + auto AAddrSetI = Config->SectionStartMap.find(A->Name); + auto BAddrSetI = Config->SectionStartMap.find(B->Name); bool AHasAddrSet = AAddrSetI != Config->SectionStartMap.end(); bool BHasAddrSet = BAddrSetI != Config->SectionStartMap.end(); if (AHasAddrSet != BHasAddrSet) @@ -698,8 +698,7 @@ static bool compareSectionsNonScript(const OutputSectionBase *A, // Some architectures have additional ordering restrictions for sections // within the same PT_LOAD. if (Config->EMachine == EM_PPC64) - return getPPC64SectionRank(A->getName()) < - getPPC64SectionRank(B->getName()); + return getPPC64SectionRank(A->Name) < getPPC64SectionRank(B->Name); if (Config->EMachine == EM_MIPS) return getMipsSectionRank(A) < getMipsSectionRank(B); @@ -711,8 +710,8 @@ template static bool compareSections(const OutputSectionBase *A, const OutputSectionBase *B) { // For now, put sections mentioned in a linker script first. - int AIndex = Script::X->getSectionIndex(A->getName()); - int BIndex = Script::X->getSectionIndex(B->getName()); + int AIndex = Script::X->getSectionIndex(A->Name); + int BIndex = Script::X->getSectionIndex(B->Name); bool AInScript = AIndex != INT_MAX; bool BInScript = BIndex != INT_MAX; if (AInScript != BInScript) @@ -997,7 +996,7 @@ template void Writer::sortSections() { auto E = OutputSections.end(); auto NonScriptI = std::find_if(OutputSections.begin(), E, [](OutputSectionBase *S) { - return Script::X->getSectionIndex(S->getName()) == INT_MAX; + return Script::X->getSectionIndex(S->Name) == INT_MAX; }); while (NonScriptI != E) { auto BestPos = std::max_element( @@ -1143,7 +1142,7 @@ template void Writer::finalizeSections() { unsigned I = 1; for (OutputSectionBase *Sec : OutputSections) { Sec->SectionIndex = I++; - Sec->ShName = In::ShStrTab->addString(Sec->getName()); + Sec->ShName = In::ShStrTab->addString(Sec->Name); } // Binary and relocatable output does not have PHDRS. @@ -1225,7 +1224,7 @@ template void Writer::addStartEndSymbols() { // gold provide the feature, and used by many programs. template void Writer::addStartStopSymbols(OutputSectionBase *Sec) { - StringRef S = Sec->getName(); + StringRef S = Sec->Name; if (!isValidCIdentifier(S)) return; addOptionalSynthetic(Saver.save("__start_" + S), Sec, 0, STV_DEFAULT); @@ -1235,7 +1234,7 @@ void Writer::addStartStopSymbols(OutputSectionBase *Sec) { template OutputSectionBase *Writer::findSection(StringRef Name) { for (OutputSectionBase *Sec : OutputSections) - if (Sec->getName() == Name) + if (Sec->Name == Name) return Sec; return nullptr; } @@ -1296,7 +1295,7 @@ template std::vector Writer::createPhdrs() { // different flags or is loaded at a discontiguous address using AT linker // script command. uintX_t NewFlags = computeFlags(Sec->getPhdrFlags()); - if (Script::X->hasLMA(Sec->getName()) || Flags != NewFlags) { + if (Script::X->hasLMA(Sec->Name) || Flags != NewFlags) { Load = AddHdr(PT_LOAD, NewFlags); Flags = NewFlags; } @@ -1359,7 +1358,7 @@ template std::vector Writer::createPhdrs() { PhdrEntry *Note = nullptr; for (OutputSectionBase *Sec : OutputSections) { if (Sec->Type == SHT_NOTE) { - if (!Note || Script::X->hasLMA(Sec->getName())) + if (!Note || Script::X->hasLMA(Sec->Name)) Note = AddHdr(PT_NOTE, PF_R); Note->add(Sec); } else { @@ -1480,7 +1479,7 @@ template void Writer::assignAddresses() { if (Sec->PageAlign) Alignment = std::max(Alignment, Config->MaxPageSize); - auto I = Config->SectionStartMap.find(Sec->getName()); + auto I = Config->SectionStartMap.find(Sec->Name); if (I != Config->SectionStartMap.end()) VA = I->second;