This is an archive of the discontinued LLVM Phabricator instance.

Fix noderef for array member of deref expr
ClosedPublic

Authored by thejh on Nov 25 2020, 3:55 PM.

Details

Summary

Given an attribute((noderef)) pointer "p" to the struct

struct s { int a[2]; };

ensure that the following expressions are treated the same way by the
noderef logic:

p->a
(*p).a

Until now, the first expression would be treated correctly (nothing is
added to PossibleDerefs because CheckMemberAccessOfNoDeref() bails out
on array members), but the second expression would incorrectly warn
because "*p" creates a PossibleDerefs entry.

Handle this case the same way as for the AddrOf operator.

Diff Detail

Event Timeline

thejh created this revision.Nov 25 2020, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2020, 3:55 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thejh requested review of this revision.Nov 25 2020, 3:55 PM
leonardchan accepted this revision.Nov 25 2020, 4:30 PM

Thanks for catching this. LGTM

This revision is now accepted and ready to land.Nov 25 2020, 4:30 PM
thejh added a comment.Dec 1 2020, 7:15 AM

@leonardchan I don't have commit access; can you land this change and D92141 for me?

Sorry. I accidentally missed this in my emails. Will commit these.

leonardchan closed this revision.Dec 7 2020, 2:42 PM

Committed in 155fca3cae275562e626d3e4fbfac70b4b75d2e7. (Sorry, I forgot to change the author email in the commit)

thejh added a comment.Dec 7 2020, 2:51 PM

Thanks! :)