[lld] r248287 - Expose ELFFileBase::getEMachine. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 09:53:56 PDT 2015


Author: rafael
Date: Tue Sep 22 11:53:55 2015
New Revision: 248287

URL: http://llvm.org/viewvc/llvm-project?rev=248287&view=rev
Log:
Expose ELFFileBase::getEMachine. NFC.

I will use it in a followup patch.

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

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=248287&r1=248286&r2=248287&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Sep 22 11:53:55 2015
@@ -27,24 +27,23 @@ template <class ELFT> static uint16_t ge
   return cast<ObjectFile<ELFT>>(B).getEMachine();
 }
 
-static uint16_t getEMachine(const ELFFileBase &B) {
-  ELFKind K = B.getELFKind();
-  switch (K) {
+uint16_t ELFFileBase::getEMachine() const {
+  switch (EKind) {
   case ELF32BEKind:
-    return getEMachine<ELF32BE>(B);
+    return ::getEMachine<ELF32BE>(*this);
   case ELF32LEKind:
-    return getEMachine<ELF32LE>(B);
+    return ::getEMachine<ELF32LE>(*this);
   case ELF64BEKind:
-    return getEMachine<ELF64BE>(B);
+    return ::getEMachine<ELF64BE>(*this);
   case ELF64LEKind:
-    return getEMachine<ELF64LE>(B);
+    return ::getEMachine<ELF64LE>(*this);
   }
   llvm_unreachable("Invalid kind");
 }
 
 bool ELFFileBase::isCompatibleWith(const ELFFileBase &Other) const {
   return getELFKind() == Other.getELFKind() &&
-         getEMachine(*this) == getEMachine(Other);
+         getEMachine() == Other.getEMachine();
 }
 
 template <class ELFT> void ELFData<ELFT>::openELF(MemoryBufferRef MB) {

Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=248287&r1=248286&r2=248287&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Tue Sep 22 11:53:55 2015
@@ -62,6 +62,8 @@ public:
   bool isCompatibleWith(const ELFFileBase &Other) const;
   ELFKind getELFKind() const { return EKind; }
 
+  uint16_t getEMachine() const;
+
 protected:
   const ELFKind EKind;
 };
@@ -122,6 +124,7 @@ class ObjectFile : public ObjectFileBase
   typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word;
 
 public:
+  using ELFData<ELFT>::getEMachine;
 
   static bool classof(const InputFile *F) {
     return F->kind() == ObjectKind &&
@@ -194,6 +197,7 @@ class SharedFile : public SharedFileBase
   std::vector<SharedSymbol<ELFT>> SymbolBodies;
 
 public:
+  using ELFData<ELFT>::getEMachine;
   llvm::MutableArrayRef<SharedSymbol<ELFT>> getSharedSymbols() {
     return SymbolBodies;
   }




More information about the llvm-commits mailing list