To add two new unique cases to the Unspecified Pointer Context (UPC):
- A pointer being casted to a boolean value is in a UPC;
- A pointer participating in pointer subtraction is in a UPC.
Paths
| Differential D144064
[-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions ClosedPublic Authored by ziqingluo-90 on Feb 14 2023, 6:15 PM.
Details Summary To add two new unique cases to the Unspecified Pointer Context (UPC):
Diff Detail Event Timelineziqingluo-90 added a child revision: D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment.Feb 17 2023, 3:51 PM ziqingluo-90 retitled this revision from [WIP][-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions to [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions.Feb 22 2023, 2:38 PM
Comment Actions Looks great overall!
This revision is now accepted and ready to land.Apr 10 2023, 11:30 AM This revision was landed with ongoing or failed builds.Apr 11 2023, 3:10 PM Closed by commit rG88f7f018e23b: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or… (authored by ziqingluo-90). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 506733 clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
|
I don't understand why we are special handling only pointer subtraction here. Won't pointer addition be also considered UPC? If so, can we just add it to this patch.