From e70e8f7fef3efb3d526ee25b3a0e2a4bf67a04b6 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 27 May 2009 16:45:02 +0000 Subject: [PATCH] IRgen support for calls to functions that return references to aggregate exressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72479 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 5 +++++ test/CodeGenCXX/references.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 00c1f8dbc1..59c00528a8 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -186,6 +186,11 @@ void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) { } void AggExprEmitter::VisitCallExpr(const CallExpr *E) { + if (E->getCallReturnType()->isReferenceType()) { + EmitAggLoadOfLValue(E); + return; + } + RValue RV = CGF.EmitCallExpr(E); EmitFinalDestCopy(E, RV); } diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp index 9d5a2ed9ee..8e19356757 100644 --- a/test/CodeGenCXX/references.cpp +++ b/test/CodeGenCXX/references.cpp @@ -74,6 +74,8 @@ void test_aggregate() { f(aggregate_return()); aggregate_reference_return().a = 10; + + c = aggregate_reference_return(); } int& reference_return() { -- 2.40.0