[lld] r195281 - Move member functions to its own cpp file.
Rui Ueyama
ruiu at google.com
Wed Nov 20 15:51:41 PST 2013
Author: ruiu
Date: Wed Nov 20 17:51:41 2013
New Revision: 195281
URL: http://llvm.org/viewvc/llvm-project?rev=195281&view=rev
Log:
Move member functions to its own cpp file.
Added:
lld/trunk/lib/Driver/WinLinkInputGraph.cpp
Modified:
lld/trunk/include/lld/Driver/WinLinkInputGraph.h
lld/trunk/lib/Driver/CMakeLists.txt
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=195281&r1=195280&r2=195281&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Wed Nov 20 17:51:41 2013
@@ -38,38 +38,7 @@ public:
virtual ErrorOr<StringRef> getPath(const LinkingContext &ctx) const;
/// \brief Parse the input file to lld::File.
- error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
- ErrorOr<StringRef> filePath = getPath(ctx);
- if (!filePath)
- return error_code(filePath);
-
- if (error_code ec = getBuffer(*filePath))
- return ec;
-
- if (ctx.logInputFiles())
- diagnostics << *filePath << "\n";
-
- if (filePath->endswith(".objtxt"))
- return ctx.getYAMLReader().parseFile(_buffer, _files);
-
- llvm::sys::fs::file_magic FileType =
- llvm::sys::fs::identify_magic(_buffer->getBuffer());
- std::unique_ptr<File> f;
-
- switch (FileType) {
- case llvm::sys::fs::file_magic::archive: {
- // Archive File
- error_code ec;
- f.reset(new FileArchive(ctx, std::move(_buffer), ec, false));
- _files.push_back(std::move(f));
- return ec;
- }
-
- case llvm::sys::fs::file_magic::coff_object:
- default:
- return _ctx.getDefaultReader().parseFile(_buffer, _files);
- }
- }
+ error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics);
/// \brief validates the Input Element
virtual bool validate() { return true; }
@@ -77,11 +46,7 @@ public:
/// \brief Dump the Input Element
virtual bool dump(raw_ostream &) { return true; }
- virtual ErrorOr<File &> getNextFile() {
- if (_nextFileIndex == _files.size())
- return make_error_code(InputGraphError::no_more_files);
- return *_files[_nextFileIndex++];
- }
+ virtual ErrorOr<File &> getNextFile();
protected:
const PECOFFLinkingContext &_ctx;
Modified: lld/trunk/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CMakeLists.txt?rev=195281&r1=195280&r2=195281&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CMakeLists.txt (original)
+++ lld/trunk/lib/Driver/CMakeLists.txt Wed Nov 20 17:51:41 2013
@@ -16,6 +16,7 @@ add_lld_library(lldDriver
Driver.cpp
GnuLdDriver.cpp
WinLinkDriver.cpp
+ WinLinkInputGraph.cpp
UniversalDriver.cpp
)
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=195281&r1=195280&r2=195281&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Nov 20 17:51:41 2013
@@ -547,20 +547,6 @@ parseArgs(int argc, const char *argv[],
// Main driver
//
-ErrorOr<StringRef> PECOFFFileNode::getPath(const LinkingContext &) const {
- if (_path.endswith_lower(".lib"))
- return _ctx.searchLibraryFile(_path);
- if (llvm::sys::path::extension(_path).empty())
- return _ctx.allocateString(_path.str() + ".obj");
- return _path;
-}
-
-ErrorOr<StringRef> PECOFFLibraryNode::getPath(const LinkingContext &) const {
- if (!_path.endswith_lower(".lib"))
- return _ctx.searchLibraryFile(_ctx.allocateString(_path.str() + ".lib"));
- return _ctx.searchLibraryFile(_path);
-}
-
bool WinLinkDriver::linkPECOFF(int argc, const char *argv[],
raw_ostream &diagnostics) {
PECOFFLinkingContext context;
Added: lld/trunk/lib/Driver/WinLinkInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=195281&view=auto
==============================================================================
--- lld/trunk/lib/Driver/WinLinkInputGraph.cpp (added)
+++ lld/trunk/lib/Driver/WinLinkInputGraph.cpp Wed Nov 20 17:51:41 2013
@@ -0,0 +1,68 @@
+//===- lib/Driver/WinLinkDriver.cpp ---------------------------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lld/Driver/WinLinkInputGraph.h"
+
+namespace lld {
+
+/// \brief Parse the input file to lld::File.
+error_code PECOFFFileNode::parse(const LinkingContext &ctx,
+ raw_ostream &diagnostics) {
+ ErrorOr<StringRef> filePath = getPath(ctx);
+ if (!filePath)
+ return error_code(filePath);
+
+ if (error_code ec = getBuffer(*filePath))
+ return ec;
+
+ if (ctx.logInputFiles())
+ diagnostics << *filePath << "\n";
+
+ if (filePath->endswith(".objtxt"))
+ return ctx.getYAMLReader().parseFile(_buffer, _files);
+
+ llvm::sys::fs::file_magic FileType =
+ llvm::sys::fs::identify_magic(_buffer->getBuffer());
+ std::unique_ptr<File> f;
+
+ switch (FileType) {
+ case llvm::sys::fs::file_magic::archive: {
+ // Archive File
+ error_code ec;
+ f.reset(new FileArchive(ctx, std::move(_buffer), ec, false));
+ _files.push_back(std::move(f));
+ return ec;
+ }
+ case llvm::sys::fs::file_magic::coff_object:
+ default:
+ return _ctx.getDefaultReader().parseFile(_buffer, _files);
+ }
+}
+
+ErrorOr<File &> PECOFFFileNode::getNextFile() {
+ if (_nextFileIndex == _files.size())
+ return make_error_code(InputGraphError::no_more_files);
+ return *_files[_nextFileIndex++];
+}
+
+ErrorOr<StringRef> PECOFFFileNode::getPath(const LinkingContext &) const {
+ if (_path.endswith_lower(".lib"))
+ return _ctx.searchLibraryFile(_path);
+ if (llvm::sys::path::extension(_path).empty())
+ return _ctx.allocateString(_path.str() + ".obj");
+ return _path;
+}
+
+ErrorOr<StringRef> PECOFFLibraryNode::getPath(const LinkingContext &) const {
+ if (!_path.endswith_lower(".lib"))
+ return _ctx.searchLibraryFile(_ctx.allocateString(_path.str() + ".lib"));
+ return _ctx.searchLibraryFile(_path);
+}
+
+} // end anonymous namespace
More information about the llvm-commits
mailing list