[lld] r218639 - [mach-o] Move implementation of MachOFileNode::parse

Nick Kledzik kledzik at apple.com
Mon Sep 29 16:04:25 PDT 2014


Author: kledzik
Date: Mon Sep 29 18:04:24 2014
New Revision: 218639

URL: http://llvm.org/viewvc/llvm-project?rev=218639&view=rev
Log:
[mach-o] Move implementation of MachOFileNode::parse

Move method implementation from header file to .cpp file.  No functionality
change.

Added:
    lld/trunk/lib/Driver/DarwinInputGraph.cpp
Modified:
    lld/trunk/include/lld/Driver/DarwinInputGraph.h
    lld/trunk/lib/Driver/CMakeLists.txt

Modified: lld/trunk/include/lld/Driver/DarwinInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=218639&r1=218638&r2=218639&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/DarwinInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/DarwinInputGraph.h Mon Sep 29 18:04:24 2014
@@ -18,11 +18,6 @@
 #define LLD_DRIVER_DARWIN_INPUT_GRAPH_H
 
 #include "lld/Core/InputGraph.h"
-#include "lld/Core/ArchiveLibraryFile.h"
-#include "lld/Core/SharedLibraryFile.h"
-#include "lld/ReaderWriter/MachOLinkingContext.h"
-
-#include <map>
 
 namespace lld {
 
@@ -34,47 +29,7 @@ public:
 
   /// \brief Parse the input file to lld::File.
   std::error_code parse(const LinkingContext &ctx,
-                        raw_ostream &diagnostics) override {
-    ErrorOr<StringRef> filePath = getPath(ctx);
-    if (std::error_code ec = filePath.getError())
-      return ec;
-
-    if (std::error_code ec = getBuffer(*filePath))
-      return ec;
-
-    if (ctx.logInputFiles())
-      diagnostics << *filePath << "\n";
-
-    std::vector<std::unique_ptr<File>> parsedFiles;
-    if (_isWholeArchive) {
-      std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles);
-      if (ec)
-        return ec;
-      assert(parsedFiles.size() == 1);
-      std::unique_ptr<File> f(parsedFiles[0].release());
-      if (auto archive =
-              reinterpret_cast<const ArchiveLibraryFile *>(f.get())) {
-        // FIXME: something needs to own archive File
-        //_files.push_back(std::move(archive));
-        return archive->parseAllMembers(_files);
-      } else {
-        // if --whole-archive is around non-archive, just use it as normal.
-        _files.push_back(std::move(f));
-        return std::error_code();
-      }
-    }
-    if (std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles))
-      return ec;
-    for (std::unique_ptr<File> &pf : parsedFiles) {
-      // If a dylib was parsed, inform LinkingContext about it.
-      if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(pf.get())) {
-        MachOLinkingContext *mctx = (MachOLinkingContext*)(&ctx);
-        mctx->registerDylib(reinterpret_cast<mach_o::MachODylibFile*>(shl));
-      }
-      _files.push_back(std::move(pf));
-    }
-    return std::error_code();
-  }
+                        raw_ostream &diagnostics) override;
 
   /// \brief Return the file that has to be processed by the resolver
   /// to resolve atoms. This iterates over all the files thats part

Modified: lld/trunk/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CMakeLists.txt?rev=218639&r1=218638&r2=218639&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CMakeLists.txt (original)
+++ lld/trunk/lib/Driver/CMakeLists.txt Mon Sep 29 18:04:24 2014
@@ -12,6 +12,7 @@ add_public_tablegen_target(DriverOptions
 
 add_lld_library(lldDriver
   CoreDriver.cpp
+  DarwinInputGraph.cpp
   DarwinLdDriver.cpp
   Driver.cpp
   GnuLdDriver.cpp

Added: lld/trunk/lib/Driver/DarwinInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinInputGraph.cpp?rev=218639&view=auto
==============================================================================
--- lld/trunk/lib/Driver/DarwinInputGraph.cpp (added)
+++ lld/trunk/lib/Driver/DarwinInputGraph.cpp Mon Sep 29 18:04:24 2014
@@ -0,0 +1,69 @@
+//===- lib/ReaderWriter/MachO/DarwinInputGraph.cpp ------------------------===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lld/Driver/DarwinInputGraph.h"
+
+#include "lld/Core/ArchiveLibraryFile.h"
+#include "lld/Core/DefinedAtom.h"
+#include "lld/Core/File.h"
+#include "lld/Core/LLVM.h"
+#include "lld/Core/Reference.h"
+#include "lld/Core/SharedLibraryFile.h"
+
+#include "lld/ReaderWriter/MachOLinkingContext.h"
+
+namespace lld {
+
+/// \brief Parse the input file to lld::File.
+std::error_code MachOFileNode::parse(const LinkingContext &ctx,
+                                     raw_ostream &diagnostics)  {
+  ErrorOr<StringRef> filePath = getPath(ctx);
+  if (std::error_code ec = filePath.getError())
+    return ec;
+
+  if (std::error_code ec = getBuffer(*filePath))
+    return ec;
+
+  if (ctx.logInputFiles())
+    diagnostics << *filePath << "\n";
+
+  std::vector<std::unique_ptr<File>> parsedFiles;
+  if (_isWholeArchive) {
+    std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles);
+    if (ec)
+      return ec;
+    assert(parsedFiles.size() == 1);
+    std::unique_ptr<File> f(parsedFiles[0].release());
+    if (auto archive =
+            reinterpret_cast<const ArchiveLibraryFile *>(f.get())) {
+      // FIXME: something needs to own archive File
+      //_files.push_back(std::move(archive));
+      return archive->parseAllMembers(_files);
+    } else {
+      // if --whole-archive is around non-archive, just use it as normal.
+      _files.push_back(std::move(f));
+      return std::error_code();
+    }
+  }
+  if (std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles))
+    return ec;
+  for (std::unique_ptr<File> &pf : parsedFiles) {
+    // If a dylib was parsed, inform LinkingContext about it.
+    if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(pf.get())) {
+      MachOLinkingContext *mctx = (MachOLinkingContext*)(&ctx);
+      mctx->registerDylib(reinterpret_cast<mach_o::MachODylibFile*>(shl));
+    }
+    _files.push_back(std::move(pf));
+  }
+  return std::error_code();
+}
+
+
+
+} // end namesapce lld





More information about the llvm-commits mailing list