Don't inherit dllimport to inline move assignment operators
Current MSVC versions don't have move assignment operators, so we
can't rely on them being available in the dll. If we have the
definition, we can just use that directly. This breaks pointer
equality, but should work fine otherwise.
When there is an MSVC version that supports move assignment,
we can key this off the -fmsc-ver option.
http://reviews.llvm.org/D4105
llvm-svn: 210715
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index b5e6dc8..d9d4097 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -4377,11 +4377,24 @@
// specialization bases.
for (Decl *Member : Class->decls()) {
- if (!isa<CXXMethodDecl>(Member) && !isa<VarDecl>(Member))
+ VarDecl *VD = dyn_cast<VarDecl>(Member);
+ CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Member);
+
+ // Only methods and static fields inherit the attributes.
+ if (!VD && !MD)
continue;
- if (isa<CXXMethodDecl>(Member) && cast<CXXMethodDecl>(Member)->isDeleted())
+
+ // Don't process deleted methods.
+ if (MD && MD->isDeleted())
continue;
+ if (MD && MD->isMoveAssignmentOperator() && !ClassExported &&
+ MD->isInlined()) {
+ // Current MSVC versions don't export the move assignment operators, so
+ // don't attempt to import them if we have a definition.
+ continue;
+ }
+
if (InheritableAttr *MemberAttr = getDLLAttr(Member)) {
if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
!MemberAttr->isInherited()) {