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

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 23 04:02:26 PDT 2025


================
@@ -0,0 +1,22 @@
+// FIXME: Currently, a nullptr check is in place before emitting a UBSan trap reason inside 
+// CodeGenFunction::EmitTrapCheck. This is disadvantageous because we may not emit a trap 
+// message in all cases where a trap message should be emitted. The check was added to prevent
+// a crash caused by a call to EmitTypeCheck in CodeGenFunction::StartFunction. The TypeMismatch 
+// handler is triggered and tries to attach itself to the debug-info location, but StartFunction 
+// only sets the debug-info location after the prologue code-gen is done resulting in a crash.
----------------
Michael137 wrote:

Don't think we need to include all these details. Lets rephrase it to:
```suggestion**
// FIXME: We should emit a trap message for this case too. But sometimes Clang will emit a ubsan trap into the prologue of a function, at which point the debug-info locations haven't been set up yet and can't hook up our artificial inline frame.
```

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


More information about the cfe-commits mailing list