[PATCH] [cleanup] Clean up the flow of creating a symbol body for regular symbols.

Chandler Carruth chandlerc at gmail.com
Mon Jun 29 14:33:13 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10791

Files:
  lld/trunk/COFF/InputFiles.cpp

Index: lld/trunk/COFF/InputFiles.cpp
===================================================================
--- lld/trunk/COFF/InputFiles.cpp
+++ lld/trunk/COFF/InputFiles.cpp
@@ -206,26 +206,26 @@
     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() {

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10791.28711.patch
Type: text/x-patch
Size: 1730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150629/7d90270a/attachment.bin>


More information about the llvm-commits mailing list