[PATCH] D51564: Distinguish `__block` variables that are captured by escaping blocks from those that aren't

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 31 18:11:22 PDT 2018


ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
Herald added a subscriber: dexonsmith.

This patch changes the way `__block` variables that aren't captured by escaping blocks are handled:

- Since non-escaping blocks on the stack never get copied to the heap (see https://reviews.llvm.org/D49303), Sema shouldn't error out when the type of a non-escaping `__block` variable doesn't have an accessible copy constructor.

- IRGen doesn't have to use the specialized byref structure (see https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a non-escaping `__block` variable anymore. Instead IRGen can emit the variable as a normal variable and copy the reference to the block literal . Byref copy/dispose helpers aren't needed either.

rdar://problem/39352313


Repository:
  rC Clang

https://reviews.llvm.org/D51564

Files:
  include/clang/AST/Decl.h
  include/clang/Sema/ScopeInfo.h
  lib/AST/Decl.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/ScopeInfo.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/block-byref-aggr.c
  test/CodeGen/blocks-seq.c
  test/CodeGen/exceptions.c
  test/CodeGen/personality.c
  test/CodeGenCXX/block-capture.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/debug-info-blocks.cpp
  test/CodeGenObjC/arc-no-arc-exceptions.m
  test/CodeGenObjC/arc-unoptimized-byref-var.m
  test/CodeGenObjC/blocks-1.m
  test/CodeGenObjC/noescape.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/PCH/block-helpers.cpp
  test/SemaObjCXX/blocks.mm
  test/SemaObjCXX/noescape.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51564.163613.patch
Type: text/x-patch
Size: 37466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180901/c280a1d9/attachment-0001.bin>


More information about the cfe-commits mailing list