[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 17:07:42 PDT 2024
================
@@ -2120,27 +2066,33 @@ void CodeGenFunction::EmitAutoVarCleanups(const AutoVarEmission &emission) {
// us from jumping into any of these scopes anyway.
if (!HaveInsertPoint()) return;
- const VarDecl &D = *emission.Variable;
+ // If we're initializing directly on the heap, _Block_object_destroy will
+ // handle destruction, so we don't need to perform cleanups directly.
----------------
ille-apple wrote:
Indeed... and looking at this again, I put too much code inside the if statement.
Not only that, there's an existing bug here when combining `__attribute__((cleanup))` with `__block`: if the variable was copied to the heap, the cleanup function will be called after the byref allocation has already been freed.
Will fix.
https://github.com/llvm/llvm-project/pull/89475
More information about the cfe-commits
mailing list