[lld] r309376 - [ELF] - Cleanup MapFile.cpp. NFC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 04:13:21 PDT 2017


Author: grimar
Date: Fri Jul 28 04:13:21 2017
New Revision: 309376

URL: http://llvm.org/viewvc/llvm-project?rev=309376&view=rev
Log:
[ELF] - Cleanup MapFile.cpp. NFC.

* Removed redundant templating.
* Added missing `static` keyword.

Modified:
    lld/trunk/ELF/MapFile.cpp

Modified: lld/trunk/ELF/MapFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=309376&r1=309375&r2=309376&view=diff
==============================================================================
--- lld/trunk/ELF/MapFile.cpp (original)
+++ lld/trunk/ELF/MapFile.cpp Fri Jul 28 04:13:21 2017
@@ -39,17 +39,16 @@ typedef DenseMap<const SectionBase *, Sm
     SymbolMapTy;
 
 // Print out the first three columns of a line.
-template <class ELFT>
 static void writeHeader(raw_ostream &OS, uint64_t Addr, uint64_t Size,
                         uint64_t Align) {
-  int W = ELFT::Is64Bits ? 16 : 8;
+  int W = Config->Is64 ? 16 : 8;
   OS << format("%0*llx %0*llx %5lld ", W, Addr, W, Size, Align);
 }
 
 static std::string indent(int Depth) { return std::string(Depth * 8, ' '); }
 
 // Returns a list of all symbols that we want to print out.
-template <class ELFT> std::vector<DefinedRegular *> getSymbols() {
+template <class ELFT> static std::vector<DefinedRegular *> getSymbols() {
   std::vector<DefinedRegular *> V;
   for (ObjFile<ELFT> *File : ObjFile<ELFT>::Instances)
     for (SymbolBody *B : File->getSymbols())
@@ -61,8 +60,7 @@ template <class ELFT> std::vector<Define
 }
 
 // Returns a map from sections to their symbols.
-template <class ELFT>
-SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> Syms) {
+static SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> Syms) {
   SymbolMapTy Ret;
   for (DefinedRegular *S : Syms)
     Ret[S->Section].push_back(S);
@@ -83,13 +81,12 @@ SymbolMapTy getSectionSyms(ArrayRef<Defi
 // Demangling symbols (which is what toString() does) is slow, so
 // we do that in batch using parallel-for.
 template <class ELFT>
-DenseMap<DefinedRegular *, std::string>
+static DenseMap<DefinedRegular *, std::string>
 getSymbolStrings(ArrayRef<DefinedRegular *> Syms) {
   std::vector<std::string> Str(Syms.size());
   parallelForEachN(0, Syms.size(), [&](size_t I) {
     raw_string_ostream OS(Str[I]);
-    writeHeader<ELFT>(OS, Syms[I]->getVA(), Syms[I]->template getSize<ELFT>(),
-                      0);
+    writeHeader(OS, Syms[I]->getVA(), Syms[I]->template getSize<ELFT>(), 0);
     OS << indent(2) << toString(*Syms[I]);
   });
 
@@ -113,7 +110,7 @@ template <class ELFT> void elf::writeMap
 
   // Collect symbol info that we want to print out.
   std::vector<DefinedRegular *> Syms = getSymbols<ELFT>();
-  SymbolMapTy SectionSyms = getSectionSyms<ELFT>(Syms);
+  SymbolMapTy SectionSyms = getSectionSyms(Syms);
   DenseMap<DefinedRegular *, std::string> SymStr = getSymbolStrings<ELFT>(Syms);
 
   // Print out the header line.
@@ -123,7 +120,7 @@ template <class ELFT> void elf::writeMap
 
   // Print out file contents.
   for (OutputSection *OSec : OutputSections) {
-    writeHeader<ELFT>(OS, OSec->Addr, OSec->Size, OSec->Alignment);
+    writeHeader(OS, OSec->Addr, OSec->Size, OSec->Alignment);
     OS << OSec->Name << '\n';
 
     // Dump symbols for each input section.
@@ -132,8 +129,8 @@ template <class ELFT> void elf::writeMap
       if (!ISD)
         continue;
       for (InputSection *IS : ISD->Sections) {
-        writeHeader<ELFT>(OS, OSec->Addr + IS->OutSecOff, IS->getSize(),
-                          IS->Alignment);
+        writeHeader(OS, OSec->Addr + IS->OutSecOff, IS->getSize(),
+                    IS->Alignment);
         OS << indent(1) << toString(IS) << '\n';
         for (DefinedRegular *Sym : SectionSyms[IS])
           OS << SymStr[Sym] << '\n';




More information about the llvm-commits mailing list