<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang -frewrite-includes fails to remove __has_include if behind a macro."
   href="https://bugs.llvm.org/show_bug.cgi?id=43982">43982</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang -frewrite-includes fails to remove __has_include if behind a macro.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>emilio@crisal.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22801" name="attach_22801" title="test-case.cpp">attachment 22801</a> <a href="attachment.cgi?id=22801&action=edit" title="test-case.cpp">[details]</a></span>
test-case.cpp

Minimal test-case attached. STR:

$ touch t.h
$ clang -frewrite-includes -E test-case.cpp > pre-processed.cpp
$ rm t.h
$ clang pre-processed.cpp
t.cpp:10:3: error: use of undeclared identifier 'std'
  std::cout << "Hello world" << std::endl;
  ^
t.cpp:10:33: error: use of undeclared identifier 'std'
  std::cout << "Hello world" << std::endl;

This is because:

 * The __has_include check is not removed when expanding, and...
 * The second <iostream> expansion is suppressed.

This is causing problems when building Firefox on Linux with distributed
compilers, because glibc has started using this pattern:
<a href="https://sourceware.org/ml/libc-alpha/2019-06/msg00254.html">https://sourceware.org/ml/libc-alpha/2019-06/msg00254.html</a>

I plan to try and submit a glibc workaround, but it'd be great if it wasn't
needed :)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>