diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 3 |
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index d16d9e9763..0580392689 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5462,12 +5462,10 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, // with the same cv-unqualified type, the copy/move operation // can be omitted by constructing the temporary object // directly into the target of the omitted copy/move - if (Constructor->isCopyConstructor() && ExprArgs.size() >= 1) { + if (ConstructKind == CXXConstructExpr::CK_Complete && + Constructor->isCopyConstructor() && ExprArgs.size() >= 1) { Expr *SubExpr = ((Expr **)ExprArgs.get())[0]; - Elidable = SubExpr->isTemporaryObject() && - ConstructKind == CXXConstructExpr::CK_Complete && - Context.hasSameUnqualifiedType(SubExpr->getType(), - Context.getTypeDeclType(Constructor->getParent())); + Elidable = SubExpr->isTemporaryObject(Context, Constructor->getParent()); } return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor, diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 60d2acec07..1ffa70207a 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3303,8 +3303,7 @@ static ExprResult CopyObject(Sema &S, // elision for return statements and throw expressions are handled as part // of constructor initialization, while copy elision for exception handlers // is handled by the run-time. - bool Elidable = CurInitExpr->isTemporaryObject() && - S.Context.hasSameUnqualifiedType(T, CurInitExpr->getType()); + bool Elidable = CurInitExpr->isTemporaryObject(S.Context, Class); SourceLocation Loc; switch (Entity.getKind()) { case InitializedEntity::EK_Result: |