[cfe-commits] r95235 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGenCXX/references.cpp

Anders Carlsson andersca at mac.com
Wed Feb 3 11:13:56 PST 2010


Author: andersca
Date: Wed Feb  3 13:13:55 2010
New Revision: 95235

URL: http://llvm.org/viewvc/llvm-project?rev=95235&view=rev
Log:
Handle reference binding in aggregate initializers. Fixes another 47 tests.

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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Wed Feb  3 13:13:55 2010
@@ -514,13 +514,13 @@
 
 void 
 AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV, QualType T) {
-  // FIXME: Remove this.
-  T = E->getType();
-
   // FIXME: Ignore result?
   // FIXME: Are initializers affected by volatile?
   if (isa<ImplicitValueInitExpr>(E)) {
     EmitNullInitializationToLValue(LV, T);
+  } else if (T->isReferenceType()) {
+    RValue RV = CGF.EmitReferenceBindingToExpr(E, /*IsInitializer=*/false);
+    CGF.EmitStoreThroughLValue(RV, LV, T);
   } else if (T->isAnyComplexType()) {
     CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false);
   } else if (CGF.hasAggregateLLVMType(T)) {
@@ -633,7 +633,7 @@
 
     // FIXME: volatility
     FieldDecl *Field = E->getInitializedFieldInUnion();
-    LValue FieldLoc = CGF.EmitLValueForField(DestPtr, Field, 0);
+    LValue FieldLoc = CGF.EmitLValueForFieldInitialization(DestPtr, Field, 0);
 
     if (NumInitElements) {
       // Store the initializer into the field
@@ -659,7 +659,7 @@
       continue;
 
     // FIXME: volatility
-    LValue FieldLoc = CGF.EmitLValueForField(DestPtr, *Field, 0);
+    LValue FieldLoc = CGF.EmitLValueForFieldInitialization(DestPtr, *Field, 0);
     // We never generate write-barries for initialized fields.
     LValue::SetObjCNonGC(FieldLoc, true);
     if (CurInitVal < NumInitElements) {

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Wed Feb  3 13:13:55 2010
@@ -38,6 +38,8 @@
   
   bool_reference_return() = true;
   a = bool_reference_return();
+  
+  struct { const bool& b; } b = { true };
 }
 
 void test_scalar() {
@@ -54,6 +56,8 @@
   
   int_reference_return() = 10;
   a = int_reference_return();
+  
+  struct { const int& a; } agg = { 10 };
 }
 
 void test_complex() {
@@ -64,6 +68,8 @@
   
   complex_int_reference_return() = 10i;
   a = complex_int_reference_return();
+  
+  struct { const _Complex int &a; } agg = { 10i };
 }
 
 void test_aggregate() {
@@ -74,6 +80,8 @@
   aggregate_reference_return().a = 10;
 
   c = aggregate_reference_return();
+  
+  struct { const C& a; } agg = { C() };
 }
 
 int& reference_return() {





More information about the cfe-commits mailing list