[lld] r205574 - Move code into a helper function.

Rui Ueyama ruiu at google.com
Thu Apr 3 15:21:59 PDT 2014


Author: ruiu
Date: Thu Apr  3 17:21:59 2014
New Revision: 205574

URL: http://llvm.org/viewvc/llvm-project?rev=205574&view=rev
Log:
Move code into a helper function.

Move code that always runs after doUndefinedAtom into doUndefinedAtom
for readability.

Modified:
    lld/trunk/lib/Core/Resolver.cpp

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=205574&r1=205573&r2=205574&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Apr  3 17:21:59 2014
@@ -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 Und
   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.





More information about the llvm-commits mailing list