diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2020-11-16 12:17:29 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2020-11-18 10:35:38 +0100 |
commit | 2be569870486a2068667f4625723c0a7409f4c97 (patch) | |
tree | 7187da8456b78190fddcc53df65d6692403f6460 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 83a03867da128bf9410ae15eb451500ed8c800f5 (diff) | |
download | llvm-2be569870486a2068667f4625723c0a7409f4c97.zip llvm-2be569870486a2068667f4625723c0a7409f4c97.tar.gz llvm-2be569870486a2068667f4625723c0a7409f4c97.tar.bz2 |
[clang][cli] Add ability to make fixups to CompilerInvocation after option parsing
Depends on D83211
Reviewed By: Bigcheese
Original patch by Daniel Grumberg.
Differential Revision: https://reviews.llvm.org/D83298
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index a9bc48f..2ea1027 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -245,6 +245,17 @@ static T extractMaskValue(T KeyPath) { return KeyPath & Value; } +static void FixupInvocation(CompilerInvocation &Invocation) { + LangOptions &LangOpts = *Invocation.getLangOpts(); + DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts(); + CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts(); + CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument; + CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents; + CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents; + + llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes); +} + //===----------------------------------------------------------------------===// // Deserialization (from args) //===----------------------------------------------------------------------===// @@ -1189,16 +1200,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.InstrumentFunctionEntryBare = Args.hasArg(OPT_finstrument_function_entry_bare); - Opts.XRayInstrumentFunctions = - Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); Opts.XRayInstructionThreshold = getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags); - Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops); - Opts.XRayOmitFunctionIndex = Args.hasArg(OPT_fno_xray_function_index); Opts.XRayTotalFunctionGroups = getLastArgIntValue(Args, OPT_fxray_function_groups, 1, Diags); Opts.XRaySelectedFunctionGroup = @@ -3447,13 +3450,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, systemBlacklists.begin(), systemBlacklists.end()); - // -fxray-instrument - Opts.XRayInstrument = Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); - // -fxray-{always,never}-instrument= filenames. Opts.XRayAlwaysInstrumentFiles = Args.getAllArgValues(OPT_fxray_always_instrument); @@ -3827,9 +3823,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, } Success &= Res.parseSimpleArgs(Args, Diags); - - llvm::sys::Process::UseANSIEscapeCodes( - Res.DiagnosticOpts->UseANSIEscapeCodes); + FixupInvocation(Res); Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags); Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args); |