[PATCH] D93856: [LLD][ELF] - Use LLVM_ELF_IMPORT_TYPES_ELFT macro instead of multiple types definitions. NFCI.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 28 02:22:50 PST 2020


grimar created this revision.
grimar added reviewers: MaskRay, psmith.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
grimar requested review of this revision.

We can reduce the number of "using" declarations.
`LLVM_ELF_IMPORT_TYPES_ELFT` was extended in D93801 <https://reviews.llvm.org/D93801>.


https://reviews.llvm.org/D93856

Files:
  lld/ELF/InputFiles.cpp
  lld/ELF/InputFiles.h
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp


Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -45,10 +45,9 @@
 // The writer writes a SymbolTable result to a file.
 template <class ELFT> class Writer {
 public:
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
+
   Writer() : buffer(errorHandler().outputBuffer) {}
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Ehdr = typename ELFT::Ehdr;
-  using Elf_Phdr = typename ELFT::Phdr;
 
   void run();
 
Index: lld/ELF/SyntheticSections.h
===================================================================
--- lld/ELF/SyntheticSections.h
+++ lld/ELF/SyntheticSections.h
@@ -461,12 +461,7 @@
 };
 
 template <class ELFT> class DynamicSection final : public SyntheticSection {
-  using Elf_Dyn = typename ELFT::Dyn;
-  using Elf_Rel = typename ELFT::Rel;
-  using Elf_Rela = typename ELFT::Rela;
-  using Elf_Relr = typename ELFT::Relr;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Sym = typename ELFT::Sym;
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
 
   // finalizeContents() fills this vector with the section contents.
   std::vector<std::pair<int32_t, std::function<uint64_t()>>> entries;
Index: lld/ELF/InputFiles.h
===================================================================
--- lld/ELF/InputFiles.h
+++ lld/ELF/InputFiles.h
@@ -189,12 +189,7 @@
 
 // .o file.
 template <class ELFT> class ObjFile : public ELFFileBase {
-  using Elf_Rel = typename ELFT::Rel;
-  using Elf_Rela = typename ELFT::Rela;
-  using Elf_Sym = typename ELFT::Sym;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Word = typename ELFT::Word;
-  using Elf_CGProfile = typename ELFT::CGProfile;
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
 
 public:
   static bool classof(const InputFile *f) { return f->kind() == ObjKind; }
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -1428,11 +1428,7 @@
 // than necessary, but you can easily understand the code if you wrap your
 // head around the data structure described above.
 template <class ELFT> void SharedFile::parse() {
-  using Elf_Dyn = typename ELFT::Dyn;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Sym = typename ELFT::Sym;
-  using Elf_Verdef = typename ELFT::Verdef;
-  using Elf_Versym = typename ELFT::Versym;
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
 
   ArrayRef<Elf_Dyn> dynamicTags;
   const ELFFile<ELFT> obj = this->getObj<ELFT>();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93856.313840.patch
Type: text/x-patch
Size: 2486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201228/42dc5ca1/attachment.bin>


More information about the llvm-commits mailing list