From 70625fb16395c2b5ae0140429e7df854006cc4d1 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 3 Apr 2014 22:21:59 +0000 Subject: [PATCH] Move code into a helper function. Move code that always runs after doUndefinedAtom into doUndefinedAtom for readability. llvm-svn: 205574 --- lld/lib/Core/Resolver.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index cf4af5cd0f19..2ed88c9d1a4b 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -69,27 +69,15 @@ private: } // namespace void Resolver::handleFile(const File &file) { - bool isEmpty = file.defined().empty() && file.sharedLibrary().empty() && - file.absolute().empty() && file.undefined().empty(); + bool isEmpty = file.defined().empty() && file.undefined().empty() && + file.sharedLibrary().empty() && file.absolute().empty(); if (isEmpty) return; for (const DefinedAtom *atom : file.defined()) doDefinedAtom(*atom); - - for (const UndefinedAtom *undefAtom : file.undefined()) { - doUndefinedAtom(*undefAtom); - // If the undefined symbol has an alternative name, try to resolve the - // symbol with the name to give it a second chance. This feature is used - // for COFF "weak external" symbol. - if (!_symbolTable.isDefined(undefAtom->name())) { - if (const UndefinedAtom *fallbackAtom = undefAtom->fallback()) { - doUndefinedAtom(*fallbackAtom); - _symbolTable.addReplacement(undefAtom, fallbackAtom); - } - } - } - + for (const UndefinedAtom *atom : file.undefined()) + doUndefinedAtom(*atom); for (const SharedLibraryAtom *atom : file.sharedLibrary()) doSharedLibraryAtom(*atom); for (const AbsoluteAtom *atom : file.absolute()) @@ -165,15 +153,23 @@ void Resolver::doUndefinedAtom(const UndefinedAtom &atom) { DEBUG_WITH_TYPE("resolver", llvm::dbgs() << " UndefinedAtom: " << llvm::format("0x%09lX", &atom) - << ", name=" - << atom.name() - << "\n"); + << ", name=" << atom.name() << "\n"); // add to list of known atoms _atoms.push_back(&atom); // tell symbol table _symbolTable.add(atom); + + // If the undefined symbol has an alternative name, try to resolve the + // symbol with the name to give it a second chance. This feature is used + // for COFF "weak external" symbol. + if (!_symbolTable.isDefined(atom.name())) { + if (const UndefinedAtom *fallbackAtom = atom.fallback()) { + doUndefinedAtom(*fallbackAtom); + _symbolTable.addReplacement(&atom, fallbackAtom); + } + } } /// \brief Add the section group and the group-child reference members.