aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorZixu Wang <9819235+zixu-w@users.noreply.github.com>2023-12-07 17:40:58 -0800
committerGitHub <noreply@github.com>2023-12-07 17:40:58 -0800
commit6e1f19168bca7e3bd4eefda50ba03eac8441dbbf (patch)
tree17a62cfb3c1090fe3443ac56ee9437bf95b4bd27 /clang/lib/Frontend/CompilerInvocation.cpp
parentc502a81b439b68cb029e16ca9d444d897b5e7727 (diff)
downloadllvm-6e1f19168bca7e3bd4eefda50ba03eac8441dbbf.zip
llvm-6e1f19168bca7e3bd4eefda50ba03eac8441dbbf.tar.gz
llvm-6e1f19168bca7e3bd4eefda50ba03eac8441dbbf.tar.bz2
[clang][PP] Add extension to predefine target OS macros (#74676)
Add an extension feature `define-target-os-macros` that enables clang to provide definitions of common TARGET_OS_* conditional macros. The extension is enabled in the Darwin toolchain driver.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 56de0f7..b33bdad 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4365,6 +4365,9 @@ static void GeneratePreprocessorArgs(const PreprocessorOptions &Opts,
if (Opts.SourceDateEpoch)
GenerateArg(Consumer, OPT_source_date_epoch, Twine(*Opts.SourceDateEpoch));
+ if (Opts.DefineTargetOSMacros)
+ GenerateArg(Consumer, OPT_fdefine_target_os_macros);
+
// Don't handle LexEditorPlaceholders. It is implied by the action that is
// generated elsewhere.
}
@@ -4463,6 +4466,10 @@ static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
if (isStrictlyPreprocessorAction(Action))
Opts.LexEditorPlaceholders = false;
+ Opts.DefineTargetOSMacros =
+ Args.hasFlag(OPT_fdefine_target_os_macros,
+ OPT_fno_define_target_os_macros, Opts.DefineTargetOSMacros);
+
return Diags.getNumErrors() == NumErrorsBefore;
}