[PATCH] D58164: Block+lambda: allow reference capture

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 13 10:31:28 PST 2019


ahatanak added a comment.

I think the root of the problem is that `BlockDecl` knows the captured variable but doesn't know the type of the capture. The type of the variable and the type of the capture can be different if the block is nested inside a lambda or another block, which is why `CI.hasCopyExpr()` can return a non-null value when `VT` is a lvalue reference:

  `-FunctionDecl 0x11306dc28 <line:11:1, line:23:1> line:11:6 test 'void ()'
      |-DeclStmt 0x11306ddb0 <line:12:3, col:9>
      | `-VarDecl 0x11306dd20 <col:3, col:8> col:8 used c 'derp' callinit
      ...
      |     |-CXXRecordDecl 0x11306dec0 <line:14:12> col:12 implicit class definition
      ...
      |     | |-FieldDecl 0x11309cc58 <line:16:7> col:7 implicit 'derp &'
      ...
      |     | |   |       `-BlockDecl 0x11309cb28 <line:15:18, line:17:5> line:15:18
      |     | |   |         |-capture nested Var 0x11306dd20 'c' 'derp'


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58164/new/

https://reviews.llvm.org/D58164





More information about the cfe-commits mailing list