aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Parse/ParsePragma.cpp3
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--lib/Sema/SemaExprCXX.cpp39
-rw-r--r--lib/Sema/SemaStmt.cpp2
4 files changed, 20 insertions, 26 deletions
diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp
index 96328e2fb6..0ecd11ec97 100644
--- a/lib/Parse/ParsePragma.cpp
+++ b/lib/Parse/ParsePragma.cpp
@@ -136,8 +136,7 @@ StmtResult Parser::HandlePragmaCaptured()
SourceLocation Loc = Tok.getLocation();
ParseScope CapturedRegionScope(this, Scope::FnScope | Scope::DeclScope);
- Actions.ActOnCapturedRegionStart(Loc, getCurScope(),
- sema::CapturedRegionScopeInfo::CR_Default);
+ Actions.ActOnCapturedRegionStart(Loc, getCurScope(), CR_Default);
StmtResult R = ParseCompoundStatement();
CapturedRegionScope.Exit();
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 203b689aa1..38c58549cd 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -1316,7 +1316,7 @@ IdentifierInfo *Sema::getSuperIdentifier() const {
}
void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
- CapturedRegionScopeInfo::CapturedRegionKind K) {
+ CapturedRegionKind K) {
CapturingScopeInfo *CSI = new CapturedRegionScopeInfo(getDiagnostics(),
S, CD, RD, K);
CSI->ReturnType = Context.VoidTy;
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 65ad83d5fc..c05d29d7d4 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -728,6 +728,18 @@ Sema::CXXThisScopeRAII::~CXXThisScopeRAII() {
}
}
+static Expr *captureThis(ASTContext &Context, RecordDecl *RD,
+ QualType ThisTy, SourceLocation Loc) {
+ FieldDecl *Field
+ = FieldDecl::Create(Context, RD, Loc, Loc, 0, ThisTy,
+ Context.getTrivialTypeSourceInfo(ThisTy, Loc),
+ 0, false, ICIS_NoInit);
+ Field->setImplicit(true);
+ Field->setAccess(AS_private);
+ RD->addDecl(Field);
+ return new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit*/true);
+}
+
void Sema::CheckCXXThisCapture(SourceLocation Loc, bool Explicit) {
// We don't need to capture this in an unevaluated context.
if (ExprEvalContexts.back().Context == Unevaluated && !Explicit)
@@ -768,29 +780,12 @@ void Sema::CheckCXXThisCapture(SourceLocation Loc, bool Explicit) {
CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[idx]);
Expr *ThisExpr = 0;
QualType ThisTy = getCurrentThisType();
- if (LambdaScopeInfo *LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
+ if (LambdaScopeInfo *LSI = dyn_cast<LambdaScopeInfo>(CSI))
// For lambda expressions, build a field and an initializing expression.
- CXXRecordDecl *Lambda = LSI->Lambda;
- FieldDecl *Field
- = FieldDecl::Create(Context, Lambda, Loc, Loc, 0, ThisTy,
- Context.getTrivialTypeSourceInfo(ThisTy, Loc),
- 0, false, ICIS_NoInit);
- Field->setImplicit(true);
- Field->setAccess(AS_private);
- Lambda->addDecl(Field);
- ThisExpr = new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/true);
- } else if (CapturedRegionScopeInfo *RSI =
- dyn_cast<CapturedRegionScopeInfo>(FunctionScopes[idx])) {
- RecordDecl *RD = RSI->TheRecordDecl;
- FieldDecl *Field
- = FieldDecl::Create(Context, RD, Loc, Loc, 0, ThisTy,
- Context.getTrivialTypeSourceInfo(ThisTy, Loc),
- 0, false, ICIS_NoInit);
- Field->setImplicit(true);
- Field->setAccess(AS_private);
- RD->addDecl(Field);
- ThisExpr = new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit*/true);
- }
+ ThisExpr = captureThis(Context, LSI->Lambda, ThisTy, Loc);
+ else if (CapturedRegionScopeInfo *RSI
+ = dyn_cast<CapturedRegionScopeInfo>(FunctionScopes[idx]))
+ ThisExpr = captureThis(Context, RSI->TheRecordDecl, ThisTy, Loc);
bool isNested = NumClosures > 1;
CSI->addThisCapture(isNested, Loc, ThisTy, ThisExpr);
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 7286d166ca..4fc1818d32 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2970,7 +2970,7 @@ static void buildCapturedStmtCaptureList(
}
void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
- CapturedRegionScopeInfo::CapturedRegionKind Kind) {
+ CapturedRegionKind Kind) {
CapturedDecl *CD = 0;
RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc);