diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-07-31 10:44:12 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-03-28 07:38:22 +0100 |
commit | 85b1354098ba0a665fdd47204d0e53e63d09d9ab (patch) | |
tree | f285b11403f258c465f1c1fb04c250324905a0f6 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | ad57e10dbca2fdeff1448afc0aa1cf23d6df8736 (diff) | |
download | llvm-85b1354098ba0a665fdd47204d0e53e63d09d9ab.zip llvm-85b1354098ba0a665fdd47204d0e53e63d09d9ab.tar.gz llvm-85b1354098ba0a665fdd47204d0e53e63d09d9ab.tar.bz2 |
[C++20][Modules][HU 5/5] 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.
As such, it preserves defines and undefs of macros that are still live after
such processing. The intent is that this output could be consumed as input
to generate considered a C++20 header unit.
We strip out any (unused) defines that come from built-in, built-in-file or
command line; these are re-added when the preprocessed source is consumed.
Differential Revision: https://reviews.llvm.org/D121099
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5bb480a..b2221198 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4413,6 +4413,8 @@ static void GeneratePreprocessorOutputArgs( GenerateArg(Args, OPT_dM, SA); if (!Generate_dM && Opts.ShowMacros) GenerateArg(Args, OPT_dD, SA); + if (Opts.DirectivesOnly) + GenerateArg(Args, OPT_fdirectives_only, SA); } static bool ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, @@ -4435,6 +4437,7 @@ static bool ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, Opts.ShowCPP = isStrictlyPreprocessorAction(Action) && !Args.hasArg(OPT_dM); Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD); + Opts.DirectivesOnly = Args.hasArg(OPT_fdirectives_only); return Diags.getNumErrors() == NumErrorsBefore; } |