[cfe-commits] r72457 - in /cfe/trunk: lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/references.cpp

Anders Carlsson andersca at mac.com
Tue May 26 20:37:57 PDT 2009


Author: andersca
Date: Tue May 26 22:37:57 2009
New Revision: 72457

URL: http://llvm.org/viewvc/llvm-project?rev=72457&view=rev
Log:
Functions that return references can be rvalues as well.

Modified:
    cfe/trunk/lib/CodeGen/CGExprComplex.cpp
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGenCXX/references.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=72457&r1=72456&r2=72457&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Tue May 26 22:37:57 2009
@@ -255,6 +255,9 @@
 
 
 ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) {
+  if (E->getCallReturnType()->isReferenceType())
+    return EmitLoadOfLValue(E);
+
   return CGF.EmitCallExpr(E).getComplexVal();
 }
 

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=72457&r1=72456&r2=72457&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue May 26 22:37:57 2009
@@ -223,6 +223,9 @@
   Value *EmitCastExpr(const Expr *E, QualType T);
 
   Value *VisitCallExpr(const CallExpr *E) {
+    if (E->getCallReturnType()->isReferenceType())
+      return EmitLoadOfLValue(E);
+    
     return CGF.EmitCallExpr(E).getScalarVal();
   }
 

Modified: cfe/trunk/test/CodeGenCXX/references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/references.cpp?rev=72457&r1=72456&r2=72457&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Tue May 26 22:37:57 2009
@@ -38,6 +38,7 @@
   f(true);
   
   bool_reference_return() = true;
+  a = bool_reference_return();
 }
 
 void test_scalar() {
@@ -53,6 +54,7 @@
   f((vec4){1,2,3,4}[0]);
   
   int_reference_return() = 10;
+  a = int_reference_return();
 }
 
 void test_complex() {
@@ -62,6 +64,7 @@
   f(10i);
   
   complex_int_reference_return() = 10i;
+  a = complex_int_reference_return();
 }
 
 void test_aggregate() {





More information about the cfe-commits mailing list