Skip to content
Commit d542ccfc authored by Akira Hatanaka's avatar Akira Hatanaka
Browse files

[CodeGen][ObjC] Block captures should inherit the type of the captured

field in the enclosing lambda or block.

This patch fixes a bug in code-gen where it uses the type of the
declared variable rather than the type of the capture of the enclosing
lambda or block for the block capture. For example, in the following
function, code-gen currently uses i32* for the block capture "a" because
"a" is passed to foo1 as a reference, but it should use i32 since the
enclosing lambda captures "a" by value.

void foo1(int &a) {
  auto lambda = [a]{
    auto block1 = ^{
      i = a;
    };
    block1();
  };
  lambda();
}

rdar://problem/18586386

Differential Revision: https://reviews.llvm.org/D21104

llvm-svn: 281682
parent f8f31c49
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment