[clang] [Clang][Driver] Emit warning when -fsanitize-trap=undefined is passed without -fsanitize=undefined (PR #147997)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 09:35:30 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Anthony Tran (anthonyhatran)
<details>
<summary>Changes</summary>
Part of a GSoC 2025 Project
---
Full diff: https://github.com/llvm/llvm-project/pull/147997.diff
2 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+5)
- (modified) clang/include/clang/Basic/DiagnosticGroups.td (+3)
``````````diff
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">;
``````````
</details>
https://github.com/llvm/llvm-project/pull/147997
More information about the cfe-commits
mailing list