[clang] [Clang] Improve error for `-fsanitize=function/kcfi -mexecute-only` incompatibility (PR #118816)
Csanád Hajdú via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 7 03:01:23 PST 2024
================
@@ -418,8 +418,14 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
Add & NotAllowedWithExecuteOnly & ~DiagnosedKinds) {
if (DiagnoseErrors) {
std::string Desc = describeSanitizeArg(Arg, KindsToDiagnose);
- D.Diag(diag::err_drv_argument_not_allowed_with)
- << Desc << Triple.str();
+ llvm::opt::Arg *A = Args.getLastArgNoClaim(
+ options::OPT_mexecute_only, options::OPT_mno_execute_only);
+ if (A && A->getOption().matches(options::OPT_mexecute_only))
+ D.Diag(diag::err_drv_argument_not_allowed_with)
+ << Desc << A->getAsString(Args);
+ else
+ D.Diag(diag::err_drv_argument_not_allowed_with)
+ << Desc << Triple.str();
----------------
Il-Capitano wrote:
Maybe `diag::err_drv_unsupported_opt_for_target` would be a better diagnostic in this case? That would produce
```
error: unsupported option '-fsanitize=function' for target '<triple>'
```
https://github.com/llvm/llvm-project/pull/118816
More information about the cfe-commits
mailing list