[PATCH] D106303: [clang] fix oops: enable implicit moves in MSVC compatibility mode
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 19 13:58:10 PDT 2021
mizvekov created this revision.
mizvekov added a reviewer: aaron.ballman.
mizvekov published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
When disabling simpler implicit moves in MSVC compatibility mode as
a workaround in D105518 <https://reviews.llvm.org/D105518>, we forgot to make the opposite change and
enable regular (P1825 <https://reviews.llvm.org/P1825>) implicit moves in the same mode.
As a result, we were not doing any implicit moves at all. OOPS!
This fixes it and adds test for this.
This is a fix to a temporary workaround, there is ongoing
work to replace this, applying the workaround only to
system headers and the ::stl namespace.
Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106303
Files:
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===================================================================
--- clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -48,3 +48,5 @@
throw x; // new-error {{no matching constructor for initialization}}
} catch (...) {
}
+
+MoveOnly test6(MoveOnly x) { return x; }
Index: clang/lib/Sema/SemaStmt.cpp
===================================================================
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3483,7 +3483,12 @@
Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
const NamedReturnInfo &NRInfo,
Expr *Value) {
- if (!getLangOpts().CPlusPlus2b && NRInfo.isMoveEligible()) {
+ // FIXME: We force P1825 implicit moves here in msvc compatibility mode
+ // because we are disabling simpler implicit moves as a temporary
+ // work around, as the MSVC STL has issues with this change.
+ // We will come back later with a more targeted approach.
+ if ((!getLangOpts().CPlusPlus2b || getLangOpts().MSVCCompat) &&
+ NRInfo.isMoveEligible()) {
ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
CK_NoOp, Value, VK_XValue, FPOptionsOverride());
Expr *InitExpr = &AsRvalue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106303.359884.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210719/783d2ede/attachment.bin>
More information about the cfe-commits
mailing list