[PATCH] D122768: [Clang][C++20] Support capturing structured bindings in lambdas

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 29 07:51:17 PDT 2022


cor3ntin added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:18399
+      if (Diagnose)
+        diagnoseUncapturableValueReferenceOrBinding(S, Loc, Var);
+      return false;
----------------
erichkeane wrote:
> first, why are we checking for !CPlusPlus... aren't BindingDecl's C++ only?  Or is there some ObjC thing for them?
> 
> second, can you clarify what the two diagnostic cases are doing?  it isn't completely clear to me the purpose of the first call here.
The first diagnostic is where we diagnose usages outside of C++ lambdas.
And below are just the C++ extension warnings


================
Comment at: clang/test/CodeGenCXX/cxx20-decomposition.cpp:26
+// CHECK: %{{.*}} = load ptr, {{.*}}
+// CHECK: %{{.*}} = load i32, {{.*}}
+// CHECK: %{{.*}} = getelementptr {{.*}}, i32 0, i32 0
----------------
erichkeane wrote:
> cor3ntin wrote:
> > erichkeane wrote:
> > > Which is the important lines here?  You might want to use the `[[NAME:.whatever]]`  (then on the 'other' side: `[[NAME]]`)syntax in here to make sure that the check-lines don't find something else.
> > > 
> > > You also likely want to use `.+` to make sure there is actually a character in there.
> > > 
> > > 
> > I'm trying to show i is captured by value and j isn't
> Hmm... I don't think it is testing what you think you're testing, particularly with so many unnamed checks.  If you send me the IR that this produces and highlight which are the 'important' lines, I can help write this for you.
To be perfectly honest, I'm neither confident about which lines are important, nor whether the test case is as meaningful as it can be.
I'm happy to mail you the IR if you have time to look at it :)


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