From 64bee65a3436e3f0c352fcfe2130676f3502cffe Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 25 Feb 2012 02:48:22 +0000 Subject: Work-in-progress for lambda conversion-to-block operator. Still need to implement the retain+autorelease outside of ARC, and there's a bug that causes the generated code to crash in ARC (which I think is unrelated to my code, although I'm not completely sure). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151428 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/Sema/SemaDeclCXX.cpp') diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index a2180be53c..1f5255dae7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8868,11 +8868,17 @@ void Sema::DefineImplicitLambdaToBlockPointerConversion( } Block->setParams(BlockParams); - // Add capture. The capture is uses a fake (NULL) variable, since we don't - // actually want to have to name a capture variable. However, the - // initializer copy-initializes the lambda object. - BlockDecl::Capture Capture(/*Variable=*/0, /*ByRef=*/false, /*Nested=*/false, - /*Copy=*/Init.take()); + // Add capture. The capture uses a fake variable, which doesn't correspond + // to any actual memory location. However, the initializer copy-initializes + // the lambda object. + TypeSourceInfo *CapVarTSI = + Context.getTrivialTypeSourceInfo(DerefThis->getType()); + VarDecl *CapVar = VarDecl::Create(Context, Block, Conv->getLocation(), + Conv->getLocation(), 0, + DerefThis->getType(), CapVarTSI, + SC_None, SC_None); + BlockDecl::Capture Capture(/*Variable=*/CapVar, /*ByRef=*/false, + /*Nested=*/false, /*Copy=*/Init.take()); Block->setCaptures(Context, &Capture, &Capture + 1, /*CapturesCXXThis=*/false); -- cgit v1.2.3