[clang] 75e4438 - [ubsan] Change "Type mismatch in operation" trap reason to "Alignment, null, or object-size error" (#169752)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 27 10:03:30 PST 2025
Author: Thurston Dang
Date: 2025-11-27T10:03:25-08:00
New Revision: 75e4438b57eb7ac2e1cdd1bcba3368bddd81d0c4
URL: https://github.com/llvm/llvm-project/commit/75e4438b57eb7ac2e1cdd1bcba3368bddd81d0c4
DIFF: https://github.com/llvm/llvm-project/commit/75e4438b57eb7ac2e1cdd1bcba3368bddd81d0c4.diff
LOG: [ubsan] Change "Type mismatch in operation" trap reason to "Alignment, null, or object-size error" (#169752)
I originally proposed this rewording when trap reasons were introduced
in
https://github.com/llvm/llvm-project/pull/145967#discussion_r2196212344.
This was not adopted because there was a counter-proposal to split the
enum; however, that work appears to have stalled
(https://github.com/llvm/llvm-project/pull/151243). In the meantime,
there has been an additional datapoint that the current wording is
confusing to users. Thus, let's reword it now to prevent further
confusion.
Added:
Modified:
clang/lib/CodeGen/SanitizerHandler.h
clang/test/DebugInfo/Generic/ubsan-trap-reason-type-mismatch.c
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/SanitizerHandler.h b/clang/lib/CodeGen/SanitizerHandler.h
index a66e7ab354eb2..871e17c22d3fa 100644
--- a/clang/lib/CodeGen/SanitizerHandler.h
+++ b/clang/lib/CodeGen/SanitizerHandler.h
@@ -64,7 +64,7 @@
SANITIZER_CHECK(SubOverflow, sub_overflow, 0, \
"Integer subtraction overflowed") \
SANITIZER_CHECK(TypeMismatch, type_mismatch, 1, \
- "Type mismatch in operation") \
+ "Alignment, null, or object-size error") \
SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0, \
"Alignment assumption violated") \
SANITIZER_CHECK( \
diff --git a/clang/test/DebugInfo/Generic/ubsan-trap-reason-type-mismatch.c b/clang/test/DebugInfo/Generic/ubsan-trap-reason-type-mismatch.c
index 802ec91b53a0d..5960930c04171 100644
--- a/clang/test/DebugInfo/Generic/ubsan-trap-reason-type-mismatch.c
+++ b/clang/test/DebugInfo/Generic/ubsan-trap-reason-type-mismatch.c
@@ -6,4 +6,4 @@ int type_mismatch(int *p) { return *p; }
// CHECK-LABEL: @type_mismatch
// CHECK: call void @llvm.ubsantrap(i8 22) {{.*}}!dbg [[LOC:![0-9]+]]
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
-// CHECK: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$Type mismatch in operation"
+// CHECK: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$Alignment, null, or object-size error"
More information about the cfe-commits
mailing list