[PECOFF] Make PECOFFFileNode::parse idempotent.

PECOFFFileNode::parse can be called twice -- once by WinLink driver and
once more by Driver. We want to make sure that the second call won't mess
up the internal data.

llvm-svn: 205284
This commit is contained in:
Rui Ueyama 2014-04-01 06:18:19 +00:00
parent 1e7d0721ae
commit e081e22036
2 changed files with 7 additions and 1 deletions

View File

@ -30,7 +30,7 @@ extern bool isCOFFLibraryFileExtension(StringRef path);
class PECOFFFileNode : public FileNode {
public:
PECOFFFileNode(PECOFFLinkingContext &ctx, StringRef path)
: FileNode(path), _ctx(ctx) {}
: FileNode(path), _ctx(ctx), _parsed(false) {}
ErrorOr<StringRef> getPath(const LinkingContext &ctx) const override;
@ -47,6 +47,9 @@ public:
protected:
const PECOFFLinkingContext &_ctx;
private:
bool _parsed;
};
/// \brief Represents a PECOFF Library File

View File

@ -18,6 +18,9 @@ bool isCOFFLibraryFileExtension(StringRef path) {
/// \brief Parse the input file to lld::File.
error_code PECOFFFileNode::parse(const LinkingContext &ctx,
raw_ostream &diagnostics) {
if (_parsed)
return error_code::success();
_parsed = true;
ErrorOr<StringRef> filePath = getPath(ctx);
if (error_code ec = filePath.getError()) {
diagnostics << "File not found: " << _path << "\n";