[all-commits] [llvm/llvm-project] e06f35: [-Wunsafe-buffer-usage] Emit fixits for array deca...
jkorous-apple via All-commits
all-commits at lists.llvm.org
Tue Feb 13 14:31:23 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e06f3522cc55cec60084a1278109ab236ef7a3ee
https://github.com/llvm/llvm-project/commit/e06f3522cc55cec60084a1278109ab236ef7a3ee
Author: jkorous-apple <32549412+jkorous-apple at users.noreply.github.com>
Date: 2024-02-13 (Tue, 13 Feb 2024)
Changed paths:
M clang/lib/Analysis/UnsafeBufferUsage.cpp
M clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-access.cpp
Log Message:
-----------
[-Wunsafe-buffer-usage] Emit fixits for array decayed to pointer (#80347)
Covers cases where DeclRefExpr referring to a const-size array decays to a
pointer and is used "as a pointer" (e. g. passed to a pointer type
parameter).
Since std::array<T, N> doesn't implicitly convert to pointer to its element
type T* the cast needs to be done explicitly as part of the fixit
when we retrofit std::array to code that previously worked with constant
size array. std::array::data() method is used for the explicit
cast.
In terms of the fixit machine this covers the UPC(DRE) case for Array fixit strategy.
The emitted fixit inserts call to std::array::data() method similarly to
analogous fixit for Span strategy.
More information about the All-commits
mailing list