[clang] [clang][Sema] Track trivial-relocatability as a type trait (PR #84621)
Barry Revzin via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 5 08:46:04 PDT 2024
================
@@ -857,8 +881,13 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().HasDeclaredCopyAssignmentWithConstParam = true;
}
- if (Method->isMoveAssignmentOperator())
+ if (Method->isMoveAssignmentOperator()) {
SMKind |= SMF_MoveAssignment;
+ }
+
+ if (Method->isUserProvided() &&
+ (Method->isCopyAssignment() || Method->isMoveAssignment()))
+ data().IsNaturallyTriviallyRelocatable = false;
----------------
brevzin wrote:
> Only "stupid types" will have a trivial copy/move constructor and a non-trivial assignment operator that does something different.
One such type is `std::tuple<int&>`. As far as I can tell, the way the different papers handle this type is:
* P1144: not trivially relocatable (because the copy/move assignment operator is user-provided)
* P2786: trivially relocatable (because we only care about move construction, and that one is defaulted)
I don't actually know what goes wrong (if anything) if you make `tuple<int&>` trivially relocatable, but at least that's a nice concrete example to think about.
https://github.com/llvm/llvm-project/pull/84621
More information about the cfe-commits
mailing list