[clang] [Clang] Keep lambdas in default template arguments dependent until used (PR #222541)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 03:22:08 PDT 2026
================
@@ -16304,11 +16308,13 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
// (A ClassTemplateSpecializationDecl is always a dependent context.)
while (DC->isRequiresExprBody() || isa<CXXExpansionStmtDecl>(DC))
DC = DC->getParent();
- if ((getSema().isUnevaluatedContext() ||
- getSema().isConstantEvaluatedContext()) &&
- !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
- cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
- (DC->isFileContext() || !DC->getParent()->isDependentContext()))
+ if (getDerived().IsLambdaAlwaysDependent())
+ DependencyKind = CXXRecordDecl::LDK_AlwaysDependent;
----------------
zyn0217 wrote:
This is very wrong: so we stop crashing because we would never build a correct CallExpr to the lambda object, and for sure this will also prevent semantic analysis for those expressions forever!
And in fact the underlying problem is never the dependency one, it's a depth mismatching issue as in https://github.com/llvm/llvm-project/issues/176405#issuecomment-3888447293. That is, our template deduction stopped working for this case, and that's why we don't have a correct instantiated parameter list even we have enough template arguments.
https://github.com/llvm/llvm-project/pull/222541
More information about the cfe-commits
mailing list