diff options
author | jkorous-apple <32549412+jkorous-apple@users.noreply.github.com> | 2024-02-14 19:03:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 19:03:37 -0800 |
commit | 6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f (patch) | |
tree | f8272d7422a4b52b33ffb27bf79e8e1a41906ace /clang/unittests/Format/ConfigParseTest.cpp | |
parent | a7982d5e7a16f681e80891a819bdf14dde928755 (diff) | |
download | llvm-6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f.zip llvm-6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f.tar.gz llvm-6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f.tar.bz2 |
[-Wunsafe-buffer-usage] Add fixits for array to pointer assignment (#81343)
Introducing CArrayToPtrAssignment gadget and implementing fixits for some cases
of array being assigned to pointer.
Key observations:
- const size array can be assigned to std::span and bounds are propagated
- const size array can't be on LHS of assignment
This means array to pointer assignment has no strategy implications.
Fixits are implemented for cases where one of the variables in the assignment is
safe. For assignment of a safe array to unsafe pointer we know that the RHS will
never be transformed since it's safe and can immediately emit the optimal fixit.
Similarly for assignment of unsafe array to safe pointer.
(Obviously this is not and can't be future-proof in regards to what
variables we consider unsafe and that is fine.)
Fixits for assignment from unsafe array to unsafe pointer (from Array to Span
strategy) are not implemented in this patch as that needs to be properly designed
first - we might possibly implement optimal fixits for partially transformed
cases, put both variables in a single fixit group or do something else.
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
0 files changed, 0 insertions, 0 deletions