[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 23 07:29:15 PDT 2025


================
@@ -4051,6 +4137,15 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
 
   llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
 
+  llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation();
+  llvm::StringRef Category = "UBSan Trap Reason";
----------------
delcypher wrote:

Given that `Category` is only used in one place I would be tempted to inline its use. I.e.

```
TrapLocation = getDebugInfo()->CreateTrapFailureMessageFor(
        TrapLocation,  "UBSan", TrapMessage);
```

I realize that might conflict more with the code in Apple's fork of Clang but I'm ok with this. Once we've handled the merge conflict we'll have a better sense of what follow up changes are needed to best resolve the conflict.

Nit: We may want to rename `UBSan Trap Reason`. I'm not sure it's necessary to mention `Trap` or `Reason`. I think `UBSan` or `Undefined Behavior Sanitizer` (if we wanted to be really verbose) would be sufficient.

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


More information about the cfe-commits mailing list