================
@@ -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(
----------------
erichkeane 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.
Right, my thought was to just disable it for this line.
> 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).
I'm actually amazed we don't have such a RAII container already! But I think
that is probably more than good here(and probably better than my suggestions).
BUT Diagnostic.h could very well get a `IgnoreAllWarningDiagRAII` object that
would be very useful I think elsewhere too.
https://github.com/llvm/llvm-project/pull/206579
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits