This is an archive of the discontinued LLVM Phabricator instance.

[-Wunsafe-buffer-usage] Handle pointer assignments only in unspecified contexts
ClosedPublic

Authored by t-rasmud on May 17 2023, 1:03 PM.

Details

Summary

This patch ensures that the assignment statements responsible for grouping variables (as in https://reviews.llvm.org/D145739) are in an unspecified context (and not in arguments of call expressions, conditions of if statements, etc)

Diff Detail

Event Timeline

t-rasmud created this revision.May 17 2023, 1:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 1:03 PM
t-rasmud requested review of this revision.May 17 2023, 1:03 PM
NoQ added a comment.May 17 2023, 1:10 PM

Great, looks correct to me!

It's probably better to squash this into D145739 so that to avoid the temporary incorrectness. (I hope it won't cause too many merge conflicts.)

clang/lib/Analysis/UnsafeBufferUsage.cpp
194–195

I think we need better comments for all three of those 😅 Like, explain what we mean by "unspecified" and write down the exact requirements on types and value kinds of replacement expressions.

ziqingluo-90 added inline comments.May 17 2023, 4:39 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
197

All the names of our contexts start with "Unspecified-". So maybe adding "Untyped" to the name makes it more clear.

t-rasmud updated this revision to Diff 523490.May 18 2023, 11:56 AM

Address comments about documentation.

t-rasmud marked 2 inline comments as done.May 18 2023, 11:56 AM
t-rasmud retitled this revision from Handle pointer assignments only in unspecified contexts to [-Wunsafe-buffer-usage] Handle pointer assignments only in unspecified contexts.May 18 2023, 11:59 AM
t-rasmud edited the summary of this revision. (Show Details)May 18 2023, 12:00 PM
NoQ added inline comments.May 18 2023, 12:48 PM
clang/lib/Analysis/UnsafeBufferUsage.cpp
197

Yeah these context names are terrible and that's entirely on me 😅

NoQ accepted this revision.May 18 2023, 12:49 PM

LGTM!

This revision is now accepted and ready to land.May 18 2023, 12:49 PM