[PATCH] D21104: [CodeGen][ObjC] Block captures should inherit the type of the captured field in the enclosing lambda or block
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 15:08:40 PDT 2016
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a subscriber: cfe-commits.
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();
}
```
http://reviews.llvm.org/D21104
Files:
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGBlocks.h
test/CodeGenObjCXX/lambda-expressions.mm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21104.59954.patch
Type: text/x-patch
Size: 6837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160607/d3110e43/attachment-0001.bin>
More information about the cfe-commits
mailing list