[clang] [Clang][Driver] Emit warning when -fsanitize-trap=undefined is passed without -fsanitize=undefined (PR #147997)
Anthony Tran via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 09:34:39 PDT 2025
https://github.com/anthonyhatran created https://github.com/llvm/llvm-project/pull/147997
Part of a GSoC 2025 Project
>From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001
From: Anthony Tran <anthonytran at anthonys-air.lan>
Date: Thu, 10 Jul 2025 09:18:50 -0700
Subject: [PATCH] Added warning and warning group for sanitizer argument
mismatch
---
clang/include/clang/Basic/DiagnosticDriverKinds.td | 5 +++++
clang/include/clang/Basic/DiagnosticGroups.td | 3 +++
2 files changed, 8 insertions(+)
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 34b6c0d7a8acd..49a8bdf06bda4 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -874,4 +874,9 @@ def warn_drv_openacc_without_cir
: Warning<"OpenACC directives will result in no runtime behavior; use "
"-fclangir to enable runtime effect">,
InGroup<SourceUsesOpenACC>;
+
+def warn_drv_sanitize_trap_mismatch : Warning<
+ "-fsanitize-trap=%0 has no effect because the matching sanitizer is not enabled; "
+ "did you mean to pass \"-fsanitize=%0\" as well?">,
+ InGroup<SanitizeTrapMismatch>;
}
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index f54a830b0103e..a79562cd9c2e0 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1752,3 +1752,6 @@ def ExplicitSpecializationStorageClass : DiagGroup<"explicit-specialization-stor
// A warning for options that enable a feature that is not yet complete
def ExperimentalOption : DiagGroup<"experimental-option">;
+
+// Warnings for sanitizer arguments
+def SanitizeTrapMismatch : DiagGroup<"sanitize-trap-mismatch">;
More information about the cfe-commits
mailing list