@@ -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" );
@@ -811,7 +823,9 @@ void AggExprEmitter::withReturnValueSlot(
811
823
if (!UseTemp) {
812
824
RetAddr = Dest.getAddress ();
813
825
} else {
814
- llvm_unreachable (" NYI" );
826
+ RetAddr = CGF.CreateMemTemp (RetTy, CGF.getLoc (E->getSourceRange ()),
827
+ " tmp" , &RetAddr);
828
+ assert (!UnimplementedFeature::shouldEmitLifetimeMarkers () && " NYI" );
815
829
}
816
830
817
831
RValue Src =
@@ -822,14 +836,13 @@ void AggExprEmitter::withReturnValueSlot(
822
836
return ;
823
837
824
838
assert (Dest.isIgnored () || Dest.getPointer () != Src.getAggregatePointer ());
825
- llvm_unreachable (" NYI" );
826
- // TODO(cir): EmitFinalDestCopy(E->getType(), Src);
839
+ buildFinalDestCopy (E->getType (), Src);
827
840
828
841
if (!RequiresDestruction) {
829
842
// If there's no dtor to run, the copy was the last use of our temporary.
830
843
// Since we're not guaranteed to be in an ExprWithCleanups, clean up
831
844
// eagerly.
832
- llvm_unreachable ( " NYI" );
845
+ assert (! UnimplementedFeature::shouldEmitLifetimeMarkers () && " NYI" );
833
846
}
834
847
}
835
848
0 commit comments