diff options
| author | Mariya Podchishchaeva <mariya.podchishchaeva@intel.com> | 2024-06-17 14:29:20 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-17 13:29:20 +0200 |
| commit | 6d973b4548e281d0b8e75e85833804bb45b6a0e8 (patch) | |
| tree | 10fd095a7efd752a78668205d597e4f95f4af96d /clang/lib/CodeGen/CGExprAgg.cpp | |
| parent | 52d87de7a42d608ac1da33795ca0a892f2b53f36 (diff) | |
| download | llvm-6d973b4548e281d0b8e75e85833804bb45b6a0e8.zip llvm-6d973b4548e281d0b8e75e85833804bb45b6a0e8.tar.gz llvm-6d973b4548e281d0b8e75e85833804bb45b6a0e8.tar.bz2 | |
[clang][CodeGen] Return RValue from `EmitVAArg` (#94635)
This should simplify handling of resulting value by the callers.
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index b2a5cee..c369163 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -78,15 +78,11 @@ public: /// then loads the result into DestPtr. void EmitAggLoadOfLValue(const Expr *E); - enum ExprValueKind { - EVK_RValue, - EVK_NonRValue - }; - /// EmitFinalDestCopy - Perform the final copy to DestPtr, if desired. /// SrcIsRValue is true if source comes from an RValue. void EmitFinalDestCopy(QualType type, const LValue &src, - ExprValueKind SrcValueKind = EVK_NonRValue); + CodeGenFunction::ExprValueKind SrcValueKind = + CodeGenFunction::EVK_NonRValue); void EmitFinalDestCopy(QualType type, RValue src); void EmitCopy(QualType type, const AggValueSlot &dest, const AggValueSlot &src); @@ -348,12 +344,13 @@ void AggExprEmitter::withReturnValueSlot( void AggExprEmitter::EmitFinalDestCopy(QualType type, RValue src) { assert(src.isAggregate() && "value must be aggregate value!"); LValue srcLV = CGF.MakeAddrLValue(src.getAggregateAddress(), type); - EmitFinalDestCopy(type, srcLV, EVK_RValue); + EmitFinalDestCopy(type, srcLV, CodeGenFunction::EVK_RValue); } /// EmitFinalDestCopy - Perform the final copy to DestPtr, if desired. -void AggExprEmitter::EmitFinalDestCopy(QualType type, const LValue &src, - ExprValueKind SrcValueKind) { +void AggExprEmitter::EmitFinalDestCopy( + QualType type, const LValue &src, + CodeGenFunction::ExprValueKind SrcValueKind) { // If Dest is ignored, then we're evaluating an aggregate expression // in a context that doesn't care about the result. Note that loads // from volatile l-values force the existence of a non-ignored @@ -365,7 +362,7 @@ void AggExprEmitter::EmitFinalDestCopy(QualType type, const LValue &src, LValue DstLV = CGF.MakeAddrLValue( Dest.getAddress(), Dest.isVolatile() ? type.withVolatile() : type); - if (SrcValueKind == EVK_RValue) { + if (SrcValueKind == CodeGenFunction::EVK_RValue) { if (type.isNonTrivialToPrimitiveDestructiveMove() == QualType::PCK_Struct) { if (Dest.isPotentiallyAliased()) CGF.callCStructMoveAssignmentOperator(DstLV, src); @@ -1317,15 +1314,13 @@ void AggExprEmitter::VisitChooseExpr(const ChooseExpr *CE) { void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) { Address ArgValue = Address::invalid(); - Address ArgPtr = CGF.EmitVAArg(VE, ArgValue); + CGF.EmitVAArg(VE, ArgValue, Dest); // If EmitVAArg fails, emit an error. - if (!ArgPtr.isValid()) { + if (!ArgValue.isValid()) { CGF.ErrorUnsupported(VE, "aggregate va_arg expression"); return; } - - EmitFinalDestCopy(VE->getType(), CGF.MakeAddrLValue(ArgPtr, VE->getType())); } void AggExprEmitter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { @@ -2027,6 +2022,13 @@ LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) { return LV; } +void CodeGenFunction::EmitAggFinalDestCopy(QualType Type, AggValueSlot Dest, + const LValue &Src, + ExprValueKind SrcKind) { + return AggExprEmitter(*this, Dest, Dest.isIgnored()) + .EmitFinalDestCopy(Type, Src, SrcKind); +} + AggValueSlot::Overlap_t CodeGenFunction::getOverlapForFieldInit(const FieldDecl *FD) { if (!FD->hasAttr<NoUniqueAddressAttr>() || !FD->getType()->isRecordType()) |
