[cfe-commits] r72459 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGenCXX/references.cpp
Eli Friedman
eli.friedman at gmail.com
Tue May 26 21:56:15 PDT 2009
Author: efriedma
Date: Tue May 26 23:56:12 2009
New Revision: 72459
URL: http://llvm.org/viewvc/llvm-project?rev=72459&view=rev
Log:
Add IRGen support for return statements in functions with reference
type.
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/CodeGenCXX/references.cpp
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=72459&r1=72458&r2=72459&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue May 26 23:56:12 2009
@@ -498,6 +498,10 @@
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()) {
Modified: cfe/trunk/test/CodeGenCXX/references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/references.cpp?rev=72459&r1=72458&r2=72459&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Tue May 26 23:56:12 2009
@@ -75,3 +75,6 @@
aggregate_reference_return().a = 10;
}
+int& reference_return() {
+ return g;
+}
More information about the cfe-commits
mailing list