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

2019-06-19 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment. In D63508#1550668 , @rsmith wrote: > Perhaps we should rewrite all `#if`-like directives to `#if 0` or `#if 1`? I think that would work too and it'd be in fact a reliable simple solution. Repository: rC Clang CHANGES SINCE LA

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

2019-06-19 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment. In D63508#1550668 , @rsmith wrote: > Perhaps we should rewrite all `#if`-like directives to `#if 0` or `#if 1`? If I understand your suggestion correctly, wouldn't the latter break this case? #if QT_HAS_INCLUDE() # include

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

2019-06-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. Perhaps we should rewrite all `#if`-like directives to `#if 0` or `#if 1`? Either that or we could emit pragmas indicating the values of later `__has_include`s. Special-casing macros of this specific form is at best a partial solution. Repository: rC Clang CHANGES S

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

2019-06-19 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment. Icecream's usage of -frewrite-includes is not special, the purpose is always to merge everything necessary for the compilation into one source file that can be later compiled on its own as if the original file was compiled. The #include expansion done during -frewrite-in

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

2019-06-19 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment. Just a thought: From the point of view of `-frewrite-includes`, it should technically do full/nested macro expansion right? But from the point of view of Icecream, that would defeat the purpose of using `-frewrite-includes`, since the goal is to embed all includes into

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

2019-06-19 Thread Luboš Luňák via Phabricator via cfe-commits
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()" 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 an

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

2019-06-18 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment. Luboš, can you please clarify what is wrong with the current Clang behavior? I'm just thinking about what should we do with nested macros. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63508/new/ https://reviews.llvm.org/D63508 __

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

2019-06-18 Thread Luboš Luňák via Phabricator via cfe-commits
llunak created this revision. llunak added reviewers: vsapsai, bkramer. llunak added a project: clang. Herald added subscribers: cfe-commits, dexonsmith. Qt5 has a wrapper macro that makes __has_include simpler to use: #ifdef __has_include 1. define QT_HAS_INCLUDE(x) __has_include(x)