[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 03:31:40 PST 2024
================
@@ -13905,6 +13911,31 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
/*IsInstantiation*/ true);
SavedContext.pop();
+ // Recompute the dependency of the lambda so that we can defer the lambda call
+ // construction until after we have sufficient template arguments. For
+ // example, template <class> struct S {
+ // template <class U>
+ // using Type = decltype([](U){}(42.0));
+ // };
+ // void foo() {
+ // using T = S<int>::Type<float>;
+ // ^~~~~~
+ // }
+ // We would end up here from instantiating the S<int> as we're ensuring the
+ // completeness. That would make us transform the lambda call expression
+ // despite the fact that we don't see the argument for U yet. We have a
+ // mechanism that circumvents the semantic checking if the CallExpr is
+ // dependent. We can harness that by recomputing the lambda dependency from
+ // the instantiation arguments. I'm putting it here rather than the above
+ // since we can see transformed lambda parameters in case that they're
+ // useful for calculation.
+ DependencyKind = getDerived().ComputeLambdaDependency(&LSICopy);
+ Class->setLambdaDependencyKind(DependencyKind);
+ // Clean up the type cache created previously. Then, we re-create a type for
+ // such Decl with the new DependencyKind.
+ Class->setTypeForDecl(nullptr);
+ getSema().Context.getTypeDeclType(Class);
+
----------------
cor3ntin wrote:
This is not great, but I am not sure how we can improve.
I think it's worth a fixme
@erichkeane
https://github.com/llvm/llvm-project/pull/82310
More information about the cfe-commits
mailing list