This is an archive of the discontinued LLVM Phabricator instance.

Fix #58958 on github
ClosedPublic

Authored by krsch on Nov 21 2022, 6:13 AM.

Details

Summary

Do not suggest to take the address of a const pointer to get void*

Diff Detail

Event Timeline

krsch created this revision.Nov 21 2022, 6:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 6:13 AM
Herald added a subscriber: rnkovacs. · View Herald Transcript
krsch requested review of this revision.Nov 21 2022, 6:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 6:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dblaikie added inline comments.
clang/lib/Sema/SemaFixItUtils.cpp
135–140

Do we need to check the constness here? What other cases does it come up? Like maybe if it's volatile we'd want to do the same thing?

krsch added inline comments.Nov 21 2022, 1:11 PM
clang/lib/Sema/SemaFixItUtils.cpp
135–140

For volatile pointers the same bad suggestion appears. Maybe I should remove the isConstQualified check as IIRC all non-const non-volatile pointers can be implicitly converted to void* so the suggestion would not appear for them. Probably any suggestion to change T* to T** for casting to void* is unlikely to be correct.

xazax.hun added inline comments.Nov 21 2022, 1:29 PM
clang/lib/Sema/SemaFixItUtils.cpp
136–137

Nit: we usually try to avoid repeating types.

136–137

Although the rest of the function clearly does not follow this guideline so feel free to leave it as is.

dblaikie added inline comments.Nov 21 2022, 2:15 PM
clang/lib/Sema/SemaFixItUtils.cpp
135–140

yeah, that's what I was thinking - probably remove the const check and maybe add a test case showing the volatile case too

krsch updated this revision to Diff 477166.Nov 22 2022, 6:18 AM

Check any pointer, not just const. Test for volatile

krsch added inline comments.Nov 22 2022, 6:19 AM
clang/lib/Sema/SemaFixItUtils.cpp
136–137

The rest of the function was made this way in commit 1e95bc0f4063e, so I thought this is the style for this part of the codebase

dblaikie accepted this revision.Nov 22 2022, 9:44 AM

Looks good, thanks!

Do you need me to commit this for you, or can you commit it yourself?

This revision is now accepted and ready to land.Nov 22 2022, 9:44 AM

please make the title of the commit say what the commit is actually doing rather than only reference a bug number, the bug number should be in the description

Please commit it yourself as I don't have a commit access. This is my first patch here.

Do you need me to commit this for you, or can you commit it yourself?

krsch added a comment.Nov 23 2022, 2:42 AM

Should I change the title myself or you can change it during commit? If it's on me, how do I change it? git commit --amend; arc diff?

Should I change the title myself or you can change it during commit? If it's on me, how do I change it? git commit --amend; arc diff?

phabricator isn't very elegant, locally changing the commit message doesn't propagate to phabricator even with arc diff, you have to change it on phabricator, then to propagate it locally arc amend

Should I change the title myself or you can change it during commit? If it's on me, how do I change it? git commit --amend; arc diff?

phabricator isn't very elegant, locally changing the commit message doesn't propagate to phabricator even with arc diff, you have to change it on phabricator, then to propagate it locally arc amend

That's OK, I'll just change it when I commit - I've got something lined up but didn't get it through yesterday.