From b2fc05a60b4a5a1a51645087ad76eb79bf47ba55 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 22 Nov 2016 03:38:40 +0000 Subject: [PATCH] Object: Make SymbolicFile::symbol_{begin,end}() virtual and remove unnecessary wrappers. llvm-svn: 287611 --- include/llvm/Object/COFF.h | 4 ++-- include/llvm/Object/COFFImportFile.h | 4 ++-- include/llvm/Object/ELFObjectFile.h | 10 +++++----- include/llvm/Object/IRObjectFile.h | 4 ++-- include/llvm/Object/MachO.h | 4 ++-- include/llvm/Object/ModuleSummaryIndexObjectFile.h | 4 ++-- include/llvm/Object/SymbolicFile.h | 10 ++-------- lib/Object/COFFObjectFile.cpp | 4 ++-- lib/Object/IRObjectFile.cpp | 4 ++-- lib/Object/MachOObjectFile.cpp | 4 ++-- 10 files changed, 23 insertions(+), 29 deletions(-) diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 95e496ed35f..696042d29da 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -746,8 +746,8 @@ protected: public: COFFObjectFile(MemoryBufferRef Object, std::error_code &EC); - basic_symbol_iterator symbol_begin_impl() const override; - basic_symbol_iterator symbol_end_impl() const override; + basic_symbol_iterator symbol_begin() const override; + basic_symbol_iterator symbol_end() const override; section_iterator section_begin() const override; section_iterator section_end() const override; diff --git a/include/llvm/Object/COFFImportFile.h b/include/llvm/Object/COFFImportFile.h index b04a44ea60d..4192fe7e5c9 100644 --- a/include/llvm/Object/COFFImportFile.h +++ b/include/llvm/Object/COFFImportFile.h @@ -47,11 +47,11 @@ public: return SymbolRef::SF_Global; } - basic_symbol_iterator symbol_begin_impl() const override { + basic_symbol_iterator symbol_begin() const override { return BasicSymbolRef(DataRefImpl(), this); } - basic_symbol_iterator symbol_end_impl() const override { + basic_symbol_iterator symbol_end() const override { DataRefImpl Symb; Symb.p = isCode() ? 2 : 1; return BasicSymbolRef(Symb, this); diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index c84881899d8..4209da829e3 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -336,8 +336,8 @@ public: return reinterpret_cast(Sec.p); } - basic_symbol_iterator symbol_begin_impl() const override; - basic_symbol_iterator symbol_end_impl() const override; + basic_symbol_iterator symbol_begin() const override; + basic_symbol_iterator symbol_end() const override; elf_symbol_iterator dynamic_symbol_begin() const; elf_symbol_iterator dynamic_symbol_end() const; @@ -843,16 +843,16 @@ ELFObjectFile::ELFObjectFile(MemoryBufferRef Object, std::error_code &EC) } template -basic_symbol_iterator ELFObjectFile::symbol_begin_impl() const { +basic_symbol_iterator ELFObjectFile::symbol_begin() const { DataRefImpl Sym = toDRI(DotSymtabSec, 0); return basic_symbol_iterator(SymbolRef(Sym, this)); } template -basic_symbol_iterator ELFObjectFile::symbol_end_impl() const { +basic_symbol_iterator ELFObjectFile::symbol_end() const { const Elf_Shdr *SymTab = DotSymtabSec; if (!SymTab) - return symbol_begin_impl(); + return symbol_begin(); DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym)); return basic_symbol_iterator(SymbolRef(Sym, this)); } diff --git a/include/llvm/Object/IRObjectFile.h b/include/llvm/Object/IRObjectFile.h index 4522363f230..8a7790ff3b9 100644 --- a/include/llvm/Object/IRObjectFile.h +++ b/include/llvm/Object/IRObjectFile.h @@ -41,8 +41,8 @@ public: const GlobalValue *getSymbolGV(DataRefImpl Symb) const { return const_cast(this)->getSymbolGV(Symb); } - basic_symbol_iterator symbol_begin_impl() const override; - basic_symbol_iterator symbol_end_impl() const override; + basic_symbol_iterator symbol_begin() const override; + basic_symbol_iterator symbol_end() const override; const Module &getModule() const { return const_cast(this)->getModule(); diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index b0f106f89c0..d74e91a1a1c 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -251,8 +251,8 @@ public: // TODO: Would be useful to have an iterator based version // of the load command interface too. - basic_symbol_iterator symbol_begin_impl() const override; - basic_symbol_iterator symbol_end_impl() const override; + basic_symbol_iterator symbol_begin() const override; + basic_symbol_iterator symbol_end() const override; // MachO specific. basic_symbol_iterator getSymbolByIndex(unsigned Index) const; diff --git a/include/llvm/Object/ModuleSummaryIndexObjectFile.h b/include/llvm/Object/ModuleSummaryIndexObjectFile.h index 74260974e61..6205927039d 100644 --- a/include/llvm/Object/ModuleSummaryIndexObjectFile.h +++ b/include/llvm/Object/ModuleSummaryIndexObjectFile.h @@ -50,11 +50,11 @@ public: llvm_unreachable("not implemented"); return 0; } - basic_symbol_iterator symbol_begin_impl() const override { + basic_symbol_iterator symbol_begin() const override { llvm_unreachable("not implemented"); return basic_symbol_iterator(BasicSymbolRef()); } - basic_symbol_iterator symbol_end_impl() const override { + basic_symbol_iterator symbol_end() const override { llvm_unreachable("not implemented"); return basic_symbol_iterator(BasicSymbolRef()); } diff --git a/include/llvm/Object/SymbolicFile.h b/include/llvm/Object/SymbolicFile.h index 894c2670f26..9655202097b 100644 --- a/include/llvm/Object/SymbolicFile.h +++ b/include/llvm/Object/SymbolicFile.h @@ -137,17 +137,11 @@ public: virtual uint32_t getSymbolFlags(DataRefImpl Symb) const = 0; - virtual basic_symbol_iterator symbol_begin_impl() const = 0; + virtual basic_symbol_iterator symbol_begin() const = 0; - virtual basic_symbol_iterator symbol_end_impl() const = 0; + virtual basic_symbol_iterator symbol_end() const = 0; // convenience wrappers. - basic_symbol_iterator symbol_begin() const { - return symbol_begin_impl(); - } - basic_symbol_iterator symbol_end() const { - return symbol_end_impl(); - } typedef iterator_range basic_symbol_iterator_range; basic_symbol_iterator_range symbols() const { return basic_symbol_iterator_range(symbol_begin(), symbol_end()); diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index 243f1aec6b5..a2d8f12449e 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -771,13 +771,13 @@ COFFObjectFile::COFFObjectFile(MemoryBufferRef Object, std::error_code &EC) EC = std::error_code(); } -basic_symbol_iterator COFFObjectFile::symbol_begin_impl() const { +basic_symbol_iterator COFFObjectFile::symbol_begin() const { DataRefImpl Ret; Ret.p = getSymbolTable(); return basic_symbol_iterator(SymbolRef(Ret, this)); } -basic_symbol_iterator COFFObjectFile::symbol_end_impl() const { +basic_symbol_iterator COFFObjectFile::symbol_end() const { // The symbol table ends where the string table begins. DataRefImpl Ret; Ret.p = reinterpret_cast(StringTable); diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index a2d2e196519..bf55398f922 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -262,14 +262,14 @@ GlobalValue *IRObjectFile::getSymbolGV(DataRefImpl Symb) { return getGV(Symb); } std::unique_ptr IRObjectFile::takeModule() { return std::move(M); } -basic_symbol_iterator IRObjectFile::symbol_begin_impl() const { +basic_symbol_iterator IRObjectFile::symbol_begin() const { Module::const_iterator I = M->begin(); DataRefImpl Ret; Ret.p = skipEmpty(I, *M); return basic_symbol_iterator(BasicSymbolRef(Ret, this)); } -basic_symbol_iterator IRObjectFile::symbol_end_impl() const { +basic_symbol_iterator IRObjectFile::symbol_end() const { DataRefImpl Ret; uint64_t NumAsm = AsmSymbols.size(); NumAsm <<= 2; diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index cd0c2006f00..76263e125ff 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -2209,7 +2209,7 @@ MachOObjectFile::getRelocationRelocatedSection(relocation_iterator Rel) const { return section_iterator(SectionRef(Sec, this)); } -basic_symbol_iterator MachOObjectFile::symbol_begin_impl() const { +basic_symbol_iterator MachOObjectFile::symbol_begin() const { DataRefImpl DRI; MachO::symtab_command Symtab = getSymtabLoadCommand(); if (!SymtabLoadCmd || Symtab.nsyms == 0) @@ -2218,7 +2218,7 @@ basic_symbol_iterator MachOObjectFile::symbol_begin_impl() const { return getSymbolByIndex(0); } -basic_symbol_iterator MachOObjectFile::symbol_end_impl() const { +basic_symbol_iterator MachOObjectFile::symbol_end() const { DataRefImpl DRI; MachO::symtab_command Symtab = getSymtabLoadCommand(); if (!SymtabLoadCmd || Symtab.nsyms == 0)