[lld] r233316 - Remove duplicate code and empty classes.

Rui Ueyama ruiu at google.com
Thu Mar 26 14:01:14 PDT 2015


Author: ruiu
Date: Thu Mar 26 16:01:13 2015
New Revision: 233316

URL: http://llvm.org/viewvc/llvm-project?rev=233316&view=rev
Log:
Remove duplicate code and empty classes.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h Thu Mar 26 16:01:13 2015
@@ -29,12 +29,6 @@ public:
   }
 };
 
-template <class ELFT> class AArch64DynamicFile : public DynamicFile<ELFT> {
-public:
-  AArch64DynamicFile(const AArch64LinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h Thu Mar 26 16:01:13 2015
@@ -18,16 +18,6 @@ namespace elf {
 
 typedef llvm::object::ELFType<llvm::support::little, 2, true> AArch64ELFType;
 
-struct AArch64DynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            AArch64LinkingContext &ctx) {
-    return lld::elf::AArch64DynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 struct AArch64ELFFileCreateELFTraits {
   typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
 
@@ -48,11 +38,10 @@ public:
 };
 
 class AArch64ELFDSOReader
-    : public ELFDSOReader<AArch64ELFType, AArch64DynamicFileCreateELFTraits,
-                          AArch64LinkingContext> {
+    : public ELFDSOReader<AArch64ELFType, AArch64LinkingContext> {
 public:
   AArch64ELFDSOReader(AArch64LinkingContext &ctx)
-      : ELFDSOReader<AArch64ELFType, AArch64DynamicFileCreateELFTraits,
+      : ELFDSOReader<AArch64ELFType,
                      AArch64LinkingContext>(ctx, llvm::ELF::EM_AARCH64) {}
 };
 

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h Thu Mar 26 16:01:13 2015
@@ -121,12 +121,6 @@ private:
   }
 };
 
-template <class ELFT> class ARMDynamicFile : public DynamicFile<ELFT> {
-public:
-  ARMDynamicFile(const ARMLinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h Thu Mar 26 16:01:13 2015
@@ -18,16 +18,6 @@ namespace elf {
 
 typedef llvm::object::ELFType<llvm::support::little, 2, false> ARMELFType;
 
-struct ARMDynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            ARMLinkingContext &ctx) {
-    return lld::elf::ARMDynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 struct ARMELFFileCreateELFTraits {
   typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
 
@@ -48,12 +38,10 @@ public:
 };
 
 class ARMELFDSOReader
-    : public ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits,
-                          ARMLinkingContext> {
+    : public ELFDSOReader<ARMELFType, ARMLinkingContext> {
 public:
   ARMELFDSOReader(ARMLinkingContext &ctx)
-      : ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits,
-                     ARMLinkingContext>(ctx, llvm::ELF::EM_ARM) {}
+      : ELFDSOReader<ARMELFType, ARMLinkingContext>(ctx, llvm::ELF::EM_ARM) {}
 };
 
 } // namespace elf

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFReader.h Thu Mar 26 16:01:13 2015
@@ -57,7 +57,17 @@ protected:
   uint64_t _machine;
 };
 
-template <typename ELFT, typename ELFTraitsT, typename ContextT>
+struct DynamicFileCreateELFTraits {
+  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
+
+  template<typename ELFT, typename ContextT>
+  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
+                            ContextT &ctx) {
+    return DynamicFile<ELFT>::create(std::move(mb), ctx);
+  }
+};
+
+template <typename ELFT, typename ContextT>
 class ELFDSOReader : public Reader {
 public:
   typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
@@ -76,9 +86,9 @@ public:
            std::vector<std::unique_ptr<File>> &result) const override {
     std::size_t maxAlignment =
         1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
-    auto f =
-        createELF<ELFTraitsT>(llvm::object::getElfArchType(mb->getBuffer()),
-                              maxAlignment, std::move(mb), _ctx);
+    auto f = createELF<DynamicFileCreateELFTraits>(
+        llvm::object::getElfArchType(mb->getBuffer()),
+        maxAlignment, std::move(mb), _ctx);
     if (std::error_code ec = f.getError())
       return ec;
     result.push_back(std::move(*f));

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h Thu Mar 26 16:01:13 2015
@@ -153,12 +153,6 @@ public:
   }
 };
 
-template <class ELFT> class HexagonDynamicFile : public DynamicFile<ELFT> {
-public:
-  HexagonDynamicFile(const HexagonLinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h Thu Mar 26 16:01:13 2015
@@ -18,16 +18,6 @@ namespace elf {
 
 typedef llvm::object::ELFType<llvm::support::little, 2, false> HexagonELFType;
 
-struct HexagonDynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            HexagonLinkingContext &ctx) {
-    return lld::elf::HexagonDynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 struct HexagonELFFileCreateELFTraits {
   typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
 
@@ -48,11 +38,10 @@ public:
 };
 
 class HexagonELFDSOReader
-    : public ELFDSOReader<HexagonELFType, HexagonDynamicFileCreateELFTraits,
-                          HexagonLinkingContext> {
+    : public ELFDSOReader<HexagonELFType, HexagonLinkingContext> {
 public:
   HexagonELFDSOReader(HexagonLinkingContext &ctx)
-      : ELFDSOReader<HexagonELFType, HexagonDynamicFileCreateELFTraits,
+      : ELFDSOReader<HexagonELFType,
                      HexagonLinkingContext>(ctx, llvm::ELF::EM_HEXAGON) {}
 };
 

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Thu Mar 26 16:01:13 2015
@@ -323,12 +323,6 @@ private:
   }
 };
 
-template <class ELFT> class MipsDynamicFile : public DynamicFile<ELFT> {
-public:
-  MipsDynamicFile(const MipsLinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h Thu Mar 26 16:01:13 2015
@@ -27,16 +27,6 @@ struct MipsELFFileCreateTraits {
   }
 };
 
-struct MipsDynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            MipsLinkingContext &ctx) {
-    return lld::elf::MipsDynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 template <class ELFT>
 class MipsELFObjectReader
     : public ELFObjectReader<ELFT, MipsELFFileCreateTraits,
@@ -63,11 +53,8 @@ private:
 };
 
 template <class ELFT>
-class MipsELFDSOReader
-    : public ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits,
-                          MipsLinkingContext> {
-  typedef ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits, MipsLinkingContext>
-      BaseReaderType;
+class MipsELFDSOReader : public ELFDSOReader<ELFT, MipsLinkingContext> {
+  typedef ELFDSOReader<ELFT, MipsLinkingContext> BaseReaderType;
 
 public:
   MipsELFDSOReader(MipsLinkingContext &ctx)

Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h Thu Mar 26 16:01:13 2015
@@ -29,12 +29,6 @@ public:
   }
 };
 
-template <class ELFT> class X86DynamicFile : public DynamicFile<ELFT> {
-public:
-  X86DynamicFile(const X86LinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h Thu Mar 26 16:01:13 2015
@@ -18,16 +18,6 @@ namespace elf {
 
 typedef llvm::object::ELFType<llvm::support::little, 2, false> X86ELFType;
 
-struct X86DynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            X86LinkingContext &ctx) {
-    return lld::elf::X86DynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 struct X86ELFFileCreateELFTraits {
   typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
 
@@ -48,11 +38,10 @@ public:
 };
 
 class X86ELFDSOReader
-    : public ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits,
-                          X86LinkingContext> {
+    : public ELFDSOReader<X86ELFType, X86LinkingContext> {
 public:
   X86ELFDSOReader(X86LinkingContext &ctx)
-      : ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits,
+      : ELFDSOReader<X86ELFType,
                      X86LinkingContext>(ctx, llvm::ELF::EM_386) {}
 };
 

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h Thu Mar 26 16:01:13 2015
@@ -29,12 +29,6 @@ public:
   }
 };
 
-template <class ELFT> class X86_64DynamicFile : public DynamicFile<ELFT> {
-public:
-  X86_64DynamicFile(const X86_64LinkingContext &context, StringRef name)
-      : DynamicFile<ELFT>(context, name) {}
-};
-
 } // elf
 } // lld
 

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h?rev=233316&r1=233315&r2=233316&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h Thu Mar 26 16:01:13 2015
@@ -18,16 +18,6 @@ namespace elf {
 
 typedef llvm::object::ELFType<llvm::support::little, 2, true> X86_64ELFType;
 
-struct X86_64DynamicFileCreateELFTraits {
-  typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
-  template <class ELFT>
-  static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
-                            X86_64LinkingContext &ctx) {
-    return lld::elf::X86_64DynamicFile<ELFT>::create(std::move(mb), ctx);
-  }
-};
-
 struct X86_64ELFFileCreateELFTraits {
   typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
 
@@ -48,11 +38,10 @@ public:
 };
 
 class X86_64ELFDSOReader
-    : public ELFDSOReader<X86_64ELFType, X86_64DynamicFileCreateELFTraits,
-                          X86_64LinkingContext> {
+    : public ELFDSOReader<X86_64ELFType, X86_64LinkingContext> {
 public:
   X86_64ELFDSOReader(X86_64LinkingContext &ctx)
-      : ELFDSOReader<X86_64ELFType, X86_64DynamicFileCreateELFTraits,
+      : ELFDSOReader<X86_64ELFType,
                      X86_64LinkingContext>(ctx, llvm::ELF::EM_X86_64) {}
 };
 





More information about the llvm-commits mailing list