diff options
author | John McCall <rjmccall@apple.com> | 2010-09-18 00:58:34 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-09-18 00:58:34 +0000 |
commit | 8ea46b6654d995678af6ea522d26ae946d2ecd08 (patch) | |
tree | 141ec36ecbe34c1f2df54d0b6995a4d2e3c6ce04 /clang/lib/CodeGen/CGExprCXX.cpp | |
parent | 79d6af3839ab79179ae853999f3baaf08dcda659 (diff) | |
download | bcm5719-llvm-8ea46b6654d995678af6ea522d26ae946d2ecd08.tar.gz bcm5719-llvm-8ea46b6654d995678af6ea522d26ae946d2ecd08.zip |
Fix a bug with binding l-values to elided temporaries, and leave a couple
helpful asserts behind.
llvm-svn: 114250
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 4dbfa7ee4fa..aadceff8be5 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/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; |