[lld] r289064 - Add two helper functions. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 07:56:34 PST 2016


Author: rafael
Date: Thu Dec  8 09:56:33 2016
New Revision: 289064

URL: http://llvm.org/viewvc/llvm-project?rev=289064&view=rev
Log:
Add two helper functions. NFC.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/SymbolTable.h

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=289064&r1=289063&r2=289064&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Dec  8 09:56:33 2016
@@ -594,6 +594,15 @@ ArrayRef<SymbolBody *> SymbolTable<ELFT>
 }
 
 template <class ELFT>
+std::vector<SymbolBody *> SymbolTable<ELFT>::find(SymbolVersion Ver) {
+  if (Ver.IsExternCpp)
+    return findDemangled(Ver.Name);
+  std::vector<SymbolBody *> Syms;
+  Syms.push_back(find(Ver.Name));
+  return Syms;
+}
+
+template <class ELFT>
 std::vector<SymbolBody *>
 SymbolTable<ELFT>::findAllDemangled(StringRef GlobPat) {
   initDemangledSyms();
@@ -607,6 +616,11 @@ SymbolTable<ELFT>::findAllDemangled(Stri
   return Res;
 }
 
+template <class ELFT>
+std::vector<SymbolBody *> SymbolTable<ELFT>::findAll(SymbolVersion Ver) {
+  return Ver.IsExternCpp ? findAllDemangled(Ver.Name) : findAll(Ver.Name);
+}
+
 // If there's only one anonymous version definition in a version
 // script file, the script does not actually define any symbol version,
 // but just specifies symbols visibilities. We assume that the script was
@@ -633,11 +647,7 @@ void SymbolTable<ELFT>::assignExactVersi
     return;
 
   // Get a list of symbols which we need to assign the version to.
-  std::vector<SymbolBody *> Syms;
-  if (Ver.IsExternCpp)
-    Syms = findDemangled(Ver.Name);
-  else
-    Syms.push_back(find(Ver.Name));
+  std::vector<SymbolBody *> Syms = find(Ver);
 
   // Assign the version.
   for (SymbolBody *B : Syms) {
@@ -659,8 +669,7 @@ void SymbolTable<ELFT>::assignWildcardVe
                                               uint16_t VersionId) {
   if (!Ver.HasWildcard)
     return;
-  std::vector<SymbolBody *> Syms =
-      Ver.IsExternCpp ? findAllDemangled(Ver.Name) : findAll(Ver.Name);
+  std::vector<SymbolBody *> Syms = findAll(Ver);
 
   // Exact matching takes precendence over fuzzy matching,
   // so we set a version to a symbol only if no version has been assigned

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=289064&r1=289063&r2=289064&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Thu Dec  8 09:56:33 2016
@@ -99,7 +99,9 @@ private:
                                    InputFile *File);
 
   ArrayRef<SymbolBody *> findDemangled(StringRef Name);
+  std::vector<SymbolBody *> find(SymbolVersion Ver);
   std::vector<SymbolBody *> findAllDemangled(StringRef GlobPat);
+  std::vector<SymbolBody *> findAll(SymbolVersion Ver);
 
   void initDemangledSyms();
   void handleAnonymousVersion();




More information about the llvm-commits mailing list