Reapply r183721, reverted in r183776, with a fix for a bug in the former (we
were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
This commit is contained in:
@@ -65,6 +65,8 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
|
||||
}
|
||||
|
||||
CodeGenFunction::~CodeGenFunction() {
|
||||
assert(LifetimeExtendedCleanupStack.empty() && "failed to emit a cleanup");
|
||||
|
||||
// If there are any unclaimed block infos, go ahead and destroy them
|
||||
// now. This can happen if IR-gen gets clever and skips evaluating
|
||||
// something.
|
||||
|
||||
Reference in New Issue
Block a user