diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-06-30 00:32:37 +0300 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-06-30 00:32:37 +0300 |
commit | ee5bf526eb2c3e05094fdaf233b5ecf8c7295862 (patch) | |
tree | c5b56d35b30adb8fd6da009ba5b350e3c2a37b8b /lld/COFF | |
parent | b7724b95d86df071c1b6f20ed2abe09a00374e31 (diff) |
[cleanup] Clean up the flow of creating a symbol body for regular symbols.
This uses a single cast and test to get the section for the symbol, and
uses the cast_or_null<> pattern throughout to handle the known type but
unknown non-null-ness.
No functionality changed.
Differential Revision: http://reviews.llvm.org/D10791
llvm-svn: 241000
Diffstat (limited to 'lld/COFF')
-rw-r--r-- | lld/COFF/InputFiles.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 61f0b6331404..5688f505a48d 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -206,26 +206,26 @@ SymbolBody *ObjectFile::createSymbolBody(COFFSymbolRef Sym, const void *AuxP, auto *Aux = (const coff_aux_weak_external *)AuxP; return new (Alloc) Undefined(Name, &SparseSymbolBodies[Aux->TagIndex]); } + + // Nothing else to do without a section chunk. + auto *SC = cast_or_null<SectionChunk>(SparseChunks[Sym.getSectionNumber()]); + if (!SC) + return nullptr; + // Handle associative sections if (IsFirst && AuxP) { - if (Chunk *C = SparseChunks[Sym.getSectionNumber()]) { - auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP); - if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE) { - auto *Parent = - (SectionChunk *)(SparseChunks[Aux->getNumber(Sym.isBigObj())]); - if (Parent) - Parent->addAssociative((SectionChunk *)C); - } - } - } - Chunk *C = SparseChunks[Sym.getSectionNumber()]; - if (auto *SC = cast_or_null<SectionChunk>(C)) { - auto *B = new (Alloc) DefinedRegular(this, Sym, SC); - if (SC->isCOMDAT() && Sym.getValue() == 0 && !AuxP) - SC->setSymbol(B); - return B; + auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP); + if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE) + if (auto *ParentSC = cast_or_null<SectionChunk>( + SparseChunks[Aux->getNumber(Sym.isBigObj())])) + ParentSC->addAssociative(SC); } - return nullptr; + + auto *B = new (Alloc) DefinedRegular(this, Sym, SC); + if (SC->isCOMDAT() && Sym.getValue() == 0 && !AuxP) + SC->setSymbol(B); + + return B; } std::error_code ImportFile::parse() { |