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

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 11 11:22:25 PDT 2025


vitalybuka wrote:

> @fmayer
> 
> > I would prefer this to be behind a flag (not necessarily in this PR), even if it's default turned on. People might not want synthetic frames added to their debug information and the top frame to point to the real code; also as this somewhat overlaps with the logic of `-fsanitize-annotate-debug-info`, with a flag people can choose which one they want.
> 
> Do you have a concrete use case where it would be problematic to emit the trap reasons in debug info as the patch does? We are not opposed to adding a flag that allows it to be disabled (e.g. `-fno-sanitize-annotated-traps` or something similar) provided the trap reasons are emitted by default. That being said we don't want to implement things that won't be used. What use case(s) do you have in mind?

I am sure it will break some users how have some stack trace analyzers. Flag will unblock compiler upgrade for them.
So having a flag sounds reasonable to me. I don't have opinion what should be a default for that flag.

In this patch probaly (copt<> "defaut is off") is OK, and in followup patch copt -> clang flag.

Given that it's done for fsanitize-annotate-debug-info, should be easy, just "replay" that patch. However that patch includes per-sanitizer granularity, which may be not needed?



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


More information about the cfe-commits mailing list