[lld] r250073 - ELF2: Split SymbolTable::addFile(). NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 11:03:21 PDT 2015


Author: ruiu
Date: Mon Oct 12 13:03:21 2015
New Revision: 250073

URL: http://llvm.org/viewvc/llvm-project?rev=250073&view=rev
Log:
ELF2: Split SymbolTable::addFile(). 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=250073&r1=250072&r2=250073&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Mon Oct 12 13:03:21 2015
@@ -28,17 +28,7 @@ template <class ELFT> bool SymbolTable<E
 
 template <class ELFT>
 void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
-
-  if (auto *E = dyn_cast<ELFFileBase<ELFT>>(File.get())) {
-    if (E->getELFKind() != Config->ElfKind ||
-        E->getEMachine() != Config->EMachine) {
-      StringRef A = E->getName();
-      StringRef B = Config->Emulation;
-      if (B.empty())
-        B = Config->FirstElf->getName();
-      error(A + " is incompatible with " + B);
-    }
-  }
+  checkCompatibility(File);
 
   if (auto *AF = dyn_cast<ArchiveFile>(File.get())) {
     ArchiveFiles.emplace_back(std::move(File));
@@ -47,6 +37,7 @@ void SymbolTable<ELFT>::addFile(std::uni
       addLazy(&Sym);
     return;
   }
+
   if (auto *S = dyn_cast<SharedFile<ELFT>>(File.get())) {
     S->parseSoName();
     if (!IncludedSoNames.insert(S->getSoName()).second)
@@ -215,6 +206,21 @@ template <class ELFT> void SymbolTable<E
   addMemberFile(New);
 }
 
+template <class ELFT>
+void SymbolTable<ELFT>::checkCompatibility(std::unique_ptr<InputFile> &File) {
+  auto *E = dyn_cast<ELFFileBase<ELFT>>(File.get());
+  if (!E)
+    return;
+  if (E->getELFKind() == Config->ElfKind &&
+      E->getEMachine() == Config->EMachine)
+    return;
+  StringRef A = E->getName();
+  StringRef B = Config->Emulation;
+  if (B.empty())
+    B = Config->FirstElf->getName();
+  error(A + " is incompatible with " + B);
+}
+
 template <class ELFT> void SymbolTable<ELFT>::addMemberFile(Lazy *Body) {
   std::unique_ptr<InputFile> File = Body->getMember();
 

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=250073&r1=250072&r2=250073&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Mon Oct 12 13:03:21 2015
@@ -58,6 +58,7 @@ private:
   void addELFFile(ELFFileBase<ELFT> *File);
   void addLazy(Lazy *New);
   void addMemberFile(Lazy *Body);
+  void checkCompatibility(std::unique_ptr<InputFile> &File);
   void init(uint16_t EMachine);
   void resolve(SymbolBody *Body);
   void reportConflict(const Twine &Message, const SymbolBody &Old,




More information about the llvm-commits mailing list