[C++20][Modules][Driver][HU 4/N] Add fdirectives-only mode for preprocessing output.
authorIain Sandoe <iain@sandoe.co.uk>
Fri, 31 Jul 2020 09:44:12 +0000 (10:44 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 23 Apr 2022 13:43:07 +0000 (14:43 +0100)
commit9dc9b21488ee2bbf54e20807585a74a17a33fceb
treebdbcaca74355c6e3733c3a8a6ba54f0fc0845163
parentde8a65f787cc21252a989ca89d966b807b7d977c
[C++20][Modules][Driver][HU 4/N] Add fdirectives-only mode for preprocessing output.

When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

Thus it preserves macros that are still live after such processing.
This output can be consumed by a second compilation to produce a header unit.

We automatically invoke this (with -E) when we know that the job produces a
header unit so that the preprocessed output reflects the macros that will be
defined when the binary HU is emitted.

Differential Revision: https://reviews.llvm.org/D121591
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cxx20-fdirectives-only.cpp [new file with mode: 0644]