[llvm] r240644 - Modernize getELFDynamicSymbolIterators.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 25 07:39:35 PDT 2015
Author: rafael
Date: Thu Jun 25 09:39:35 2015
New Revision: 240644
URL: http://llvm.org/viewvc/llvm-project?rev=240644&view=rev
Log:
Modernize getELFDynamicSymbolIterators.
* Have it return a iterator_range.
* Remove the global function.
* Rename to getDynamicSymbolIterators.
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=240644&r1=240643&r2=240644&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Thu Jun 25 09:39:35 2015
@@ -46,8 +46,7 @@ public:
// and addend or not.
virtual bool hasRelocationAddend(DataRefImpl Rel) const = 0;
- virtual std::pair<symbol_iterator, symbol_iterator>
- getELFDynamicSymbolIterators() const = 0;
+ virtual symbol_iterator_range getDynamicSymbolIterators() const = 0;
virtual uint64_t getSectionFlags(SectionRef Sec) const = 0;
virtual uint32_t getSectionType(SectionRef Sec) const = 0;
@@ -237,8 +236,7 @@ public:
ELFT::Is64Bits);
}
- std::pair<symbol_iterator, symbol_iterator>
- getELFDynamicSymbolIterators() const override;
+ symbol_iterator_range getDynamicSymbolIterators() const override;
bool isRelocatableObject() const override;
};
@@ -855,20 +853,15 @@ unsigned ELFObjectFile<ELFT>::getArch()
}
template <class ELFT>
-std::pair<symbol_iterator, symbol_iterator>
-ELFObjectFile<ELFT>::getELFDynamicSymbolIterators() const {
- return std::make_pair(dynamic_symbol_begin(), dynamic_symbol_end());
+ObjectFile::symbol_iterator_range
+ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
+ return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
}
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
return EF.getHeader()->e_type == ELF::ET_REL;
}
-inline std::pair<symbol_iterator, symbol_iterator>
-getELFDynamicSymbolIterators(const SymbolicFile *Obj) {
- return cast<ELFObjectFileBase>(Obj)->getELFDynamicSymbolIterators();
-}
-
}
}
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=240644&r1=240643&r2=240644&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jun 25 09:39:35 2015
@@ -890,14 +890,14 @@ static void dumpSymbolNamesFromObject(Sy
basic_symbol_iterator IBegin = Obj.symbol_begin();
basic_symbol_iterator IEnd = Obj.symbol_end();
if (DynamicSyms) {
- if (!Obj.isELF()) {
+ const auto *E = dyn_cast<ELFObjectFileBase>(&Obj);
+ if (!E) {
error("File format has no dynamic symbol table", Obj.getFileName());
return;
}
- std::pair<symbol_iterator, symbol_iterator> IDyn =
- getELFDynamicSymbolIterators(&Obj);
- IBegin = IDyn.first;
- IEnd = IDyn.second;
+ auto IDyn = E->getDynamicSymbolIterators();
+ IBegin = IDyn.begin();
+ IEnd = IDyn.end();
}
std::string NameBuffer;
raw_string_ostream OS(NameBuffer);
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=240644&r1=240643&r2=240644&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Jun 25 09:39:35 2015
@@ -77,10 +77,9 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj,
bool NoSymbolTable = (Module->symbol_begin() == Module->symbol_end());
if (NoSymbolTable && Module->isELF()) {
// Fallback to dynamic symbol table, if regular symbol table is stripped.
- std::pair<symbol_iterator, symbol_iterator> IDyn =
- getELFDynamicSymbolIterators(Module);
- for (symbol_iterator si = IDyn.first, se = IDyn.second; si != se; ++si) {
- addSymbol(*si, OpdExtractor.get(), OpdAddress);
+ auto IDyn = cast<ELFObjectFileBase>(Module)->getDynamicSymbolIterators();
+ for (SymbolRef Sym : IDyn) {
+ addSymbol(Sym, OpdExtractor.get(), OpdAddress);
}
}
}
More information about the llvm-commits
mailing list