This is an archive of the discontinued LLVM Phabricator instance.

[clang] disable P2266 simpler implicit moves under -fms-compatibility
ClosedPublic

Authored by mizvekov on Jul 6 2021, 5:31 PM.

Details

Summary

The Microsoft STL currently has some issues with P2266.
We disable it for now in that mode, but we might come back later with a
more targetted approach.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Diff Detail

Event Timeline

mizvekov requested review of this revision.Jul 6 2021, 5:31 PM
mizvekov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2021, 5:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thank you for working on this! I applied the patch locally and confirmed that it solves the issue at hand.

However, I'm not certain this is the right approach; what's the plan moving forward? This patch means that users of clang-cl will not get the simpler implicit moves. Once the STL gets fixed, then what? We can't remove this check for MS compat because then people using older STLs will go back to getting unacceptable compile errors and I'd hate to have to wait for long enough that old MSVC STLs have fallen out of circulation before enabling simpler implicit moves for clang-cl users.

Thank you for working on this! I applied the patch locally and confirmed that it solves the issue at hand.

However, I'm not certain this is the right approach; what's the plan moving forward? This patch means that users of clang-cl will not get the simpler implicit moves. Once the STL gets fixed, then what? We can't remove this check for MS compat because then people using older STLs will go back to getting unacceptable compile errors and I'd hate to have to wait for long enough that old MSVC STLs have fallen out of circulation before enabling simpler implicit moves for clang-cl users.

I had missed some important context that was in https://reviews.llvm.org/D99005#2860494, namely that this is just to get us back to a good state immediately but there will be further follow-up work to target just the problematic part of the MSVC STL. So long as the follow-up work happens, I think this patch gets us moving forward without causing a lot of churn. If we find that a more targeted approach isn't feasible for some reason, we'll still have to figure out what to do, but at least this enables the feature for users who can use it, which is great.

Can you add a test case to demonstrate the behavior with this patch under -fms-compatibility and some comments explaining what's going on (just in case anyone comes peeking while the work is happening)? I'd suggest adding a FIXME comment to SemaStmt.cpp as well, just to be safe, in case the follow-up work is delayed for some reason.

I agree with Aaron for the need of a test. At one point, we may wish to replace these calls with getLangOpts().isCompatibleWithMSVC or some similar inspection of MSCompatibilityVersion, but I acknowledge we can't do that until we figure out what the correct version IS!

Otherwise this seems like an appropriate temporary solution.

clang/lib/Frontend/InitPreprocessor.cpp
602

This isn't adding a 'tab' character here, is it?

Ping? Normally I wouldn't bother people so quickly, but this patch is addressing a major regression on trunk that had a revert request. We either need to get this landed ASAP or revert the original commit.

@aaron.ballman Yeah don't worry, having dinner, my hobby shift is starting soon though :-)

mizvekov updated this revision to Diff 357078.Jul 7 2021, 2:30 PM

Address review comments.

mizvekov marked an inline comment as done.Jul 7 2021, 2:32 PM
mizvekov added inline comments.
clang/lib/Frontend/InitPreprocessor.cpp
602

No, just four spaces. This was clean on my linter, and it passed all green on the buildbots, which have a clang-format check.

aaron.ballman accepted this revision.Jul 7 2021, 2:53 PM

LGTM, thank you!

This revision is now accepted and ready to land.Jul 7 2021, 2:53 PM
This revision was automatically updated to reflect the committed changes.
mizvekov marked an inline comment as done.