make -frewrite-includes also rewrite conditions in #if/#elif
authorLubos Lunak <l.lunak@centrum.cz>
Wed, 18 Sep 2019 19:09:41 +0000 (19:09 +0000)
committerLubos Lunak <l.lunak@centrum.cz>
Wed, 18 Sep 2019 19:09:41 +0000 (19:09 +0000)
commit533434fc728ad457533fac2c8c4ef7b8906dd05e
tree52a84682aa11d89302af2d50f41588961fa89640
parent5741d19f046f24450ebda3a421a8ce49043ad2b8
make -frewrite-includes also rewrite conditions in #if/#elif

Those conditions may use __has_include, which needs to be rewritten.
The existing code has already tried to rewrite just __has_include,
but it didn't work with macro expansion, so e.g. Qt's
"#define QT_HAS_INCLUDE(x) __has_include(x)" didn't get handled
properly. Since the preprocessor run knows what each condition evaluates
to, just rewrite the entire condition. This of course requires that
the -frewrite-include pass has the same setup as the following
compilation, but that has always been the requirement.

Differential Revision: https://reviews.llvm.org/D63508

llvm-svn: 372248
clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
clang/test/Frontend/rewrite-includes-conditions.c [new file with mode: 0644]
clang/test/Frontend/rewrite-includes.c
clang/test/Modules/preprocess-module.cpp