[CodeGen] Make sure the EH cleanup for block captures is conditional when the block...
authorErik Pilkington <erik.pilkington@gmail.com>
Mon, 31 Aug 2020 13:42:34 +0000 (09:42 -0400)
committerErik Pilkington <erik.pilkington@gmail.com>
Mon, 31 Aug 2020 14:12:17 +0000 (10:12 -0400)
commita9a6e62ddff21c597b82f0f6d26bca6a1a473a6f
tree16afb24ae4b1adedf534bf906bfd066ca2b14c1d
parent41634497d4fd21f28d08ac6f538ca4045f386c95
[CodeGen] Make sure the EH cleanup for block captures is conditional when the block literal is in a conditional context

Previously, clang was crashing on the attached test because the EH cleanup for
the block capture was incorrectly emitted under the assumption that the
expression wasn't conditionally evaluated. This was because before 9a52de00260,
pushLifetimeExtendedDestroy was mainly used with C++ automatic lifetime
extension, where a conditionally evaluated expression wasn't possible. Now that
we're using this path for block captures, we need to handle this case.

rdar://66250047

Differential revision: https://reviews.llvm.org/D86854
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenObjC/arc-blocks-exceptions.m [new file with mode: 0644]