@@ -4676,7 +4676,7 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
4676
4676
OCE && OCE->isAssignmentOp ()) {
4677
4677
// Just like with regular assignments, we need to special-case assignment
4678
4678
// operators here and evaluate the RHS (the second arg) before the LHS (the
4679
- // first arg. We fix this by using a Flip op later.
4679
+ // first arg) . We fix this by using a Flip op later.
4680
4680
assert (Args.size () == 2 );
4681
4681
IsAssignmentOperatorCall = true ;
4682
4682
std::reverse (Args.begin (), Args.end ());
@@ -5664,6 +5664,21 @@ bool Compiler<Emitter>::compileDestructor(const CXXDestructorDecl *Dtor) {
5664
5664
return this ->emitPopPtr (Dtor) && this ->emitRetVoid (Dtor);
5665
5665
}
5666
5666
5667
+ template <class Emitter >
5668
+ bool Compiler<Emitter>::compileUnionCopyAssignmentOperator(
5669
+ const CXXMethodDecl *MD) {
5670
+ if (!this ->emitThis (MD))
5671
+ return false ;
5672
+
5673
+ auto PVD = MD->getParamDecl (0 );
5674
+ ParamOffset PO = this ->Params [PVD]; // Must exist.
5675
+
5676
+ if (!this ->emitGetParam (PT_Ptr, PO.Offset , MD))
5677
+ return false ;
5678
+
5679
+ return this ->emitMemcpy (MD) && this ->emitRet (PT_Ptr, MD);
5680
+ }
5681
+
5667
5682
template <class Emitter >
5668
5683
bool Compiler<Emitter>::visitFunc(const FunctionDecl *F) {
5669
5684
// Classify the return type.
@@ -5675,9 +5690,15 @@ bool Compiler<Emitter>::visitFunc(const FunctionDecl *F) {
5675
5690
return this ->compileDestructor (Dtor);
5676
5691
5677
5692
// Emit custom code if this is a lambda static invoker.
5678
- if (const auto *MD = dyn_cast<CXXMethodDecl>(F);
5679
- MD && MD->isLambdaStaticInvoker ())
5680
- return this ->emitLambdaStaticInvokerBody (MD);
5693
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(F)) {
5694
+ const RecordDecl *RD = MD->getParent ();
5695
+
5696
+ if (RD->isUnion () && MD->isCopyAssignmentOperator ())
5697
+ return this ->compileUnionCopyAssignmentOperator (MD);
5698
+
5699
+ if (MD->isLambdaStaticInvoker ())
5700
+ return this ->emitLambdaStaticInvokerBody (MD);
5701
+ }
5681
5702
5682
5703
// Regular functions.
5683
5704
if (const auto *Body = F->getBody ())
0 commit comments