[lld] r255849 - ELF: Make checkCompatibility a non-member function.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 15:31:22 PST 2015
Author: ruiu
Date: Wed Dec 16 17:31:22 2015
New Revision: 255849
URL: http://llvm.org/viewvc/llvm-project?rev=255849&view=rev
Log:
ELF: Make checkCompatibility a non-member function.
Because the function does not use any member of SymbolTable class.
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=255849&r1=255848&r2=255849&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Dec 16 17:31:22 2015
@@ -34,9 +34,23 @@ template <class ELFT> bool SymbolTable<E
}
template <class ELFT>
+static void checkCompatibility(InputFile *FileP) {
+ auto *F = dyn_cast<ELFFileBase<ELFT>>(FileP);
+ if (!F)
+ return;
+ if (F->getELFKind() == Config->EKind && F->getEMachine() == Config->EMachine)
+ return;
+ StringRef A = F->getName();
+ StringRef B = Config->Emulation;
+ if (B.empty())
+ B = Config->FirstElf->getName();
+ error(A + " is incompatible with " + B);
+}
+
+template <class ELFT>
void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
- checkCompatibility(File);
InputFile *FileP = File.release();
+ checkCompatibility<ELFT>(FileP);
// .a file
if (auto *F = dyn_cast<ArchiveFile>(FileP)) {
@@ -209,20 +223,6 @@ template <class ELFT> void SymbolTable<E
}
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->EKind && 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(Undefined<ELFT> *Undef, Lazy *L) {
// Weak undefined symbols should not fetch members from archives.
// If we were to keep old symbol we would not know that an archive member was
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=255849&r1=255848&r2=255849&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Wed Dec 16 17:31:22 2015
@@ -65,7 +65,6 @@ private:
Symbol *insert(SymbolBody *New);
void addLazy(Lazy *New);
void addMemberFile(Undefined<ELFT> *Undef, Lazy *L);
- void checkCompatibility(std::unique_ptr<InputFile> &File);
void resolve(SymbolBody *Body);
std::string conflictMsg(SymbolBody *Old, SymbolBody *New);
More information about the llvm-commits
mailing list