[clang] [clang] Fixed predefined expressions after lambda parameters (PR #211811)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 08:16:29 PDT 2026


================
@@ -2116,7 +2116,13 @@ static PredefinedIdentKind getPredefinedExprKind(tok::TokenKind Kind) {
 /// getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used
 /// to determine the value of a PredefinedExpr. This can be either a
 /// block, lambda, captured statement, function, otherwise a nullptr.
-static Decl *getPredefinedExprDecl(DeclContext *DC) {
+static Decl *getPredefinedExprDecl(Sema &S, DeclContext *DC) {
+  if (isLambdaCallOperator(DC)) {
+    LambdaScopeInfo *LSI = S.getCurLambda();
+    if (LSI->BeforeCompoundStatement) {
+      DC = DC->getParent();
+    }
+  }
----------------
cor3ntin wrote:

I think if we are for example in a requires block of a lambda expression we still get the wrong context.
This entiere `if` needs to be in the while loop below

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


More information about the cfe-commits mailing list