[llvm] r240783 - Simplify isObject. NFC.
Rafael Espindola
rafael.espindola at gmail.com
Fri Jun 26 06:24:23 PDT 2015
Author: rafael
Date: Fri Jun 26 08:24:23 2015
New Revision: 240783
URL: http://llvm.org/viewvc/llvm-project?rev=240783&view=rev
Log:
Simplify isObject. NFC.
Modified:
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
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=240783&r1=240782&r2=240783&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Fri Jun 26 08:24:23 2015
@@ -777,26 +777,12 @@ static char getSymbolNMTypeChar(IRObject
return getSymbolNMTypeChar(*GV);
}
-template <class ELFT>
-static bool isELFObject(ELFObjectFile<ELFT> &Obj, symbol_iterator I) {
- typedef typename ELFObjectFile<ELFT>::Elf_Sym Elf_Sym;
-
- DataRefImpl Symb = I->getRawDataRefImpl();
- const Elf_Sym *ESym = Obj.getSymbol(Symb);
-
- return ESym->getType() == ELF::STT_OBJECT;
-}
-
static bool isObject(SymbolicFile &Obj, basic_symbol_iterator I) {
- if (ELF32LEObjectFile *ELF = dyn_cast<ELF32LEObjectFile>(&Obj))
- return isELFObject(*ELF, I);
- if (ELF64LEObjectFile *ELF = dyn_cast<ELF64LEObjectFile>(&Obj))
- return isELFObject(*ELF, I);
- if (ELF32BEObjectFile *ELF = dyn_cast<ELF32BEObjectFile>(&Obj))
- return isELFObject(*ELF, I);
- if (ELF64BEObjectFile *ELF = dyn_cast<ELF64BEObjectFile>(&Obj))
- return isELFObject(*ELF, I);
- return false;
+ auto *ELF = dyn_cast<ELFObjectFileBase>(&Obj);
+ if (!ELF)
+ return false;
+
+ return elf_symbol_iterator(I)->getELFType() == ELF::STT_OBJECT;
}
static char getNMTypeChar(SymbolicFile &Obj, basic_symbol_iterator I) {
More information about the llvm-commits
mailing list