aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaLambda.cpp
diff options
context:
space:
mode:
authorCorentin Jabot <corentinjabot@gmail.com>2022-08-03 20:59:36 +0200
committerCorentin Jabot <corentinjabot@gmail.com>2022-08-03 21:00:29 +0200
commita274219600ea00c4406248acfbea113e29a8ead2 (patch)
treecbbffd3653ec77bae4ee8e2ee931a942d96a4fc3 /clang/lib/Sema/SemaLambda.cpp
parent1f64f8bcabb65c9622386d7458e42ee33b2eb7dc (diff)
downloadllvm-a274219600ea00c4406248acfbea113e29a8ead2.zip
llvm-a274219600ea00c4406248acfbea113e29a8ead2.tar.gz
llvm-a274219600ea00c4406248acfbea113e29a8ead2.tar.bz2
Revert "[Clang][C++20] Support capturing structured bindings in lambdas"
This reverts commit 44f2baa3804a62ca793f0ff3e43aa71cea91a795. Breaks self builds and seems to have conformance issues.
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r--clang/lib/Sema/SemaLambda.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 3f271d6..afc2f3e 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1088,7 +1088,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
if (C->Init.isInvalid())
continue;
- ValueDecl *Var = nullptr;
+ VarDecl *Var = nullptr;
if (C->Init.isUsable()) {
Diag(C->Loc, getLangOpts().CPlusPlus14
? diag::warn_cxx11_compat_init_capture
@@ -1166,10 +1166,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
continue;
}
- if (auto *BD = R.getAsSingle<BindingDecl>())
- Var = BD;
- else
- Var = R.getAsSingle<VarDecl>();
+ Var = R.getAsSingle<VarDecl>();
if (Var && DiagnoseUseOfDecl(Var, C->Loc))
continue;
}
@@ -1203,13 +1200,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
if (Var->isInvalidDecl())
continue;
- VarDecl *Underlying;
- if (auto *BD = dyn_cast<BindingDecl>(Var))
- Underlying = dyn_cast<VarDecl>(BD->getDecomposedDecl());
- else
- Underlying = cast<VarDecl>(Var);
-
- if (!Underlying->hasLocalStorage()) {
+ if (!Var->hasLocalStorage()) {
Diag(C->Loc, diag::err_capture_non_automatic_variable) << C->Id;
Diag(Var->getLocation(), diag::note_previous_decl) << C->Id;
continue;
@@ -1233,7 +1224,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
}
if (C->Init.isUsable()) {
- addInitCapture(LSI, cast<VarDecl>(Var));
+ addInitCapture(LSI, Var);
} else {
TryCaptureKind Kind = C->Kind == LCK_ByRef ? TryCapture_ExplicitByRef :
TryCapture_ExplicitByVal;
@@ -1583,7 +1574,7 @@ ExprResult Sema::BuildCaptureInit(const Capture &Cap,
// An init-capture is initialized directly from its stored initializer.
if (Cap.isInitCapture())
- return cast<VarDecl>(Cap.getVariable())->getInit();
+ return Cap.getVariable()->getInit();
// For anything else, build an initialization expression. For an implicit
// capture, the capture notionally happens at the capture-default, so use
@@ -1614,7 +1605,7 @@ ExprResult Sema::BuildCaptureInit(const Capture &Cap,
Init = This;
} else {
assert(Cap.isVariableCapture() && "unknown kind of capture");
- ValueDecl *Var = Cap.getVariable();
+ VarDecl *Var = Cap.getVariable();
Name = Var->getIdentifier();
Init = BuildDeclarationNameExpr(
CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), Loc), Var);
@@ -1663,7 +1654,7 @@ mapImplicitCaptureStyle(CapturingScopeInfo::ImplicitCaptureStyle ICS) {
bool Sema::CaptureHasSideEffects(const Capture &From) {
if (From.isInitCapture()) {
- Expr *Init = cast<VarDecl>(From.getVariable())->getInit();
+ Expr *Init = From.getVariable()->getInit();
if (Init && Init->HasSideEffects(Context))
return true;
}
@@ -1713,9 +1704,9 @@ FieldDecl *Sema::BuildCaptureField(RecordDecl *RD,
TypeSourceInfo *TSI = nullptr;
if (Capture.isVariableCapture()) {
- const auto *Var = dyn_cast_or_null<VarDecl>(Capture.getVariable());
- if (Var && Var->isInitCapture())
- TSI = Var->getTypeSourceInfo();
+ auto *Var = Capture.getVariable();
+ if (Var->isInitCapture())
+ TSI = Capture.getVariable()->getTypeSourceInfo();
}
// FIXME: Should we really be doing this? A null TypeSourceInfo seems more
@@ -1863,7 +1854,7 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
return LambdaCapture(From.getLocation(), IsImplicit, LCK_VLAType);
} else {
assert(From.isVariableCapture() && "unknown kind of capture");
- ValueDecl *Var = From.getVariable();
+ VarDecl *Var = From.getVariable();
LambdaCaptureKind Kind =
From.isCopyCapture() ? LCK_ByCopy : LCK_ByRef;
return LambdaCapture(From.getLocation(), IsImplicit, Kind, Var,