<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 18, 2016 at 6:28 AM, Vassil Vassilev <span dir="ltr"><<a href="mailto:v.g.vassilev@gmail.com" target="_blank">v.g.vassilev@gmail.com</a>></span> 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"><span class="">On 08/04/16 03:24, Richard Smith via cfe-commits 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: rsmith<br>
Date: Thu Apr  7 20:23:59 2016<br>
New Revision: 265766<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265766&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=265766&view=rev</a><br>
Log:<br>
[modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.<br>
<br>
Modified:<br>
     cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br>
     cfe/trunk/test/Modules/preprocess.cpp<br>
<br>
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766&r1=265765&r2=265766&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766&r1=265765&r2=265766&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr  7 20:23:59 2016<br>
@@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion<br>
        OS << "#include "<br>
           << (IsAngled ? '<' : '"')<br>
           << FileName<br>
-         << (IsAngled ? '>' : '"');<br>
+         << (IsAngled ? '>' : '"')<br>
+         << " /* clang -E: implicit import for module "<br>
+         << Imported->getFullModuleName() << " */";<br>
</blockquote></span>
It seems that in some cases the FileName needs to be tweaked to be able to compile the output back. For instance:<br>
clang -I folder/ file.cxx<br>
cat file.cxx<br>
#include "subfolder/A.h"<br>
<br>
cat folder/subfolder/A.h<br>
#include "B.h"<br>
<br>
B.h resides in folder/subfolder/ and FileName argument would be B.h causing the printer to generate #include "B.h" /* clang -E: implicit import for... */ which cannot be compiled back.</blockquote><div><br></div><div>Ugh, yeah, that makes sense.</div><div><br></div><div>It seems superficially that what we should do for a file found relative to the current file (or in MSVC mode, for a file found relative to a possibly-indirect includer of the current file) is to prepend the path from that file's search path to the current file. That is, if we find "foo/bar.h" in search path "includes/x", and we find "baz/quux.h" relative to bar.h, we should produce the path "foo/baz/quux.h" (to be found relative to "includes/x"). However, that won't work if there is a prior include path that also contains a "foo/baz/quux.h", so we would need to also include the search path in the include path. And *that* won't work if . is not a search path and one of the search paths is a relative path.</div><div><br></div><div>I wonder whether the problem is really that we're handling #include search paths incorrectly in the presence of #line markers. Perhaps for the relative path search we should somehow instruct clang to look for files relative to the presumed file rather than the physical file? That would match our intent for these files. However, this doesn't match the GCC behavior, so we probably can't do it by default. =/</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"><div class=""><div class="h5">
<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">
      }<br>
      // Since we want a newline after the @import, but not a #<line>, start a new<br>
      // line immediately.<br>
<br>
Modified: cfe/trunk/test/Modules/preprocess.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess.cpp?rev=265766&r1=265765&r2=265766&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess.cpp?rev=265766&r1=265765&r2=265766&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/preprocess.cpp (original)<br>
+++ cfe/trunk/test/Modules/preprocess.cpp Thu Apr  7 20:23:59 2016<br>
@@ -1,6 +1,6 @@<br>
  // RUN: rm -rf %t<br>
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -x c++ -E %s | \<br>
-// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK --check-prefix=CXX<br>
+// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK --check-prefix=CXX --check-prefix=CXX-DASHE<br>
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -x objective-c -E %s | \<br>
  // RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK --check-prefix=OBJC<br>
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -x c++ -E -frewrite-includes %s | \<br>
@@ -14,7 +14,9 @@ foo bar baz<br>
  // The weird {{ }} here is to prevent the -frewrite-includes test from matching its own CHECK lines.<br>
    // CXX: #include{{ }}"dummy.h"<br>
+// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */<br>
  // CXX: #include{{ }}"dummy.h"<br>
+// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */<br>
  // CXX: foo bar baz<br>
    // OBJC: @import{{ }}dummy; /* clang<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>