[clang] [UBSAN] add null, alignment and array-bounds checks (PR #190739)
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 21:23:40 PDT 2026
================
@@ -38,15 +37,17 @@ __attribute__((noinline)) void test_init_plain_arr_idx(struct Small arr[4]) {
// SHARED-LABEL: define {{[^@]*}}@test_init_list_plain_arr_idx
// SHARED: [[ARR:%.*]] = load ptr, ptr %arr.addr
// SHARED: [[SRC:%.*]] = getelementptr inbounds %struct.Small, ptr [[ARR]], i64 0
-// SHARED-NOT: call void @__ubsan_handle_type_mismatch_v1_abort
-// SHARED-NOT: icmp ne ptr [[SRC]], null
+// SHARED: icmp ne ptr [[SRC]], null
+// SHARED: call void @__ubsan_handle_type_mismatch_v1_abort(
// SHARED: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %{{.*}}, ptr align 4 [[SRC]], i64 4, i1 false)
__attribute__((noinline)) void test_init_list_plain_arr_idx(struct Small arr[4]) {
struct Small a[] = {arr[0]};
}
+// Two ubsan calls: one for destination (c), one for source (arr[0])
// SHARED-LABEL: define {{[^@]*}}@test_nested_member_plain_arr_idx
-// SHARED: call void @__ubsan_handle_type_mismatch_v1_abort
+// SHARED: call void @__ubsan_handle_type_mismatch_v1_abort(
+// SHARED: call void @__ubsan_handle_type_mismatch_v1_abort(
----------------
hubert-reinterpretcast wrote:
Maybe we don't need this test? This test is different from other tests because of its LHS, which already had checking (likely from the member access operation).
https://github.com/llvm/llvm-project/pull/190739
More information about the cfe-commits
mailing list