[UBSan] add pointer/array access checks for aggregate assignment/initialization operands (#190739)
This PR adds UbSan `null`, `alignment`, and `array-bounds` checks for
aggregate copy operations.
When copying scalar types, clang emits `null`/`alignment` checks via
`EmitCheckedLValue`. However, aggregate copies used `EmitLValue`,
skipping these checks entirely.
Code changes:
- `CGExprAgg.cpp`: `EmitCheckedLValue` in `EmitAggLoadOfLValue` (RHS
check)
- `CGExprAgg.cpp`: `EmitCheckedLValue` in `VisitBinAssign` (LHS check)
- `CGClass.cpp`: `EmitCheckedLValue` for trivial copy/move constructor
arg
- `CGExprCXX.cpp`: `EmitCheckedLValue` for trivial `operator=` RHS
Test updates:
- `ubsan-aggregate-null-align.c`:
- 4 cases with IR patterns for LHS/RHS
- Other cases verify handler call only
- Array bounds condition check for past-the-end
- Union type under `USE_UNION` macro
- `ubsan-new-checks.cpp`: `func_15` updated to use local variable as
source, preserving original CHECK-NOT guard against extra alignment
checks
---------
Co-authored-by: vasu-ibm <Vasu.Sharma2@ibm.com>
Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com>