From 8a97005f97a2a93fc2cd942c040668c5d4df7537 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 22 Oct 2010 22:05:03 +0000 Subject: [PATCH] After discussion with Doug and John, I am reverting the patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117159 91177308-0d34-0410-b5e6-96231b3b80d8 --- clang.xcodeproj/project.pbxproj | 1 - lib/CodeGen/CGExprAgg.cpp | 19 +------------------ lib/CodeGen/CGExprCXX.cpp | 1 - lib/CodeGen/CGValue.h | 9 +-------- test/CodeGenCXX/stmtexpr-copy-init.cpp | 26 -------------------------- 5 files changed, 2 insertions(+), 54 deletions(-) diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index fa1e24574e..9c95d0a3de 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -2039,7 +2039,6 @@ isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; compatibilityVersion = "Xcode 2.4"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 99b46d41a8..31ba3373f0 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -147,23 +147,6 @@ public: /// represents a value lvalue, this method emits the address of the lvalue, /// then loads the result into DestPtr. void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) { - if (CGF.getContext().getLangOptions().CPlusPlus) { - if (const CXXConstructExpr *CE = Dest.getCtorExpr()) { - // Perform copy initialization of Src into Dest. - const CXXConstructorDecl *CD = CE->getConstructor(); - CXXCtorType Type = - (CE->getConstructionKind() == CXXConstructExpr::CK_Complete) - ? Ctor_Complete : Ctor_Base; - bool ForVirtualBase = - CE->getConstructionKind() == CXXConstructExpr::CK_VirtualBase; - // Call the constructor. - const Stmt * S = dyn_cast(E); - clang::ConstExprIterator BegExp(&S); - CGF.EmitCXXConstructorCall(CD, Type, ForVirtualBase, Dest.getAddr(), - BegExp, (BegExp+1)); - return; - } - } LValue LV = CGF.EmitLValue(E); EmitFinalDestCopy(E, LV); } @@ -221,6 +204,7 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src, bool Ignore) { CGF.CGM.getLangOptions().CPlusPlus || (IgnoreResult && Ignore)) return; + // If the source is volatile, we must read from it; to do that, we need // some place to put it. Dest = CGF.CreateAggTemp(E->getType(), "agg.tmp"); @@ -238,7 +222,6 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src, bool Ignore) { SizeVal); return; } - // If the result of the assignment is used, copy the LHS there also. // FIXME: Pass VolatileDest as well. I think we also need to merge volatile // from the source as well, as we can't eliminate it if either operand diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 3cebfe7f88..2a88d33997 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -299,7 +299,6 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E, assert(getContext().hasSameUnqualifiedType(E->getType(), E->getArg(0)->getType())); if (E->getArg(0)->isTemporaryObject(getContext(), CD->getParent())) { - Dest.setCtorExpr(const_cast(E)); EmitAggExpr(E->getArg(0), Dest); return; } diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index fd82be7558..a000b22331 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -26,7 +26,6 @@ namespace llvm { namespace clang { class ObjCPropertyRefExpr; class ObjCImplicitSetterGetterRefExpr; - class CXXConstructExpr; namespace CodeGen { class CGBitFieldInfo; @@ -336,7 +335,6 @@ public: class AggValueSlot { /// The address. llvm::Value *Addr; - CXXConstructExpr *CtorExpr; // Associated flags. bool VolatileFlag : 1; @@ -349,7 +347,6 @@ public: static AggValueSlot ignored() { AggValueSlot AV; AV.Addr = 0; - AV.CtorExpr = 0; AV.VolatileFlag = AV.LifetimeFlag = AV.RequiresGCollection = 0; return AV; } @@ -367,7 +364,6 @@ public: bool RequiresGCollection=false) { AggValueSlot AV; AV.Addr = Addr; - AV.CtorExpr = 0; AV.VolatileFlag = Volatile; AV.LifetimeFlag = LifetimeExternallyManaged; AV.RequiresGCollection = RequiresGCollection; @@ -379,10 +375,7 @@ public: return forAddr(LV.getAddress(), LV.isVolatileQualified(), LifetimeExternallyManaged, RequiresGCollection); } - - void setCtorExpr(CXXConstructExpr *E) { CtorExpr = E; } - CXXConstructExpr *getCtorExpr() const { return CtorExpr; } - + bool isLifetimeExternallyManaged() const { return LifetimeFlag; } diff --git a/test/CodeGenCXX/stmtexpr-copy-init.cpp b/test/CodeGenCXX/stmtexpr-copy-init.cpp index 8a460e36a2..e69de29bb2 100644 --- a/test/CodeGenCXX/stmtexpr-copy-init.cpp +++ b/test/CodeGenCXX/stmtexpr-copy-init.cpp @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s -// rdar //8540501 - -struct A -{ - int i; - A (int j) : i(j) {} - A (const A &j) : i(j.i) {} - A& operator= (const A &j) { i = j.i; return *this; } -}; - -A foo(int j) -{ - return ({ j ? A(1) : A(0); }); -} - -int main() -{ - return foo(1).i-1; -} - -void foo2() -{ - A b = ({ A a(1); a; }); -} - -- 2.40.0