<div dir="ltr">On Wed, Oct 9, 2013 at 11:40 AM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Ruiu,<br>
<br>
I am not ok with the interface. Its difficult to handle things if you want to figure out the FileNode type later.<br>
<br>
I think readFile should be renamed to getBuffer() which just returns the buffer associated with the file (or) an error code.<br>
</blockquote><div><br></div><div>That would improve the code quality. I just consolidated the duplicate code that you wrote into one place, so I believe it's at least improving. :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Darwin needs to do that to get the filetype in the Driver to construct the InputGraph nodes properly.<br></blockquote><div><br></div><div>I didn't change the behavior of the code.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Thanks<br>
<br>
Shankar Easwaran<div class=""><div class="h5"><br>
<br>
On 10/9/2013 1:14 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Author: ruiu<br>
Date: Wed Oct  9 13:14:23 2013<br>
New Revision: 192311<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=192311&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=192311&view=rev</a><br>
Log:<br>
Do not process .objtxt file twice.<br>
<br>
A file with .objtxt extension is parsed in readFile(), but because we did not<br>
propagate that information to the calling side, calling side would try to parse<br>
it again. This patch will fix the issue by adding an extra parameter to<br>
readFile().<br>
<br>
Modified:<br>
     lld/trunk/include/lld/Driver/<u></u>DarwinInputGraph.h<br>
     lld/trunk/include/lld/Driver/<u></u>GnuLdInputGraph.h<br>
     lld/trunk/include/lld/Driver/<u></u>InputGraph.h<br>
     lld/trunk/include/lld/Driver/<u></u>WinLinkInputGraph.h<br>
     lld/trunk/lib/Driver/<u></u>InputGraph.cpp<br>
<br>
Modified: lld/trunk/include/lld/Driver/<u></u>DarwinInputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/include/lld/<u></u>Driver/DarwinInputGraph.h?rev=<u></u>192311&r1=192310&r2=192311&<u></u>view=diff</a><br>


==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/include/lld/Driver/<u></u>DarwinInputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/<u></u>DarwinInputGraph.h Wed Oct  9 13:14:23 2013<br>
@@ -42,7 +42,9 @@ public:<br>
      /// \brief Parse the input file to lld::File.<br>
    llvm::error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
-    if (error_code ec = readFile(ctx, diagnostics))<br>
+    // Read the file to _buffer.<br>
+    bool isYaml = false;<br>
+    if (error_code ec = readFile(ctx, diagnostics, isYaml))<br>
        return ec;<br>
      (void) (_isWholeArchive);<br>
      return llvm::error_code::success();<br>
<br>
Modified: lld/trunk/include/lld/Driver/<u></u>GnuLdInputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/GnuLdInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/include/lld/<u></u>Driver/GnuLdInputGraph.h?rev=<u></u>192311&r1=192310&r2=192311&<u></u>view=diff</a><br>


==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/include/lld/Driver/<u></u>GnuLdInputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/<u></u>GnuLdInputGraph.h Wed Oct  9 13:14:23 2013<br>
@@ -73,8 +73,11 @@ public:<br>
    /// \brief Parse the input file to lld::File.<br>
    llvm::error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
      // Read the file to _buffer.<br>
-    if (error_code ec = readFile(ctx, diagnostics))<br>
+    bool isYaml = false;<br>
+    if (error_code ec = readFile(ctx, diagnostics, isYaml))<br>
        return ec;<br>
+    if (isYaml)<br>
+      return error_code::success();<br>
        // Identify File type<br>
      llvm::sys::fs::file_magic FileType =<br>
<br>
Modified: lld/trunk/include/lld/Driver/<u></u>InputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/InputGraph.h?rev=192311&r1=192310&r2=192311&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/include/lld/<u></u>Driver/InputGraph.h?rev=<u></u>192311&r1=192310&r2=192311&<u></u>view=diff</a><br>


==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/include/lld/Driver/<u></u>InputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/<u></u>InputGraph.h Wed Oct  9 13:14:23 2013<br>
@@ -309,7 +309,8 @@ public:<br>
    protected:<br>
    /// \brief Read the file into _buffer.<br>
-  error_code readFile(const LinkingContext &ctx, raw_ostream &diagnostics);<br>
+  error_code readFile(const LinkingContext &ctx, raw_ostream &diagnostics,<br>
+                      bool &isYaml);<br>
      StringRef _path;                             // The path of the Input file<br>
    InputGraph::FileVectorT _files;              // A vector of lld File objects<br>
<br>
Modified: lld/trunk/include/lld/Driver/<u></u>WinLinkInputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=192311&r1=192310&r2=192311&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/include/lld/<u></u>Driver/WinLinkInputGraph.h?<u></u>rev=192311&r1=192310&r2=<u></u>192311&view=diff</a><br>


==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/include/lld/Driver/<u></u>WinLinkInputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/<u></u>WinLinkInputGraph.h Wed Oct  9 13:14:23 2013<br>
@@ -40,8 +40,11 @@ public:<br>
    /// \brief Parse the input file to lld::File.<br>
    error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
      // Read the file to _buffer.<br>
-    if (error_code ec = readFile(ctx, diagnostics))<br>
+    bool isYaml = false;<br>
+    if (error_code ec = readFile(ctx, diagnostics, isYaml))<br>
        return ec;<br>
+    if (isYaml)<br>
+      return error_code::success();<br>
        llvm::sys::fs::file_magic FileType =<br>
          llvm::sys::fs::identify_magic(<u></u>_buffer->getBuffer());<br>
<br>
Modified: lld/trunk/lib/Driver/<u></u>InputGraph.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/InputGraph.cpp?rev=192311&r1=192310&r2=192311&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/lib/Driver/<u></u>InputGraph.cpp?rev=192311&r1=<u></u>192310&r2=192311&view=diff</a><br>


==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/lib/Driver/<u></u>InputGraph.cpp (original)<br>
+++ lld/trunk/lib/Driver/<u></u>InputGraph.cpp Wed Oct  9 13:14:23 2013<br>
@@ -99,7 +99,8 @@ FileNode::FileNode(StringRef path, int64<br>
    /// \brief Read the file into _buffer.<br>
  error_code<br>
-FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
+FileNode::readFile(const LinkingContext &ctx, raw_ostream &diagnostics,<br>
+                   bool &isYaml) {<br>
    ErrorOr<StringRef> filePath = getPath(ctx);<br>
    if (!filePath &&<br>
        error_code(filePath) == llvm::errc::no_such_file_or_<u></u>directory)<br>
@@ -119,9 +120,11 @@ FileNode::readFile(const LinkingContext<br>
      // YAML file is identified by a .objtxt extension<br>
    // FIXME : Identify YAML files by using a magic<br>
-  if (filePath->endswith(".objtxt")<u></u>)<br>
+  if (filePath->endswith(".objtxt")<u></u>) {<br>
      if (error_code ec = ctx.getYAMLReader().parseFile(<u></u>_buffer, _files))<br>
        return ec;<br>
+    isYaml = true;<br>
+  }<br>
    return error_code::success();<br>
  }<br>
  <br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
<br>
</blockquote>
<br>
<br></div></div><span class=""><font color="#888888">
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</font></span></blockquote></div><br></div></div>