[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

Luboš Luňák via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 02:08:10 PDT 2019


llunak added a comment.

The code uses a raw lexer, so it doesn't expand macros. Thus the piece of code quoted will not get the "#if QT_HAS_INCLUDE(<chrono>)" part rewritten. My specific use case is the Icecream distributed build tool which does remote builds in a chroot and so this #if will be false and the expanded contents of <chrono> will be ignored, leading to build errors (https://github.com/icecc/icecream/issues/471).

I can change the code to use 'while' instead of 'if' to handle nested macros, but I think such an approach should go only so far. My patch is simple and handles a realistic scenario, but if more complex macro handling is needed (which is a question), then IMO the code should be changed to do macro expansion properly. It was a long time ago when I wrote the code, but seeing that usage of Preprocessor::SetMacroExpansionOnlyInDirectives() I think such an expansion could be done similarly how handling macro expansion is handled in other directives - which IIRC is getting that information from PPCallbacks.


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