[all-commits] [llvm/llvm-project] 762af1: [-Wunsafe-buffer-usage] Add a Fixable for pointer ...
Ziqing Luo via All-commits
all-commits at lists.llvm.org
Wed Apr 12 15:00:32 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 762af11d4c5d0bd1e76f23a07087773db09ef17d
https://github.com/llvm/llvm-project/commit/762af11d4c5d0bd1e76f23a07087773db09ef17d
Author: Ziqing Luo <ziqing at udel.edu>
Date: 2023-04-12 (Wed, 12 Apr 2023)
Changed paths:
M clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
M clang/lib/Analysis/UnsafeBufferUsage.cpp
A clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
Log Message:
-----------
[-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment
For a pointer type expression `e` of the form `++DRE`, if `e` is under
an Unspecified Pointer Context (UPC) and `DRE` is suppose to be
transformed to have std:span type, we generate fix-its that transform `e` to
`(DRE = DRE.subspan(1)).data()`.
For reference, `e` is in an UPC if `e` is
- an argument of a function call (except the callee has [[unsafe_buffer_usage]] attribute), or
- the operand of a cast-to-(Integer or Boolean) operation; or
- the operand of a pointer subtraction operation; or
- the operand of a pointer comparison operation;
We may extend the definition of UPC by adding more cases later.
Reviewed by: NoQ (Artem Dergachev)
Differential revision: https://reviews.llvm.org/D144304
More information about the All-commits
mailing list