[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 11:19:00 PDT 2024


================
@@ -19000,7 +19056,7 @@ bool Sema::tryCaptureVariable(
     Explicit = false;
     FunctionScopesIndex--;
     if (IsInScopeDeclarationContext)
-      DC = ParentDC;
+      DC = skipRequiresBody(ParentDC);
----------------
mizvekov wrote:

That is one of your tests actually:

`clang/test/SemaCXX/lambda-unevaluated.cpp`
```C++
// GH88081: Test if we evaluate the requires expression with lambda captures properly.
namespace GH88081 {

// Test that ActOnLambdaClosureQualifiers() is called only once.
void foo(auto value)
  requires requires { [&] -> decltype(value) {}; }
  // expected-error at -1 {{non-local lambda expression cannot have a capture-default}}
{}
```

The difference is that now the requires expression is properly reparented to `foo`, where as before it would just sit at the namespace.

https://github.com/llvm/llvm-project/pull/107942


More information about the cfe-commits mailing list