[cfe-commits] r95223 - in /cfe/trunk/lib: CodeGen/CGCall.cpp CodeGen/CGClass.cpp CodeGen/CGDecl.cpp CodeGen/CGDeclCXX.cpp CodeGen/CGExpr.cpp CodeGen/CodeGenFunction.h Sema/SemaInit.cpp

Anders Carlsson andersca at mac.com
Wed Feb 3 08:38:03 PST 2010


Author: andersca
Date: Wed Feb  3 10:38:03 2010
New Revision: 95223

URL: http://llvm.org/viewvc/llvm-project?rev=95223&view=rev
Log:
Revert the new reference binding code; I came up with a way simpler solution for the reference binding bug that is preventing self-hosting.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/lib/Sema/SemaInit.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb  3 10:38:03 2010
@@ -802,11 +802,8 @@
 }
 
 RValue CodeGenFunction::EmitCallArg(const Expr *E, QualType ArgType) {
-  if (const CXXBindReferenceExpr *BE = dyn_cast<CXXBindReferenceExpr>(E))
-    return RValue::get(EmitCXXBindReferenceExpr(BE));
-  
   if (ArgType->isReferenceType())
-    return EmitReferenceBindingToExpr(E, ArgType);
+    return EmitReferenceBindingToExpr(E);
 
   return EmitAnyExprToTemp(E);
 }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Feb  3 10:38:03 2010
@@ -838,7 +838,7 @@
   // was implicitly generated, we shouldn't be zeroing memory.
   RValue RHS;
   if (FieldType->isReferenceType()) {
-    RHS = CGF.EmitReferenceBindingToExpr(MemberInit->getInit(), FieldType,
+    RHS = CGF.EmitReferenceBindingToExpr(MemberInit->getInit(),
                                          /*IsInitializer=*/true);
     CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
   } else if (FieldType->isArrayType() && !MemberInit->getInit()) {

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  3 10:38:03 2010
@@ -507,12 +507,8 @@
         
         Builder.CreateCall4(CGM.getMemCpyFn(), Loc, SrcPtr, SizeVal, AlignVal);
       }
-    } else if (const CXXBindReferenceExpr *BE = 
-                dyn_cast<CXXBindReferenceExpr>(Init)) {
-      llvm::Value *V = EmitCXXBindReferenceExpr(BE);
-      EmitStoreOfScalar(V, Loc, /*Volatile=*/false, Ty);
     } else if (Ty->isReferenceType()) {
-      RValue RV = EmitReferenceBindingToExpr(Init, Ty, /*IsInitializer=*/true);
+      RValue RV = EmitReferenceBindingToExpr(Init, /*IsInitializer=*/true);
       EmitStoreOfScalar(RV.getScalarVal(), Loc, false, Ty);
     } else if (!hasAggregateLLVMType(Init->getType())) {
       llvm::Value *V = EmitScalarExpr(Init);

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Feb  3 10:38:03 2010
@@ -81,7 +81,7 @@
     return;
   }
   if (Init->isLvalue(getContext()) == Expr::LV_Valid) {
-    RValue RV = EmitReferenceBindingToExpr(Init, T, /*IsInitializer=*/true);
+    RValue RV = EmitReferenceBindingToExpr(Init, /*IsInitializer=*/true);
     EmitStoreOfScalar(RV.getScalarVal(), DeclPtr, false, T);
     return;
   }
@@ -225,7 +225,7 @@
     QualType T = D.getType();
     // We don't want to pass true for IsInitializer here, because a static
     // reference to a temporary does not extend its lifetime.
-    RValue RV = EmitReferenceBindingToExpr(D.getInit(), T,
+    RValue RV = EmitReferenceBindingToExpr(D.getInit(),
                                            /*IsInitializer=*/false);
     EmitStoreOfScalar(RV.getScalarVal(), GV, /*Volatile=*/false, T);
 

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Feb  3 10:38:03 2010
@@ -92,31 +92,8 @@
                      IsInitializer);
 }
 
-llvm::Value * 
-CodeGenFunction::EmitCXXBindReferenceExpr(const CXXBindReferenceExpr *E) {
-  QualType T = E->getType();
-  assert(T->isAnyComplexType() && "FIXME: Unhandled bind expression!");
-  
-  const Expr *SubExpr = E->getSubExpr();
-
-  if (!E->requiresTemporaryCopy())
-    return EmitLValue(SubExpr).getAddress();
-
-  llvm::Value *Value = CreateTempAlloca(ConvertTypeForMem(T), "reftmp");
-    
-  if (T->isAnyComplexType()) 
-    EmitComplexExprIntoAddr(SubExpr, Value, /*DestIsVolatile=*/false);
-  else
-    assert(false && "Unhandled bind expression");
-    
-  return Value;
-}
-
 RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
-                                                   QualType DestType,
                                                    bool IsInitializer) {
-  assert(!E->getType()->isAnyComplexType() && 
-         "Should not use this function for complex types!");
   bool ShouldDestroyTemporaries = false;
   unsigned OldNumLiveTemporaries = 0;
 
@@ -478,8 +455,6 @@
     return EmitCXXConstructLValue(cast<CXXConstructExpr>(E));
   case Expr::CXXBindTemporaryExprClass:
     return EmitCXXBindTemporaryLValue(cast<CXXBindTemporaryExpr>(E));
-  case Expr::CXXBindReferenceExprClass:
-    return EmitLValue(cast<CXXBindReferenceExpr>(E)->getSubExpr());
   case Expr::CXXExprWithTemporariesClass:
     return EmitCXXExprWithTemporariesLValue(cast<CXXExprWithTemporaries>(E));
   case Expr::CXXZeroInitValueExprClass:

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=95223&r1=95222&r2=95223&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Feb  3 10:38:03 2010
@@ -1111,10 +1111,7 @@
 
   /// EmitReferenceBindingToExpr - Emits a reference binding to the passed in
   /// expression. Will emit a temporary variable if E is not an LValue.
-  RValue EmitReferenceBindingToExpr(const Expr* E, QualType DestType,
-                                    bool IsInitializer = false);
-
-  llvm::Value *EmitCXXBindReferenceExpr(const CXXBindReferenceExpr *E);
+  RValue EmitReferenceBindingToExpr(const Expr* E, bool IsInitializer = false);
 
   //===--------------------------------------------------------------------===//
   //                           Expression Emission

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=95223&r1=95222&r2=95223&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Feb  3 10:38:03 2010
@@ -3304,31 +3304,16 @@
       // Check exception specifications
       if (S.CheckExceptionSpecCompatibility(CurInitExpr, DestType))
         return S.ExprError();
-      
-      // FIXME: We should do this for all types.
-      if (DestType->isAnyComplexType()) {
-        CurInit = 
-          S.Owned(CXXBindReferenceExpr::Create(S.Context, 
-                                               CurInit.takeAs<Expr>(), 
-                                               /*ExtendsLifetime=*/false,
-                                               /*RequiresTemporaryCopy=*/false));
-      }
 
       break;
 
     case SK_BindReferenceToTemporary:
+      // Reference binding does not have any corresponding ASTs.
+
       // Check exception specifications
       if (S.CheckExceptionSpecCompatibility(CurInitExpr, DestType))
         return S.ExprError();
 
-      // FIXME: We should do this for all types.
-      if (DestType->isAnyComplexType()) {
-        CurInit = 
-          S.Owned(CXXBindReferenceExpr::Create(S.Context, 
-                                               CurInit.takeAs<Expr>(), 
-                                               /*ExtendsLifetime=*/false,
-                                               /*RequiresTemporaryCopy=*/true));
-      }
       break;
         
     case SK_UserConversion: {





More information about the cfe-commits mailing list