aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-09-18 00:58:34 +0000
committerJohn McCall <rjmccall@apple.com>2010-09-18 00:58:34 +0000
commitfc1e6c79bbfe0e9a58bb792996d51f42e36e3d6a (patch)
tree38666e0a404848969ebfcf3378eaf09689e115b6 /lib/CodeGen/CGExprCXX.cpp
parent3ed3272a54d6736b9f25d9993f4424ba7f4249d1 (diff)
Fix a bug with binding l-values to elided temporaries, and leave a couple
helpful asserts behind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--lib/CodeGen/CGExprCXX.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index 4dbfa7ee4f..aadceff8be 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -280,10 +280,12 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E,
if (CD->isTrivial() && CD->isDefaultConstructor())
return;
- // Code gen optimization to eliminate copy constructor and return
- // its first argument instead, if in fact that argument is a temporary
- // object.
+ // Elide the constructor if we're constructing from a temporary.
+ // The temporary check is required because Sema sets this on NRVO
+ // returns.
if (getContext().getLangOptions().ElideConstructors && E->isElidable()) {
+ assert(getContext().hasSameUnqualifiedType(E->getType(),
+ E->getArg(0)->getType()));
if (E->getArg(0)->isTemporaryObject(getContext(), CD->getParent())) {
EmitAggExpr(E->getArg(0), Dest);
return;