This is an archive of the discontinued LLVM Phabricator instance.

[-Wunsafe-buffer-usage] Add an unsafe gadget for pointer-arithmetic operations
ClosedPublic

Authored by ziqingluo-90 on Dec 2 2022, 3:03 PM.

Details

Summary

For -Wunsafe-buffer-usage diagnostics, we want to warn about pointer arithmetics since resulting pointers can be used to access buffers.
Therefore, I add an UnsafeGadget representing general pointer arithmetic operations.

Diff Detail

Event Timeline

ziqingluo-90 created this revision.Dec 2 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2022, 3:03 PM
Herald added a subscriber: rnkovacs. · View Herald Transcript
ziqingluo-90 requested review of this revision.Dec 2 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2022, 3:03 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NoQ added inline comments.Dec 8 2022, 6:21 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
319–320

Let's unhardcode the bind tags just like in the subscript patch?

Did a rebase and addressed the comment.

NoQ accepted this revision.Jan 3 2023, 1:24 PM

LGTM!

clang/lib/Analysis/UnsafeBufferUsage.cpp
354

It's pretty likely that it won't because we'll need a more specialized gadget for this.

This revision is now accepted and ready to land.Jan 3 2023, 1:24 PM
This revision was landed with ongoing or failed builds.Jan 4 2023, 5:02 PM
This revision was automatically updated to reflect the committed changes.