[PATCH] D13153: [ELF2] Use static non-member function when it suffices

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 19:20:19 PDT 2015


davide created this revision.
davide added a reviewer: ruiu.
davide added a subscriber: llvm-commits.
davide set the repository for this revision to rL LLVM.

Try to address Rui's comment on my previous commit.

Repository:
  rL LLVM

http://reviews.llvm.org/D13153

Files:
  ELF/OutputSections.cpp
  ELF/OutputSections.h
  ELF/Writer.cpp

Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -336,7 +336,7 @@
       Elf_Sym_Range Syms = File.getLocalSymbols();
       for (const Elf_Sym &Sym : Syms) {
         ErrorOr<StringRef> SymName = Sym.getName(File.getStringTable());
-        if (SymName && SymTabSec.shouldKeepInSymtab(*SymName))
+        if (SymName && shouldKeepInSymtab(*SymName))
           SymTabSec.addSymbol(*SymName, true);
       }
     }
Index: ELF/OutputSections.h
===================================================================
--- ELF/OutputSections.h
+++ ELF/OutputSections.h
@@ -15,6 +15,8 @@
 #include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Object/ELF.h"
 
+#include "Config.h"
+
 #include <type_traits>
 
 namespace lld {
@@ -41,6 +43,14 @@
 bool includeInSymtab(const SymbolBody &B);
 bool includeInDynamicSymtab(const SymbolBody &B);
 
+static bool shouldKeepInSymtab(StringRef SymName) {
+  if (Config->DiscardNone)
+    return true;
+
+  // ELF defines dynamic locals as symbols which name starts with ".L".
+  return !(Config->DiscardLocals && SymName.startswith(".L"));
+}
+
 // This represents a section in an output file.
 // Different sub classes represent different types of sections. Some contain
 // input sections, others are created by the linker.
@@ -186,8 +196,6 @@
       ++NumLocals;
   }
 
-  bool shouldKeepInSymtab(StringRef Name);
-
   StringTableSection<ELFT::Is64Bits> &getStrTabSec() const { return StrTabSec; }
   unsigned getNumSymbols() const { return NumVisible + 1; }
 
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -272,15 +272,6 @@
   return true;
 }
 
-template <class ELFT>
-bool SymbolTableSection<ELFT>::shouldKeepInSymtab(StringRef SymName) {
-  if (Config->DiscardNone)
-    return true;
-
-  // ELF defines dynamic locals as symbols which name starts with ".L".
-  return !(Config->DiscardLocals && SymName.startswith(".L"));
-}
-
 bool lld::elf2::includeInDynamicSymtab(const SymbolBody &B) {
   if (Config->ExportDynamic || Config->Shared)
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13153.35694.patch
Type: text/x-patch
Size: 2186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150925/4416b000/attachment.bin>


More information about the llvm-commits mailing list