Revert r118991.
Elidable CXXConstructExpr should inhibit calling destructor for temporary that is copied, not the one created. This is because eliding copy constructor means that the object that was to be copied will be constructed directly in memory the copy would be constructed in. llvm-svn: 119044
This commit is contained in:
@@ -2579,18 +2579,11 @@ CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(BinaryOperator *E) {
|
||||
return RHSBlock ? RHSBlock : LHSBlock;
|
||||
}
|
||||
|
||||
static bool hasElidableCXXConstructExpr(CXXBindTemporaryExpr *E) {
|
||||
if (CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E->getSubExpr()))
|
||||
if (CE->isElidable())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CFGBlock *CFGBuilder::VisitCXXBindTemporaryExprForTemporaryDtors(
|
||||
CXXBindTemporaryExpr *E, bool BindToTemporary) {
|
||||
// First add destructors for temporaries in subexpression.
|
||||
CFGBlock *B = VisitForTemporaryDtors(E->getSubExpr());
|
||||
if (!BindToTemporary && !hasElidableCXXConstructExpr(E)) {
|
||||
if (!BindToTemporary) {
|
||||
// If lifetime of temporary is not prolonged (by assigning to constant
|
||||
// reference) add destructor for it.
|
||||
autoCreateBlock();
|
||||
|
||||
Reference in New Issue
Block a user