================
@@ -15383,6 +15401,31 @@ static void diagnoseDeprecatedCopyOperation(Sema &S,
CXXMethodDecl *CopyOp) {
}
}
+// A defaulted copy or move assignment operator for a union copies the object
+// representation as if by a memcpy, the same way the defaulted union copy
+// constructor does. The memberwise loops in DefineImplicitCopyAssignment and
+// DefineImplicitMoveAssignment skip union members, so the whole-object copy is
+// emitted here instead. Marks AssignOp invalid and returns false on failure.
+static bool buildUnionAssignmentCopy(Sema &S, SourceLocation Loc,
+ CXXRecordDecl *ClassDecl,
+ std::optional<RefBuilder> &ExplicitObject,
+ std::optional<DerefBuilder> &DerefThis,
+ const ExprBuilder &From,
+ CXXMethodDecl *AssignOp,
+ SmallVectorImpl<Stmt *> &Statements) {
+ ExprBuilder &To = ExplicitObject ? static_cast<ExprBuilder
&>(*ExplicitObject)
+ : static_cast<ExprBuilder &>(*DerefThis);
+ StmtResult Copy = buildMemcpyForAssignmentOp(
----------------
AaronBallman wrote:
We actually do that hack with HTML rewriting; I think we'd want an RAII object
to restore the old diagnostics when we're done, though.
We only want to suppress warnings though, right? e.g.,
`DiagnosticsEngine::setIgnoreAllWarnings()` would work as well (can
save/restore that instead of installing a whole new consumer).
https://github.com/llvm/llvm-project/pull/206579
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits