[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

Thurston Dang via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 24 18:16:42 PDT 2025


================
@@ -2595,6 +2595,16 @@ def fsanitize_undefined_trap_on_error
 def fno_sanitize_undefined_trap_on_error
     : Flag<["-"], "fno-sanitize-undefined-trap-on-error">, Group<f_clang_Group>,
       Alias<fno_sanitize_trap_EQ>, AliasArgs<["undefined"]>;
+defm sanitize_annotate_debug_info_traps
+    : BoolFOption<
+          "sanitize-annotate-debug-info-traps",
----------------
thurstond wrote:

I would much prefer `-fsanitize-debug-trap-reasons`.

While I agree that there is a degree of confusion from "somewhat related flags have completely different flags", I think it is a lesser evil than potentially confusing users into thinking that the flags are interconnected when they are not.

For example:
```
clang -fsanitize-annotate-debug-info=integer
      -fsanitize-annotate-debug-info-traps
```
evokes the idea to me that `-fsanitize-annotate-debug-info-traps` would only apply to integer checks, when actually they operate independently. (This is somewhat similar to the problem tackled by Anthony's WIP patch in https://github.com/llvm/llvm-project/pull/147997)

The other reason (pun not intended) that I like `-fsanitize-debug-trap-reasons` is that "trap reasons" is the most concise way to describe this patch (e.g., it's in the patch title), so it's good to have it as part of the flag name.

https://github.com/llvm/llvm-project/pull/145967


More information about the cfe-commits mailing list