[clang] [UBSAN] add null, alignment and array-bounds checks (PR #190739)
VASU SHARMA via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 14 02:07:04 PDT 2026
vasu-the-sharma wrote:
> > > // CHECK: call void @__ubsan_handle_type_mismatch_v1_abort
> > > // CHECK: call void @llvm.memcpy
> >
> >
> > Update these to check for the labels (with the calls being on the next line). Note that this does not cover the array bounds checking.
>
> Considering that we are testing different operand/operation forms on purpose (because of varying compiler code paths), I think we should (to reduce test complexity) limit the explicit checking for the IR condition checks to single "exemplar" cases (e.g., one each of non-array LHS and RHS, one each of array LHS and RHS). For the other non-array-bounds checks, we could check just for the handler call. We need to check the IR condition check for the array bounds though (to accurately identify that one-past-the-end is considered not okay to access).
Done. The updated structure of the testcase is:
Exemplar cases (IR with CHECK-NEXT):
```
test_lhs_ptr - non-array LHS (C only)
test_lhs_array - array LHS (C only)
test_rhs_ptr - non-array RHS
test_rhs_array - array RHS
```
Simple cases (handler call only):
```
test_init_from_ptr, test_init_from_array
C++ forms: test_cxx_direct_init, test_cxx_brace_init, test_cxx_new
```
Array bounds (condition check):
`test_oob_rhs - checks br i1 and handler.out_of_bounds:`
I have also added `union` type under `macro` control with extra `RUN` line.
https://github.com/llvm/llvm-project/pull/190739
More information about the cfe-commits
mailing list