summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-03 03:01:57 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-03 03:01:57 +0000
commitdb56b919e522883b16ad45015ee64dd37ed933a6 (patch)
tree12ad2d8b16dc02949282202d95478dd8924ec697 /clang
parentbf5ce0a6c27c1a31b1fb57c179f227f8efe115be (diff)
downloadbcm5719-llvm-db56b919e522883b16ad45015ee64dd37ed933a6.tar.gz
bcm5719-llvm-db56b919e522883b16ad45015ee64dd37ed933a6.zip
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. llvm-svn: 95192
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp4
-rw-r--r--clang/lib/Sema/TreeTransform.h6
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 8dd747240aa..4253d18c390 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -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) &&
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1938e3dfb59..b1b85e5928a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -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());
OpenPOWER on IntegriCloud