[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 4 20:07:18 PDT 2024


================
@@ -80,6 +80,81 @@ struct Response {
     return R;
   }
 };
+
+// Retrieve the primary template for a lambda call operator. It's
+// unfortunate that we only have the mappings of call operators rather
+// than lambda classes.
+const FunctionDecl *
+getPrimaryTemplateOfGenericLambda(const FunctionDecl *LambdaCallOperator) {
+  while (true) {
----------------
zyn0217 wrote:

(Sorry for replying this late, I just got around to this PR.)

> What cases do we have where this takes more than 1 step?
The lambda itself might be defined within a template, and I presume transforming that template introduces multilevel mappings.

> I also wonder if we'd be better off finding the primary `CXXRecordDecl`, then picking it up from there? We could use `getTemplateInstantiationPattern` then `getDescribedClassTemplate` I think?

If we examine `TemplateInstantiator::transformedLocalDecl`, we'd see there's only handling for `CXXMethodDecls` of adding such mappings that we can extract from the Decls themselves. I think it is possible that we can use the primary `CXXRecordDecl` approach, although looking for that Decl might involve handling `LocalInstantiationScopes`, which IMO is not super straightforward.

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


More information about the cfe-commits mailing list