[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
================
@@ -18,8 +17,8 @@ extern "C" {
// SHARED-LABEL: define {{[^@]*}}@test_assign_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_assign_plain_arr_idx(struct Small *dest, struct Small arr[4]) {
*dest = arr[0];
----------------
hubert-reinterpretcast wrote:
I suggest splitting the tests so that one of the LHS or the RHS is always just a plain reference to a local variable of the struct type. That way, we can simplify the checks.
@tonykuttai, any thoughts on how much we can assume simply by checking for the handler call?
Also, @vasu-the-sharma can you make the struct type a union type under macro control and add extra RUN lines to test that?
https://github.com/llvm/llvm-project/pull/190739
More information about the cfe-commits
mailing list