[PATCH] D122768: [Clang][C++20] Support capturing structured bindings in lambdas
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 24 16:49:49 PDT 2022
shafik added inline comments.
================
Comment at: clang/lib/AST/StmtPrinter.cpp:2166
if (Node->isInitCapture(C)) {
+ VarDecl *D = cast<VarDecl>(C->getCapturedVar());
----------------
I wonder if it is worth commenting that only a `VarDecl` can be an init capture and therefore we can unconditionally cast to `VarDecl`?
================
Comment at: clang/lib/Sema/SemaInit.cpp:7851
+ bool InitCapture =
+ isa<VarDecl>(VD) && cast<VarDecl>(VD)->isInitCapture();
Diag(Elem.Capture->getLocation(), diag::note_lambda_capture_initializer)
----------------
cor3ntin wrote:
> shafik wrote:
> > I see we are doing this kind of check to see if we have a `VarDecl` and then check if it is an init capture and I wish there was a way not to repeat this but I don't see it.
> I considered having a function In ValueDecl, what do you think?
I thought about that but when I looked at `ValueDecl` it seemed pretty lightweight.
@aaron.ballman wdyt is `ValueDecl` the right place or is this code repetition ok?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122768/new/
https://reviews.llvm.org/D122768
More information about the cfe-commits
mailing list