summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-02-25 02:48:22 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-02-25 02:48:22 +0000
commit64bee65a3436e3f0c352fcfe2130676f3502cffe (patch)
tree9154d934a177c762072a49a0fa5d0813c37c780a /lib/Sema/SemaDeclCXX.cpp
parente1d4330adaaa7faf093e725c9c993207eb2d778a (diff)
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
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp16
1 files changed, 11 insertions, 5 deletions
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);