[PATCH] D63508: make -frewrite-includes also rewrite conditions in #if/#elif

Tor Arne Vestbø via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 14:28:10 PDT 2019


torarnv added a comment.

Just for understanding what's going on here, I'm going to ask some stupid questions 😄

So, this will make `-frewrite-includes` do more work, to ensure that it not only covers the "top level" `#include` or `__has_include` case, but also `__has_include` in one or more levels of macros?

Does that effectively means it needs to do full preprocessing? Eg. to determine cases like this:

  #ifdef FOO
  #define BAR(x) __has_include(x)
  #else
  #define BAR(x) 0
  #endif

Or do we draw the line there and only support `__has_include` in macros if those are not conditional themselves? Does it depend on whether `-E` is passed with `-frewrite-includes`?

Will this mean that cases like icecream and distcc that use `-frewrite-includes` will have fully preprocessed sources to send to the remote hosts (with correct line/column number when compilation fails), or should they still pass `-D` options during the remote compilation? I'm referring to this quote from the distcc manual:

> run_second_cpp
> 
> If false, ccache will first run preprocessor to preprocess the source code and then on a cache miss run the compiler on the preprocessed source code instead of the original source code. This makes cache misses slightly faster since the source code only has to be preprocessed once. The downside is that some compilers won’t produce the same result (for instance diagnostics warnings) when compiling preprocessed source code.
> 
> A solution to the above mentioned downside is to set run_second_cpp to false and pass -fdirectives-only (for GCC) or -frewrite-includes (for Clang) to the compiler. This will cause the compiler to leave the macros and other preprocessor information, and only process the #include directives. When run in this way, the preprocessor arguments will be passed to the compiler since it still has to do some preprocessing (like macros).

How does `ICECC_REMOTE_CPP` work in this case?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63508/new/

https://reviews.llvm.org/D63508





More information about the cfe-commits mailing list