[lld] r194360 - [cleanup] remove readFile and replace with getBuffer.
Shankar Easwaran
shankare at codeaurora.org
Sun Nov 10 18:13:30 PST 2013
Author: shankare
Date: Sun Nov 10 20:13:30 2013
New Revision: 194360
URL: http://llvm.org/viewvc/llvm-project?rev=194360&view=rev
Log:
[cleanup] remove readFile and replace with getBuffer.
no functionality change.
Modified:
lld/trunk/include/lld/Driver/DarwinInputGraph.h
lld/trunk/include/lld/Driver/GnuLdInputGraph.h
lld/trunk/include/lld/Driver/InputGraph.h
lld/trunk/include/lld/Driver/WinLinkInputGraph.h
lld/trunk/lib/Driver/InputGraph.cpp
Modified: lld/trunk/include/lld/Driver/DarwinInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=194360&r1=194359&r2=194360&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/DarwinInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/DarwinInputGraph.h Sun Nov 10 20:13:30 2013
@@ -42,10 +42,19 @@ public:
/// \brief Parse the input file to lld::File.
error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
- // Read the file to _buffer.
- bool isYaml = false;
- if (error_code ec = readFile(ctx, diagnostics, isYaml))
+ 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);
+
(void) (_isWholeArchive);
return error_code::success();
}
Modified: lld/trunk/include/lld/Driver/GnuLdInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/GnuLdInputGraph.h?rev=194360&r1=194359&r2=194360&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/GnuLdInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/GnuLdInputGraph.h Sun Nov 10 20:13:30 2013
@@ -72,12 +72,18 @@ public:
/// \brief Parse the input file to lld::File.
error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
- // Read the file to _buffer.
- bool isYaml = false;
- if (error_code ec = readFile(ctx, diagnostics, isYaml))
+ ErrorOr<StringRef> filePath = getPath(ctx);
+ if (!filePath)
+ return error_code(filePath);
+
+ if (error_code ec = getBuffer(*filePath))
return ec;
- if (isYaml)
- return error_code::success();
+
+ if (ctx.logInputFiles())
+ diagnostics << *filePath << "\n";
+
+ if (filePath->endswith(".objtxt"))
+ return ctx.getYAMLReader().parseFile(_buffer, _files);
// Identify File type
llvm::sys::fs::file_magic FileType =
Modified: lld/trunk/include/lld/Driver/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/InputGraph.h?rev=194360&r1=194359&r2=194360&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/InputGraph.h (original)
+++ lld/trunk/include/lld/Driver/InputGraph.h Sun Nov 10 20:13:30 2013
@@ -297,8 +297,7 @@ public:
protected:
/// \brief Read the file into _buffer.
- error_code readFile(const LinkingContext &ctx, raw_ostream &diagnostics,
- bool &isYaml);
+ error_code getBuffer(StringRef filePath);
StringRef _path; // The path of the Input file
InputGraph::FileVectorT _files; // A vector of lld File objects
Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=194360&r1=194359&r2=194360&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Sun Nov 10 20:13:30 2013
@@ -39,12 +39,18 @@ public:
/// \brief Parse the input file to lld::File.
error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
- // Read the file to _buffer.
- bool isYaml = false;
- if (error_code ec = readFile(ctx, diagnostics, isYaml))
+ ErrorOr<StringRef> filePath = getPath(ctx);
+ if (!filePath)
+ return error_code(filePath);
+
+ if (error_code ec = getBuffer(*filePath))
return ec;
- if (isYaml)
- return error_code::success();
+
+ 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());
Modified: lld/trunk/lib/Driver/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/InputGraph.cpp?rev=194360&r1=194359&r2=194360&view=diff
==============================================================================
--- lld/trunk/lib/Driver/InputGraph.cpp (original)
+++ lld/trunk/lib/Driver/InputGraph.cpp Sun Nov 10 20:13:30 2013
@@ -98,33 +98,16 @@ FileNode::FileNode(StringRef path, int64
_resolveState(Resolver::StateNoChange), _nextFileIndex(0) {}
/// \brief Read the file into _buffer.
-error_code
-FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics,
- bool &isYaml) {
- ErrorOr<StringRef> filePath = getPath(ctx);
- if (!filePath &&
- error_code(filePath) == llvm::errc::no_such_file_or_directory)
- return make_error_code(llvm::errc::no_such_file_or_directory);
-
+error_code FileNode::getBuffer(StringRef filePath) {
// Create a memory buffer
OwningPtr<MemoryBuffer> opmb;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(*filePath, opmb))
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, opmb))
return ec;
std::unique_ptr<MemoryBuffer> mb(opmb.take());
_buffer = std::move(mb);
- if (ctx.logInputFiles())
- diagnostics << _buffer->getBufferIdentifier() << "\n";
-
- // YAML file is identified by a .objtxt extension
- // FIXME : Identify YAML files by using a magic
- if (filePath->endswith(".objtxt")) {
- if (error_code ec = ctx.getYAMLReader().parseFile(_buffer, _files))
- return ec;
- isYaml = true;
- }
return error_code::success();
}
More information about the llvm-commits
mailing list