diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-15 09:59:19 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-15 10:15:58 +0100 |
commit | 56c5548d7f07f5853a2e40562db08dc2e56ece03 (patch) | |
tree | 204d736d9c03bc5051bc5742e1414aa308442fb4 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 573255b47eb9b210e74a1c620fee363dfaa52794 (diff) | |
download | llvm-56c5548d7f07f5853a2e40562db08dc2e56ece03.zip llvm-56c5548d7f07f5853a2e40562db08dc2e56ece03.tar.gz llvm-56c5548d7f07f5853a2e40562db08dc2e56ece03.tar.bz2 |
[clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option
This patch enables marshalling of the exception model options while enforcing their mutual exclusivity. The clang driver interface remains the same, this only affects the cc1 command line.
Depends on D93215.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D93216
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index e4058cf..23c4ad8 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -300,7 +300,7 @@ static Optional<std::string> normalizeTriple(OptSpecifier Opt, int TableIndex, template <typename T, typename U> static T mergeForwardValue(T KeyPath, U Value) { - return Value; + return static_cast<T>(Value); } template <typename T, typename U> static T mergeMaskValue(T KeyPath, U Value) { @@ -316,10 +316,12 @@ static T extractMaskValue(T KeyPath) { return KeyPath & Value; } -static void FixupInvocation(CompilerInvocation &Invocation) { +static void FixupInvocation(CompilerInvocation &Invocation, + DiagnosticsEngine &Diags) { LangOptions &LangOpts = *Invocation.getLangOpts(); DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts(); CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts(); + TargetOptions &TargetOpts = Invocation.getTargetOpts(); FrontendOptions &FrontendOpts = Invocation.getFrontendOpts(); CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument; CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents; @@ -327,6 +329,13 @@ static void FixupInvocation(CompilerInvocation &Invocation) { FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex; llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes); + + llvm::Triple T(TargetOpts.Triple); + + if (LangOpts.getExceptionHandling() != llvm::ExceptionHandling::None && + T.isWindowsMSVCEnvironment()) + Diags.Report(diag::err_fe_invalid_exception_model) + << static_cast<unsigned>(LangOpts.getExceptionHandling()) << T.str(); } //===----------------------------------------------------------------------===// @@ -2970,27 +2979,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, /*Default=*/false) && Opts.FixedPoint; - // Handle exception personalities - Arg *A = Args.getLastArg( - options::OPT_fsjlj_exceptions, options::OPT_fseh_exceptions, - options::OPT_fdwarf_exceptions, options::OPT_fwasm_exceptions); - if (A) { - const Option &Opt = A->getOption(); - llvm::Triple T(TargetOpts.Triple); - if (T.isWindowsMSVCEnvironment()) - Diags.Report(diag::err_fe_invalid_exception_model) - << Opt.getName() << T.str(); - - if (Opt.matches(options::OPT_fsjlj_exceptions)) - Opts.setExceptionHandling(llvm::ExceptionHandling::SjLj); - else if (Opt.matches(options::OPT_fseh_exceptions)) - Opts.setExceptionHandling(llvm::ExceptionHandling::WinEH); - else if (Opt.matches(options::OPT_fdwarf_exceptions)) - Opts.setExceptionHandling(llvm::ExceptionHandling::DwarfCFI); - else if (Opt.matches(options::OPT_fwasm_exceptions)) - Opts.setExceptionHandling(llvm::ExceptionHandling::Wasm); - } - Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind); Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp); @@ -3827,7 +3815,6 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, } Success &= Res.parseSimpleArgs(Args, Diags); - FixupInvocation(Res); Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags); ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args); @@ -3919,6 +3906,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Res.getCodeGenOpts().Argv0 = Argv0; Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs; + FixupInvocation(Res, Diags); + return Success; } @@ -4046,8 +4035,10 @@ void CompilerInvocation::generateCC1CommandLine( TABLE_INDEX) \ if ((FLAGS)&options::CC1Option) { \ [&](const auto &Extracted) { \ - if (ALWAYS_EMIT || (Extracted != ((IMPLIED_CHECK) ? (IMPLIED_VALUE) \ - : (DEFAULT_VALUE)))) \ + if (ALWAYS_EMIT || \ + (Extracted != \ + static_cast<decltype(this->KEYPATH)>( \ + (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE)))) \ DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted); \ }(EXTRACTOR(this->KEYPATH)); \ } |