[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 16:23:00 PDT 2024
================
@@ -2653,11 +2655,39 @@ const BlockByrefInfo &CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
info.FieldOffset = varOffset;
info.ByrefAlignment = std::max(varAlign, getPointerAlign());
+ // If we're initializing directly on the heap, then we should emit a
+ // no-op copy helper, both because we don't need a real one (the
+ // object will never move), and because a real one would break the
+ // pre-init _Block_object_assign.
+ info.ForceNoopCopy = D->needsInitOnHeap();
+
auto pair = BlockByrefInfos.insert({D, info});
assert(pair.second && "info was inserted recursively?");
return pair.first->second;
}
+void CodeGenFunction::emitByrefInitOnHeap(llvm::Value *P) {
----------------
ille-apple wrote:
Good point. I'll change the name to `emitByrefHeapAlloc`.
https://github.com/llvm/llvm-project/pull/89475
More information about the cfe-commits
mailing list