aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-07-16 07:11:13 -0700
committerGitHub <noreply@github.com>2025-07-16 07:11:13 -0700
commit76058c09071491fd097e85a0f5434b564dfad60b (patch)
treeef66ded553cc693136c1bd018f65166bc7e34b55 /clang/lib/Frontend/CompilerInvocation.cpp
parent1600450f9098e5c9cb26840bd53f1be8a2559b7d (diff)
downloadllvm-76058c09071491fd097e85a0f5434b564dfad60b.zip
llvm-76058c09071491fd097e85a0f5434b564dfad60b.tar.gz
llvm-76058c09071491fd097e85a0f5434b564dfad60b.tar.bz2
[clang] Move `ExceptionHandling` from `LangOptions` to `CodeGenOptions` (#148982)
This PR removes the command line parsing workaround introduced in https://github.com/llvm/llvm-project/pull/146342 by moving `LangOptions::ExceptionHandling` to `CodeGenOptions` that get parsed even for IR input. Additionally, this improves layering, where the codegen library now checks `CodeGenOptions` instead of `LangOptions` for exception handling. (This got enabled by https://github.com/llvm/llvm-project/pull/146422.)
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp45
1 files changed, 3 insertions, 42 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 56d10ce..6ab36d86 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -593,11 +593,11 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
CodeGenOpts.CodeModel = TargetOpts.CodeModel;
CodeGenOpts.LargeDataThreshold = TargetOpts.LargeDataThreshold;
- if (LangOpts.getExceptionHandling() !=
- LangOptions::ExceptionHandlingKind::None &&
+ if (CodeGenOpts.getExceptionHandling() !=
+ CodeGenOptions::ExceptionHandlingKind::None &&
T.isWindowsMSVCEnvironment())
Diags.Report(diag::err_fe_invalid_exception_model)
- << static_cast<unsigned>(LangOpts.getExceptionHandling()) << T.str();
+ << static_cast<unsigned>(CodeGenOpts.getExceptionHandling()) << T.str();
if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
Diags.Report(diag::warn_c_kext);
@@ -3713,23 +3713,6 @@ static StringRef GetInputKindName(InputKind IK) {
llvm_unreachable("unknown input language");
}
-static StringRef getExceptionHandlingName(unsigned EHK) {
- switch (static_cast<LangOptions::ExceptionHandlingKind>(EHK)) {
- case LangOptions::ExceptionHandlingKind::None:
- return "none";
- case LangOptions::ExceptionHandlingKind::DwarfCFI:
- return "dwarf";
- case LangOptions::ExceptionHandlingKind::SjLj:
- return "sjlj";
- case LangOptions::ExceptionHandlingKind::WinEH:
- return "seh";
- case LangOptions::ExceptionHandlingKind::Wasm:
- return "wasm";
- }
-
- llvm_unreachable("covered switch");
-}
-
void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
ArgumentConsumer Consumer,
const llvm::Triple &T,
@@ -3745,10 +3728,6 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Consumer, OPT_pic_is_pie);
for (StringRef Sanitizer : serializeSanitizerKinds(Opts.Sanitize))
GenerateArg(Consumer, OPT_fsanitize_EQ, Sanitizer);
- if (Opts.ExceptionHandling) {
- GenerateArg(Consumer, OPT_exception_model,
- getExceptionHandlingName(Opts.ExceptionHandling));
- }
return;
}
@@ -4057,24 +4036,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
Diags, Opts.Sanitize);
- if (const Arg *A = Args.getLastArg(options::OPT_exception_model)) {
- std::optional<LangOptions::ExceptionHandlingKind> EMValue =
- llvm::StringSwitch<std::optional<LangOptions::ExceptionHandlingKind>>(
- A->getValue())
- .Case("dwarf", LangOptions::ExceptionHandlingKind::DwarfCFI)
- .Case("sjlj", LangOptions::ExceptionHandlingKind::SjLj)
- .Case("seh", LangOptions::ExceptionHandlingKind::WinEH)
- .Case("wasm", LangOptions::ExceptionHandlingKind::Wasm)
- .Case("none", LangOptions::ExceptionHandlingKind::None)
- .Default(std::nullopt);
- if (EMValue) {
- Opts.ExceptionHandling = static_cast<unsigned>(*EMValue);
- } else {
- Diags.Report(diag::err_drv_invalid_value)
- << A->getAsString(Args) << A->getValue();
- }
- }
-
return Diags.getNumErrors() == NumErrorsBefore;
}