This is an archive of the discontinued LLVM Phabricator instance.

[Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode
ClosedPublic

Authored by ningvin on Sep 6 2022, 7:00 AM.

Details

Summary

When running in MSVC compatibility mode, previously no deprecated copy operation warnings (enabled by -Wdeprecated-copy) were raised. This restriction was already in place when the deprecated copy warning was first introduced.

This patch removes said restriction so that deprecated copy warnings, if enabled, are also raised in MSVC compatibility mode. The reasoning here being that these warnings are still useful when running in MSVC compatibility mode and also have to be semi-explicitly enabled in the first place (using -Wdeprecated-copy, -Wdeprecated or -Wextra).

Diff Detail

Event Timeline

ningvin created this revision.Sep 6 2022, 7:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2022, 7:00 AM
ningvin requested review of this revision.Sep 6 2022, 7:00 AM

Got any pointers to the commits/authors that added this functionality in the first place? (would be good to have any review history, etc, to check against the change here)

@hansw for windows compatibility discussions

Got any pointers to the commits/authors that added this functionality in the first place? (would be good to have any review history, etc, to check against the change here)

That would be @rsmith if I am not mistaken with https://reviews.llvm.org/rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad (not sure how to best link to commits/changes in phabricator).

Got any pointers to the commits/authors that added this functionality in the first place? (would be good to have any review history, etc, to check against the change here)

That would be @rsmith if I am not mistaken

Ah, indeed - thanks for the context. (I almost thought it wasn't in that patch, because there was no mention of "MSVC" there - but I see now it was "MicrosoftMode" back then)

with https://reviews.llvm.org/rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad (not sure how to best link to commits/changes in phabricator).

That works, you can also take the hash with the rG prefix and use that: rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad and that works too.

hans added a subscriber: hans.Sep 9 2022, 5:03 AM

For more context, this was initially raised in https://discourse.llvm.org/t/why-is-the-deprecated-copy-warning-suppressed-in-msvc-compatibility-mode/65085/1

I'm not aware of any reason for the special microsoft mode case, but it's very possible that I'm missing something.

That works, you can also take the hash with the rG prefix and use that: rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad and that works too.

Didn't know that, thanks!

Oh yes sorry, I should have linked to that.

That works, you can also take the hash with the rG prefix and use that: rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad and that works too.

Didn't know that, thanks!

Oh yes sorry, I should have linked to that.

ah, *thumbs up* then, though I'll probably leave it to @hansw to review so he's aware of when this goes in/will have context in case any fallout is observed on the Windows side of things

hans added inline comments.Sep 9 2022, 12:24 PM
clang/test/SemaCXX/deprecated-copy-msvc.cpp
1 ↗(On Diff #458154)

Can we just add a RUN line with -fms-compatibility to clang/test/SemaCXX/deprecated-copy.cpp ?

ningvin added a comment.EditedSep 9 2022, 12:48 PM

That is indeed a better option than to simply copy the test case. I did some more digging and found the following test cases which reference the deprecated copy warning (all located under clang/test/SemaCXX/):

I suppose adding the respective RUN lines with -fms-compatibility to all of them is the way to go. I will try that tomorrow to see if something breaks and then update this patch.

ningvin updated this revision to Diff 459277.Sep 10 2022, 3:21 AM

I added the respective RUN lines to the different test cases, did not seem to break anything on my end.

hans accepted this revision.Sep 12 2022, 7:57 AM

lgtm

Maybe give Richard another day or two in case he wants to take a look, but otherwise landing this and seeing if there are any problems we didn't know about sounds good to me.

This revision is now accepted and ready to land.Sep 12 2022, 7:57 AM

@hans just to clarify as I do not have commit access: do I still need to perform some action?

hans added a comment.Sep 14 2022, 10:49 AM

@hans just to clarify as I do not have commit access: do I still need to perform some action?

Ah, thanks for letting me know. I've committed on your behalf as https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28

Ah, thanks for letting me know. I've committed on your behalf as https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28

Sweet, thanks a lot :-)