]> granicus.if.org Git - clang/commitdiff
Provide a real fix for PR6199, reverting the old workaround. Here, we
authorDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2010 03:01:57 +0000 (03:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2010 03:01:57 +0000 (03:01 +0000)
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95192 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprCXX.cpp
lib/Sema/TreeTransform.h

index 8dd747240aaf9b755d5f2acee322d3e81e9ed5d7..4253d18c390a3a6f3212de0425649557789619c3 100644 (file)
@@ -309,9 +309,7 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
   if (getContext().getLangOptions().ElideConstructors && E->isElidable()) {
     const Expr *Arg = E->getArg(0);
     
-    // FIXME: This 'while' statement should really be an 'if' statement, it's 
-    // added as a workaround for PR6199.
-    while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
+    if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
       assert((ICE->getCastKind() == CastExpr::CK_NoOp ||
               ICE->getCastKind() == CastExpr::CK_ConstructorConversion ||
               ICE->getCastKind() == CastExpr::CK_UserDefinedConversion) &&
index 1938e3dfb5973610c25e23adbe81edf31170666c..b1b85e5928a50bb040af2202a289454766743510 100644 (file)
@@ -4808,6 +4808,12 @@ TreeTransform<Derived>::TransformDependentScopeDeclRefExpr(
 template<typename Derived>
 Sema::OwningExprResult
 TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
+  // CXXConstructExprs are always implicit, so when we have a
+  // 1-argument construction we just transform that argument.
+  if (E->getNumArgs() == 1 ||
+      (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1))))
+    return getDerived().TransformExpr(E->getArg(0));
+
   TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
 
   QualType T = getDerived().TransformType(E->getType());