[cfe-commits] r95192 - in /cfe/trunk/lib: CodeGen/CGExprCXX.cpp Sema/TreeTransform.h

Douglas Gregor dgregor at apple.com
Tue Feb 2 19:01:58 PST 2010


Author: dgregor
Date: Tue Feb  2 21:01:57 2010
New Revision: 95192

URL: http://llvm.org/viewvc/llvm-project?rev=95192&view=rev
Log:
Provide a real fix for PR6199, reverting the old workaround. Here, we
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.


Modified:
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Feb  2 21:01:57 2010
@@ -309,9 +309,7 @@
   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) &&

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=95192&r1=95191&r2=95192&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Feb  2 21:01:57 2010
@@ -4808,6 +4808,12 @@
 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());





More information about the cfe-commits mailing list