This fixes a crash that occurs when a block nested in a c++ lambda captures a reference that is captured by the enclosing lambda.
rdar://problem/18586651
Paths
| Differential D19536
[CodeGenObjCXX] Fix handling of blocks in lambda ClosedPublic Authored by ahatanak on Apr 26 2016, 9:48 AM.
Details Summary This fixes a crash that occurs when a block nested in a c++ lambda captures a reference that is captured by the enclosing lambda. rdar://problem/18586651
Diff Detail Event Timelineahatanak updated this object.
Comment Actions Apply John's patch with a few modifications. I had to special case __block variables and remove the line creating a load from a reference to fix the failing regression tests. Closed by commit rL268532: [CodeGenObjCXX] Fix handling of blocks in lambda. (authored by ahatanak). · Explain WhyMay 4 2016, 11:46 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 56090 lib/CodeGen/CGBlocks.cpp
test/CodeGenObjCXX/block-nested-in-lambda.cpp
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hmm. It's become increasingly clear that my original decision to expand the decl-ref logic here was a mistake. Please just turn this entire block of conditions into:
if (blockDecl->isConversionFromLambda()) { // The lambda capture in a lambda's conversion-to-block-pointer is // special; we'll simply emit it directly. src = Address::invalid(); } else { DeclRefExpr declRef( const_cast<VarDecl *>(variable), /*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type, VK_LValue, SourceLocation()); src = EmitDeclRefLValue(&declRef).getAddress(); }