@@ -138,6 +138,9 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
138
138
139
139
enum ExprValueKind { EVK_RValue, EVK_NonRValue };
140
140
141
+ // / Perform the final copy to DestPtr, if desired.
142
+ void buildFinalDestCopy (QualType type, RValue src);
143
+
141
144
// / Perform the final copy to DestPtr, if desired. SrcIsRValue is true if
142
145
// / source comes from an RValue.
143
146
void buildFinalDestCopy (QualType type, const LValue &src,
@@ -331,6 +334,13 @@ void AggExprEmitter::buildAggLoadOfLValue(const Expr *E) {
331
334
buildFinalDestCopy (E->getType (), LV);
332
335
}
333
336
337
+ // / Perform the final copy to DestPtr, if desired.
338
+ void AggExprEmitter::buildFinalDestCopy (QualType type, RValue src) {
339
+ assert (src.isAggregate () && " value must be aggregate value!" );
340
+ LValue srcLV = CGF.makeAddrLValue (src.getAggregateAddress (), type);
341
+ buildFinalDestCopy (type, srcLV, EVK_RValue);
342
+ }
343
+
334
344
// / Perform the final copy to DestPtr, if desired.
335
345
void AggExprEmitter::buildFinalDestCopy (QualType type, const LValue &src,
336
346
ExprValueKind SrcValueKind) {
@@ -342,11 +352,13 @@ void AggExprEmitter::buildFinalDestCopy(QualType type, const LValue &src,
342
352
return ;
343
353
344
354
// Copy non-trivial C structs here.
345
- if (Dest.isVolatile () || UnimplementedFeature::volatileTypes () )
346
- llvm_unreachable ( " volatile is NYI " );
355
+ if (Dest.isVolatile ())
356
+ assert (! UnimplementedFeature::volatileTypes () );
347
357
348
358
if (SrcValueKind == EVK_RValue) {
349
- llvm_unreachable (" rvalue is NYI" );
359
+ if (type.isNonTrivialToPrimitiveDestructiveMove () == QualType::PCK_Struct) {
360
+ llvm_unreachable (" move assignment/move ctor for rvalue is NYI" );
361
+ }
350
362
} else {
351
363
if (type.isNonTrivialToPrimitiveCopy () == QualType::PCK_Struct)
352
364
llvm_unreachable (" non-trivial primitive copy is NYI" );
@@ -808,7 +820,9 @@ void AggExprEmitter::withReturnValueSlot(
808
820
if (!UseTemp) {
809
821
RetAddr = Dest.getAddress ();
810
822
} else {
811
- llvm_unreachable (" NYI" );
823
+ RetAddr = CGF.CreateMemTemp (RetTy, CGF.getLoc (E->getSourceRange ()),
824
+ " tmp" , &RetAddr);
825
+ assert (!UnimplementedFeature::shouldEmitLifetimeMarkers () && " NYI" );
812
826
}
813
827
814
828
RValue Src =
@@ -819,14 +833,13 @@ void AggExprEmitter::withReturnValueSlot(
819
833
return ;
820
834
821
835
assert (Dest.isIgnored () || Dest.getPointer () != Src.getAggregatePointer ());
822
- llvm_unreachable (" NYI" );
823
- // TODO(cir): EmitFinalDestCopy(E->getType(), Src);
836
+ buildFinalDestCopy (E->getType (), Src);
824
837
825
838
if (!RequiresDestruction) {
826
839
// If there's no dtor to run, the copy was the last use of our temporary.
827
840
// Since we're not guaranteed to be in an ExprWithCleanups, clean up
828
841
// eagerly.
829
- llvm_unreachable ( " NYI" );
842
+ assert (! UnimplementedFeature::shouldEmitLifetimeMarkers () && " NYI" );
830
843
}
831
844
}
832
845
0 commit comments