[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)
Anthony Tran via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 11 13:26:59 PDT 2025
================
@@ -730,6 +754,18 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
options::OPT_fno_sanitize_recover_EQ);
RecoverableKinds &= Kinds;
+ // Parse any -fsanitize-trap=<...> flags the user provided, then
+ // diagnose any which do not have a matching -fsanitize=<...>
+ if (DiagnoseErrors) {
+ SanitizerMask ExplicitTrap = parseSanitizeArgs(
----------------
anthonyhatran wrote:
I tried that, but `parseSanitizeArgs` adds in the `SanitizerMask`, `TrappingDefault`, so it enables these bits: `SanitizerKind::CFI | SanitizerKind::LocalBounds` by default. This means more warnings are emitted than what the user actually entered. I could work around this, but I thought my approach would be cleaner. Let me know if you would prefer the `parseSanitizeTrapArgs` approach though.
https://github.com/llvm/llvm-project/pull/147997
More information about the cfe-commits
mailing list