summaryrefslogtreecommitdiffstats
path: root/clang/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
commitb909bf4937df1661615191c0864080baa578a5f2 (patch)
tree800bf30fe2f32f6b9ccb1efb9a5bf9943b8f9848 /clang/lib/CodeGen/CGStmt.cpp
parent4034a95dc857eed8ba339f8dbb46fc542ef12772 (diff)
downloadbcm5719-llvm-b909bf4937df1661615191c0864080baa578a5f2.tar.gz
bcm5719-llvm-b909bf4937df1661615191c0864080baa578a5f2.zip
Add IRGen support for return statements in functions with reference
type. llvm-svn: 72459
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index b13b9e529d3..b67996c6763 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/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()) {
OpenPOWER on IntegriCloud