[lld] r296123 - Delete trivial getter.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 06:28:01 PST 2017


Author: rafael
Date: Fri Feb 24 08:28:00 2017
New Revision: 296123

URL: http://llvm.org/viewvc/llvm-project?rev=296123&view=rev
Log:
Delete trivial getter.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/MapFile.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296123&r1=296122&r2=296123&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Feb 24 08:28:00 2017
@@ -515,7 +515,7 @@ template <class ELFT>
 static OutputSectionBase *
 findSection(StringRef Name, const std::vector<OutputSectionBase *> &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<OutputSectionBase *> Ret;
   if (I == End)
@@ -752,7 +752,7 @@ template <class ELFT> void LinkerScript<
   }
 
   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 <class ELFT> std::vector<PhdrEn
       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<EL
   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<EL
 template <class ELFT>
 uint64_t LinkerScript<ELFT>::getOutputSectionSize(StringRef Name) {
   for (OutputSectionBase *Sec : *OutputSections)
-    if (Sec->getName() == Name)
+    if (Sec->Name == Name)
       return Sec->Size;
   return 0;
 }

Modified: lld/trunk/ELF/MapFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=296123&r1=296122&r2=296123&view=diff
==============================================================================
--- lld/trunk/ELF/MapFile.cpp (original)
+++ lld/trunk/ELF/MapFile.cpp Fri Feb 24 08:28:00 2017
@@ -102,8 +102,7 @@ static void writeMapFile2(raw_fd_ostream
      << " 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 = "";

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=296123&r1=296122&r2=296123&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Feb 24 08:28:00 2017
@@ -49,7 +49,6 @@ public:
   void setLMAOffset(uint64_t LMAOff) { LMAOffset = LMAOff; }
   uint64_t getLMA() const { return Addr + LMAOffset; }
   template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);
-  StringRef getName() const { return Name; }
 
   virtual void addSection(InputSectionBase *C) {}
   virtual Kind getKind() const { return Base; }

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296123&r1=296122&r2=296123&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Feb 24 08:28:00 2017
@@ -568,7 +568,7 @@ static int getPPC64SectionRank(StringRef
 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 <class ELFT> bool elf::isRelroS
   if (Sec == Out<ELFT>::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(con
                                      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(con
 
   // 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(con
   // 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 <class ELFT>
 static bool compareSections(const OutputSectionBase *A,
                             const OutputSectionBase *B) {
   // For now, put sections mentioned in a linker script first.
-  int AIndex = Script<ELFT>::X->getSectionIndex(A->getName());
-  int BIndex = Script<ELFT>::X->getSectionIndex(B->getName());
+  int AIndex = Script<ELFT>::X->getSectionIndex(A->Name);
+  int BIndex = Script<ELFT>::X->getSectionIndex(B->Name);
   bool AInScript = AIndex != INT_MAX;
   bool BInScript = BIndex != INT_MAX;
   if (AInScript != BInScript)
@@ -997,7 +996,7 @@ template <class ELFT> void Writer<ELFT>:
   auto E = OutputSections.end();
   auto NonScriptI =
       std::find_if(OutputSections.begin(), E, [](OutputSectionBase *S) {
-        return Script<ELFT>::X->getSectionIndex(S->getName()) == INT_MAX;
+        return Script<ELFT>::X->getSectionIndex(S->Name) == INT_MAX;
       });
   while (NonScriptI != E) {
     auto BestPos = std::max_element(
@@ -1143,7 +1142,7 @@ template <class ELFT> void Writer<ELFT>:
   unsigned I = 1;
   for (OutputSectionBase *Sec : OutputSections) {
     Sec->SectionIndex = I++;
-    Sec->ShName = In<ELFT>::ShStrTab->addString(Sec->getName());
+    Sec->ShName = In<ELFT>::ShStrTab->addString(Sec->Name);
   }
 
   // Binary and relocatable output does not have PHDRS.
@@ -1225,7 +1224,7 @@ template <class ELFT> void Writer<ELFT>:
 // gold provide the feature, and used by many programs.
 template <class ELFT>
 void Writer<ELFT>::addStartStopSymbols(OutputSectionBase *Sec) {
-  StringRef S = Sec->getName();
+  StringRef S = Sec->Name;
   if (!isValidCIdentifier(S))
     return;
   addOptionalSynthetic<ELFT>(Saver.save("__start_" + S), Sec, 0, STV_DEFAULT);
@@ -1235,7 +1234,7 @@ void Writer<ELFT>::addStartStopSymbols(O
 template <class ELFT>
 OutputSectionBase *Writer<ELFT>::findSection(StringRef Name) {
   for (OutputSectionBase *Sec : OutputSections)
-    if (Sec->getName() == Name)
+    if (Sec->Name == Name)
       return Sec;
   return nullptr;
 }
@@ -1296,7 +1295,7 @@ template <class ELFT> std::vector<PhdrEn
     // different flags or is loaded at a discontiguous address using AT linker
     // script command.
     uintX_t NewFlags = computeFlags<ELFT>(Sec->getPhdrFlags());
-    if (Script<ELFT>::X->hasLMA(Sec->getName()) || Flags != NewFlags) {
+    if (Script<ELFT>::X->hasLMA(Sec->Name) || Flags != NewFlags) {
       Load = AddHdr(PT_LOAD, NewFlags);
       Flags = NewFlags;
     }
@@ -1359,7 +1358,7 @@ template <class ELFT> std::vector<PhdrEn
   PhdrEntry *Note = nullptr;
   for (OutputSectionBase *Sec : OutputSections) {
     if (Sec->Type == SHT_NOTE) {
-      if (!Note || Script<ELFT>::X->hasLMA(Sec->getName()))
+      if (!Note || Script<ELFT>::X->hasLMA(Sec->Name))
         Note = AddHdr(PT_NOTE, PF_R);
       Note->add(Sec);
     } else {
@@ -1480,7 +1479,7 @@ template <class ELFT> void Writer<ELFT>:
     if (Sec->PageAlign)
       Alignment = std::max<uintX_t>(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;
 




More information about the llvm-commits mailing list