[clang] 1d68eca - [clang] fix oops: enable implicit moves in MSVC compatibility mode
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 20 14:32:14 PDT 2021
Author: Matheus Izvekov
Date: 2021-07-20T23:32:05+02:00
New Revision: 1d68ecafd6ad9ba8857c78e567abbc58810329c1
URL: https://github.com/llvm/llvm-project/commit/1d68ecafd6ad9ba8857c78e567abbc58810329c1
DIFF: https://github.com/llvm/llvm-project/commit/1d68ecafd6ad9ba8857c78e567abbc58810329c1.diff
LOG: [clang] fix oops: enable implicit moves in MSVC compatibility mode
When disabling simpler implicit moves in MSVC compatibility mode as
a workaround in D105518, we forgot to make the opposite change and
enable regular (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>
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D106303
Added:
Modified:
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 643dde437fc94..2ae27de9b2079 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3483,7 +3483,12 @@ ExprResult
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;
diff --git a/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp b/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
index 2143c0535e606..07db9b8333fa6 100644
--- a/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
+++ b/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -48,3 +48,5 @@ void test5() try {
throw x; // new-error {{no matching constructor for initialization}}
} catch (...) {
}
+
+MoveOnly test6(MoveOnly x) { return x; }
More information about the cfe-commits
mailing list