From dc8d3a2104dc217dc998e5d545326386e142466c Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 24 Dec 2015 08:36:56 +0000 Subject: [PATCH] Return early and remove a redundant error check. NFC. llvm-svn: 256367 --- lld/ELF/InputFiles.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 9dc4cdfb8892..c0fbe03d1b12 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -61,16 +61,13 @@ ELFFileBase::getSymbolsHelper(bool Local) { template uint32_t ELFFileBase::getSectionIndex(const Elf_Sym &Sym) const { - uint32_t Index = Sym.st_shndx; - if (Index == ELF::SHN_XINDEX) - Index = this->ELFObj.getExtendedSymbolTableIndex(&Sym, this->Symtab, - SymtabSHNDX); - else if (Index == ELF::SHN_UNDEF || Index >= ELF::SHN_LORESERVE) + uint32_t I = Sym.st_shndx; + if (I == ELF::SHN_XINDEX) + return this->ELFObj.getExtendedSymbolTableIndex(&Sym, this->Symtab, + SymtabSHNDX); + if (I >= ELF::SHN_LORESERVE) return 0; - - if (!Index) - error("Invalid section index"); - return Index; + return I; } template void ELFFileBase::initStringTable() {