]> granicus.if.org Git - clang/commit
Fix cleanup registration for lambda captures.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 17 Jan 2019 22:05:50 +0000 (22:05 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 17 Jan 2019 22:05:50 +0000 (22:05 +0000)
commit08d0c133ccb1b530ed743a021dc5995fbcdaf012
tree61cebf8e36bc05b82bcfe94a36c7d8e5a41cddd0
parent8abc38eefae434edc7fc43ab41086bfccb0641e3
Fix cleanup registration for lambda captures.

Lambda captures should be destroyed if an exception is thrown only if
the construction of the complete lambda-expression has not completed.
(If the lambda-expression has been fully constructed, any exception will
invoke its destructor, which will destroy the captures.)

This is directly modeled after how we handle the equivalent situation in
InitListExprs.

Note that EmitLambdaLValue was unreachable because in C++11 onwards the
frontend never creates the awkward situation where a prvalue expression
(such as a lambda) is used in an lvalue context (such as the left-hand
side of a class member access).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351487 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprCXX.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenCXX/cxx1y-init-captures-eh.cpp [new file with mode: 0644]