forked from OSchip/llvm-project
Do not process .objtxt file twice.
A file with .objtxt extension is parsed in readFile(), but because we did not propagate that information to the calling side, calling side would try to parse it again. This patch will fix the issue by adding an extra parameter to readFile(). llvm-svn: 192311
This commit is contained in:
parent
95d4e61411
commit
85cc66d85e
|
@ -42,7 +42,9 @@ public:
|
|||
|
||||
/// \brief Parse the input file to lld::File.
|
||||
llvm::error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
|
||||
if (error_code ec = readFile(ctx, diagnostics))
|
||||
// Read the file to _buffer.
|
||||
bool isYaml = false;
|
||||
if (error_code ec = readFile(ctx, diagnostics, isYaml))
|
||||
return ec;
|
||||
(void) (_isWholeArchive);
|
||||
return llvm::error_code::success();
|
||||
|
|
|
@ -73,8 +73,11 @@ public:
|
|||
/// \brief Parse the input file to lld::File.
|
||||
llvm::error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
|
||||
// Read the file to _buffer.
|
||||
if (error_code ec = readFile(ctx, diagnostics))
|
||||
bool isYaml = false;
|
||||
if (error_code ec = readFile(ctx, diagnostics, isYaml))
|
||||
return ec;
|
||||
if (isYaml)
|
||||
return error_code::success();
|
||||
|
||||
// Identify File type
|
||||
llvm::sys::fs::file_magic FileType =
|
||||
|
|
|
@ -309,7 +309,8 @@ public:
|
|||
|
||||
protected:
|
||||
/// \brief Read the file into _buffer.
|
||||
error_code readFile(const LinkingContext &ctx, raw_ostream &diagnostics);
|
||||
error_code readFile(const LinkingContext &ctx, raw_ostream &diagnostics,
|
||||
bool &isYaml);
|
||||
|
||||
StringRef _path; // The path of the Input file
|
||||
InputGraph::FileVectorT _files; // A vector of lld File objects
|
||||
|
|
|
@ -40,8 +40,11 @@ public:
|
|||
/// \brief Parse the input file to lld::File.
|
||||
error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
|
||||
// Read the file to _buffer.
|
||||
if (error_code ec = readFile(ctx, diagnostics))
|
||||
bool isYaml = false;
|
||||
if (error_code ec = readFile(ctx, diagnostics, isYaml))
|
||||
return ec;
|
||||
if (isYaml)
|
||||
return error_code::success();
|
||||
|
||||
llvm::sys::fs::file_magic FileType =
|
||||
llvm::sys::fs::identify_magic(_buffer->getBuffer());
|
||||
|
|
|
@ -99,7 +99,8 @@ FileNode::FileNode(StringRef path, int64_t ordinal)
|
|||
|
||||
/// \brief Read the file into _buffer.
|
||||
error_code
|
||||
FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics) {
|
||||
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)
|
||||
|
@ -119,9 +120,11 @@ FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics) {
|
|||
|
||||
// YAML file is identified by a .objtxt extension
|
||||
// FIXME : Identify YAML files by using a magic
|
||||
if (filePath->endswith(".objtxt"))
|
||||
if (filePath->endswith(".objtxt")) {
|
||||
if (error_code ec = ctx.getYAMLReader().parseFile(_buffer, _files))
|
||||
return ec;
|
||||
isYaml = true;
|
||||
}
|
||||
return error_code::success();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue