[all-commits] [llvm/llvm-project] 6fce42: [-Wunsafe-buffer-usage] Add fixits for array to po...
jkorous-apple via All-commits
all-commits at lists.llvm.org
Wed Feb 14 19:03:49 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f
https://github.com/llvm/llvm-project/commit/6fce42f89a2c3f12b019bd3d7fef3e8db2d4671f
Author: jkorous-apple <32549412+jkorous-apple at users.noreply.github.com>
Date: 2024-02-14 (Wed, 14 Feb 2024)
Changed paths:
M clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
M clang/lib/Analysis/UnsafeBufferUsage.cpp
M clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
A clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-array-assign-to-ptr.cpp
Log Message:
-----------
[-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.
More information about the All-commits
mailing list