summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-02-11 02:51:16 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-02-11 02:51:16 +0000
commitc9751069f5c99635fef60030041b904c0a431707 (patch)
treee5412bb2e293dcfda900c9aeba08b5c25e4492a3 /clang/lib
parentd0e58e9be8115c88c80f79a1fde229d735927641 (diff)
downloadbcm5719-llvm-c9751069f5c99635fef60030041b904c0a431707.tar.gz
bcm5719-llvm-c9751069f5c99635fef60030041b904c0a431707.zip
Make sure Sema creates a field for 'this' captures. (Doug, please double-check that this is correct.)
llvm-svn: 150292
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5a2a8272308..c16d7e2282e 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -707,8 +707,22 @@ void Sema::CheckCXXThisCapture(SourceLocation Loc, bool Explicit) {
for (unsigned idx = FunctionScopes.size() - 1;
NumClosures; --idx, --NumClosures) {
CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[idx]);
+ Expr *ThisExpr = 0;
+ if (LambdaScopeInfo *LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
+ // For lambda expressions, build a field and an initializing expression.
+ QualType ThisTy = getCurrentThisType();
+ CXXRecordDecl *Lambda = LSI->Lambda;
+ FieldDecl *Field
+ = FieldDecl::Create(Context, Lambda, Loc, Loc, 0, ThisTy,
+ Context.getTrivialTypeSourceInfo(ThisTy, Loc),
+ 0, false, false);
+ Field->setImplicit(true);
+ Field->setAccess(AS_private);
+ Lambda->addDecl(Field);
+ ThisExpr = new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/true);
+ }
bool isNested = NumClosures > 1;
- CSI->AddThisCapture(isNested, Loc);
+ CSI->AddThisCapture(isNested, Loc, ThisExpr);
}
}
OpenPOWER on IntegriCloud