aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2020-08-31 09:42:34 -0400
committerErik Pilkington <erik.pilkington@gmail.com>2020-08-31 10:12:17 -0400
commita9a6e62ddff21c597b82f0f6d26bca6a1a473a6f (patch)
tree16afb24ae4b1adedf534bf906bfd066ca2b14c1d /clang/lib/CodeGen/CodeGenFunction.h
parent41634497d4fd21f28d08ac6f538ca4045f386c95 (diff)
downloadllvm-a9a6e62ddff21c597b82f0f6d26bca6a1a473a6f.zip
llvm-a9a6e62ddff21c597b82f0f6d26bca6a1a473a6f.tar.gz
llvm-a9a6e62ddff21c597b82f0f6d26bca6a1a473a6f.tar.bz2
[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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 77671b0..b4f8b11 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -672,12 +672,13 @@ public:
initFullExprCleanup();
}
- /// Queue a cleanup to be pushed after finishing the current
- /// full-expression.
+ /// Queue a cleanup to be pushed after finishing the current full-expression,
+ /// potentially with an active flag.
template <class T, class... As>
void pushCleanupAfterFullExpr(CleanupKind Kind, As... A) {
if (!isInConditionalBranch())
- return pushCleanupAfterFullExprImpl<T>(Kind, Address::invalid(), A...);
+ return pushCleanupAfterFullExprWithActiveFlag<T>(Kind, Address::invalid(),
+ A...);
Address ActiveFlag = createCleanupActiveFlag();
assert(!DominatingValue<Address>::needsSaving(ActiveFlag) &&
@@ -687,12 +688,12 @@ public:
SavedTuple Saved{saveValueInCond(A)...};
typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
- pushCleanupAfterFullExprImpl<CleanupType>(Kind, ActiveFlag, Saved);
+ pushCleanupAfterFullExprWithActiveFlag<CleanupType>(Kind, ActiveFlag, Saved);
}
template <class T, class... As>
- void pushCleanupAfterFullExprImpl(CleanupKind Kind, Address ActiveFlag,
- As... A) {
+ void pushCleanupAfterFullExprWithActiveFlag(CleanupKind Kind,
+ Address ActiveFlag, As... A) {
LifetimeExtendedCleanupHeader Header = {sizeof(T), Kind,
ActiveFlag.isValid()};