]> granicus.if.org Git - clang/commitdiff
Change EmitReferenceBindingToExpr to take a decl instead of a boolean.
authorAnders Carlsson <andersca@mac.com>
Sat, 26 Jun 2010 16:35:32 +0000 (16:35 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 26 Jun 2010 16:35:32 +0000 (16:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106949 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGClass.cpp
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h

index 349ab852c94f05bc7d59e7bd993d6890055d8f58..9a63a74fea62a1ca3070cfc6d2336ab69f658229 100644 (file)
@@ -878,7 +878,7 @@ RValue CodeGenFunction::EmitDelegateCallArg(const VarDecl *Param) {
 
 RValue CodeGenFunction::EmitCallArg(const Expr *E, QualType ArgType) {
   if (ArgType->isReferenceType())
-    return EmitReferenceBindingToExpr(E);
+    return EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0);
 
   return EmitAnyExprToTemp(E);
 }
index 55ae48d76f9d030bba448f1c61e875f88bc1ab1a..4028cda6b661adf2bbe55583504a102ff5404504 100644 (file)
@@ -461,8 +461,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
   // was implicitly generated, we shouldn't be zeroing memory.
   RValue RHS;
   if (FieldType->isReferenceType()) {
-    RHS = CGF.EmitReferenceBindingToExpr(MemberInit->getInit(),
-                                         /*IsInitializer=*/true);
+    RHS = CGF.EmitReferenceBindingToExpr(MemberInit->getInit(), Field);
     CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
   } else if (FieldType->isArrayType() && !MemberInit->getInit()) {
     CGF.EmitNullInitialization(LHS.getAddress(), Field->getType());
index ee8fadadc534d51cc5569d66ef85bbe8d8bfdf83..0190cac0784cb8f127649ebc856fa8a625958d46 100644 (file)
@@ -653,7 +653,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
                             Loc, SrcPtr, SizeVal, AlignVal, NotVolatile);
       }
     } else if (Ty->isReferenceType()) {
-      RValue RV = EmitReferenceBindingToExpr(Init, /*IsInitializer=*/true);
+      RValue RV = EmitReferenceBindingToExpr(Init, &D);
       EmitStoreOfScalar(RV.getScalarVal(), Loc, false, Ty);
     } else if (!hasAggregateLLVMType(Init->getType())) {
       llvm::Value *V = EmitScalarExpr(Init);
index 9695173513b26c9ec602fb778b39eed2457cc406..459a1e1fa62be3991e140c16a79c2cd60d698f0d 100644 (file)
@@ -94,7 +94,7 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
     return;
   }
   if (Init->isLvalue(getContext()) == Expr::LV_Valid) {
-    RValue RV = EmitReferenceBindingToExpr(Init, /*IsInitializer=*/true);
+    RValue RV = EmitReferenceBindingToExpr(Init, &D);
     EmitStoreOfScalar(RV.getScalarVal(), DeclPtr, false, T);
     return;
   }
@@ -376,8 +376,9 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
     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.
+    // FIXME: This is incorrect.
     RValue RV = EmitReferenceBindingToExpr(D.getInit(),
-                                           /*IsInitializer=*/false);
+                                           /*InitializedDecl=*/0);
     EmitStoreOfScalar(RV.getScalarVal(), GV, /*Volatile=*/false, T);
 
   } else
index cfb5af724bf12b4be9ac796d1ad0bbe59ce15990..5e84ffc06dc0f52754c1247fa1cc2a01ef37ef25 100644 (file)
@@ -168,8 +168,11 @@ struct SubobjectAdjustment {
   }
 };
 
-RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
-                                                   bool IsInitializer) {
+RValue
+CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
+                                            const NamedDecl *InitializedDecl) {
+  bool IsInitializer = InitializedDecl;
+
   bool ShouldDestroyTemporaries = false;
   unsigned OldNumLiveTemporaries = 0;
 
index 1a644f37a3dc740994f39b7c355e54f4613404b8..04e0044aaf2bb8806641ee22372bb2d30ca33c54 100644 (file)
@@ -588,7 +588,7 @@ AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV, QualType T) {
   if (isa<ImplicitValueInitExpr>(E)) {
     EmitNullInitializationToLValue(LV, T);
   } else if (T->isReferenceType()) {
-    RValue RV = CGF.EmitReferenceBindingToExpr(E, /*IsInitializer=*/false);
+    RValue RV = CGF.EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0);
     CGF.EmitStoreThroughLValue(RV, LV, T);
   } else if (T->isAnyComplexType()) {
     CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false);
index efde3807111fa2cca7d201f6e30d878c347156ed..22c154ad1e2660da1025c8f5cb9988a62e39d805 100644 (file)
@@ -631,7 +631,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
   } else if (FnRetTy->isReferenceType()) {
     // If this function returns a reference, take the address of the expression
     // rather than the value.
-    RValue Result = EmitReferenceBindingToExpr(RV, false);
+    RValue Result = EmitReferenceBindingToExpr(RV, /*InitializedDecl=*/0);
     Builder.CreateStore(Result.getScalarVal(), ReturnValue);
   } else if (!hasAggregateLLVMType(RV->getType())) {
     Builder.CreateStore(EmitScalarExpr(RV), ReturnValue);
index 4985bdb0ca47508631bc5d53735fdf3fdd120740..25fb7ab86188c28bdc6207d863a2873bf0e9db42 100644 (file)
@@ -1185,7 +1185,8 @@ public:
 
   /// 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, bool IsInitializer = false);
+  RValue EmitReferenceBindingToExpr(const Expr* E, 
+                                    const NamedDecl *InitializedDecl);
 
   //===--------------------------------------------------------------------===//
   //                           Expression Emission