aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-27 04:56:12 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-27 04:56:12 +0000
commitd54b6ac2f4f6f0bd0076cbfa885b57277066f06c (patch)
treef0f2d4c1aa7143b8a0d95e006d5fe2ebe9c0e711 /lib/CodeGen/CGStmt.cpp
parent0f294632f36459174199b77699e339715244b5ab (diff)
Add IRGen support for return statements in functions with reference
type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index b13b9e529d..b67996c676 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -498,6 +498,10 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
EmitAnyExpr(RV);
} else if (RV == 0) {
// Do nothing (return value is left uninitialized)
+ } else if (FnRetTy->isReferenceType()) {
+ // If this function returns a reference, take the address of the expression
+ // rather than the value.
+ Builder.CreateStore(EmitLValue(RV).getAddress(), ReturnValue);
} else if (!hasAggregateLLVMType(RV->getType())) {
Builder.CreateStore(EmitScalarExpr(RV), ReturnValue);
} else if (RV->getType()->isAnyComplexType()) {