From ba71c085234044f8291b82749552a79d01f99631 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 16 May 2013 06:20:58 +0000 Subject: First pass of semantic analysis for init-captures: check the initializer, build a FieldDecl from it, and propagate both into the closure type and the LambdaExpr. You can't do much useful with them yet -- you can't use them within the body of the lambda, because we don't have a representation for "the this of the lambda, not the this of the enclosing context". We also don't have support or a representation for a nested capture of an init-capture yet, which was intended to work despite not being allowed by the current standard wording. llvm-svn: 181985 --- clang/lib/Sema/SemaExpr.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index fa2bfd260b9..8c612b42ca0 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -9932,7 +9932,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, if (Cap.isThisCapture()) continue; BlockDecl::Capture NewCap(Cap.getVariable(), Cap.isBlockCapture(), - Cap.isNested(), Cap.getCopyExpr()); + Cap.isNested(), Cap.getInitExpr()); Captures.push_back(NewCap); } BSI->TheDecl->setCaptures(Context, Captures.begin(), Captures.end(), @@ -11144,17 +11144,18 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, cast(FunctionScopes[FunctionScopesIndex]); // Check whether we've already captured it. - if (CSI->CaptureMap.count(Var)) { + if (CSI->isCaptured(Var)) { + const CapturingScopeInfo::Capture &Cap = CSI->getCapture(Var); + // If we found a capture, any subcaptures are nested. Nested = true; // Retrieve the capture type for this variable. - CaptureType = CSI->getCapture(Var).getCaptureType(); + CaptureType = Cap.getCaptureType(); // Compute the type of an expression that refers to this variable. DeclRefType = CaptureType.getNonReferenceType(); - const CapturingScopeInfo::Capture &Cap = CSI->getCapture(Var); if (Cap.isCopyCapture() && !(isa(CSI) && cast(CSI)->Mutable)) DeclRefType.addConst(); -- cgit v1.2.3