[lld] r205284 - [PECOFF] Make PECOFFFileNode::parse idempotent.

Rui Ueyama ruiu at google.com
Mon Mar 31 23:18:19 PDT 2014


Author: ruiu
Date: Tue Apr  1 01:18:19 2014
New Revision: 205284

URL: http://llvm.org/viewvc/llvm-project?rev=205284&view=rev
Log:
[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.

Modified:
    lld/trunk/include/lld/Driver/WinLinkInputGraph.h
    lld/trunk/lib/Driver/WinLinkInputGraph.cpp

Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=205284&r1=205283&r2=205284&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Tue Apr  1 01:18:19 2014
@@ -30,7 +30,7 @@ extern bool isCOFFLibraryFileExtension(S
 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

Modified: lld/trunk/lib/Driver/WinLinkInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=205284&r1=205283&r2=205284&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkInputGraph.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkInputGraph.cpp Tue Apr  1 01:18:19 2014
@@ -18,6 +18,9 @@ bool isCOFFLibraryFileExtension(StringRe
 /// \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";





More information about the llvm-commits mailing list