[clang] [clang][CodeGen] Fix MSVC ABI for classes with a deleted copy assignment operator (PR #90547)
Max Winkler via cfe-commits
cfe-commits at lists.llvm.org
Fri May 3 18:30:04 PDT 2024
================
@@ -1131,13 +1132,18 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
return false;
if (RD->hasNonTrivialCopyAssignment())
return false;
+ if (RD->needsImplicitCopyAssignment() && !RD->hasSimpleCopyAssignment())
----------------
MaxEW707 wrote:
Correct. The two main cases we need to cover are the following.
I'll make a comment to explain the logic.
```
struct Test
{
Test& operator=(const Test&) = delete;
int x;
};
```
In this case `DefaultedCopyAssignmentIsDeleted` is `false` on the `CXXRecordDecl`. So we need to query `isDeleted` on the copy assignment operator `CXXMethodDecl`.
```
struct Test
{
int& x;
};
```
In this case we have no `CXXMethodDecl` for the copy assignment operator so we need to check if `DefaultedCopyAssignmentIsDeleted` is `true` on the `CXXRecordDecl`.
https://github.com/llvm/llvm-project/pull/90547
More information about the cfe-commits
mailing list