This is an archive of the discontinued LLVM Phabricator instance.

[-Wunsafe-buffer-usage] Emit warnings about unsafe operations on arrays
AbandonedPublic

Authored by jkorous on Jan 9 2023, 9:46 PM.

Details

Diff Detail

Event Timeline

jkorous created this revision.Jan 9 2023, 9:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 9:46 PM
jkorous requested review of this revision.Jan 9 2023, 9:46 PM
NoQ added inline comments.Jan 10 2023, 5:57 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
331

Should this gadget receive the same treatment?

jkorous added inline comments.Jan 11 2023, 12:38 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
331

Oh! Yes, it definitely should!
@t-rasmud Can you please take over this patch?

jkorous added inline comments.Jan 12 2023, 12:31 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
331

I am sorry, I jumped the gun - the other gadget seems fine.
It looks like it already handles the situation since it expects an expression of pointer type (which reference to an array that decayed to a pointer totally is).

NoQ added inline comments.Jan 12 2023, 1:17 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
331

Yeah I think you're right, this gadget doesn't care about variable type, and the implicit array-to-pointer decay takes care of the expression type for us. Let's add a test for this anyway, just to acknowledge that this works, and then I think the patch is good to go!