[PATCH] D144304: [WIP][-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment
Ziqing Luo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 17 15:51:08 PST 2023
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: jkorous, NoQ, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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 `span` type,
we generate fix-its that transform `e` to `(DRE = DRE.subspan(1)).data()`.
For reference, the UPC is currently defined as
- 1. an argument of a function call (except the callee has [[unsafe_buffer_usage]] attribute), or
- 2. the operand of a cast-to-(Integer or Boolean) operation; or
- 3. the operand of a pointer subtraction operation; or
- 4. the operand of a pointer comparison operation;
We may extend the definition of UPC by adding more cases later.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144304
Files:
clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144304.498515.patch
Type: text/x-patch
Size: 6036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230217/5f0c140b/attachment.bin>
More information about the cfe-commits
mailing list