diff options
author | John McCall <rjmccall@apple.com> | 2014-11-18 00:19:01 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2014-11-18 00:19:01 +0000 |
commit | 0d8d6c094f5da64e2c1bda992e8a65a5af27fdb1 (patch) | |
tree | 8d2dc736c77895a85aae0a018e7c254291093498 /clang/lib/Sema/SemaDecl.cpp | |
parent | 41c247a677f0dafaa13fc05a028275334d5df779 (diff) | |
download | bcm5719-llvm-0d8d6c094f5da64e2c1bda992e8a65a5af27fdb1.tar.gz bcm5719-llvm-0d8d6c094f5da64e2c1bda992e8a65a5af27fdb1.zip |
Fix an assertion when ending a function definition.
The bug is that ExprCleanupObjects isn't always empty
in a fresh evaluation context. New evaluation contexts just
track the current depth of the stack.
The assertion will misfire whenever we finish processing
a function body inside an expression that contained an earlier
block literal with non-trivial captures. That's actually
a lot less likely than you'd think, though, because it has
to be a real function declaration, not just another block.
Mixed block/lambda code would work, as would a template
instantiation or a local class definition.
The code works correctly if the assertion is disabled.
rdar://16356628
llvm-svn: 222194
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a4b995fa977..b63863e96bb 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10579,7 +10579,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, } } - assert(ExprCleanupObjects.empty() && "Leftover temporaries in function"); + assert(ExprCleanupObjects.size() == ExprEvalContexts.back().NumCleanupObjects + && "Leftover temporaries in function"); assert(!ExprNeedsCleanups && "Unaccounted cleanups in function"); assert(MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"); |