[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 26 08:20:51 PDT 2024


================
@@ -4006,6 +4007,37 @@ class TreeTransform {
                                       NumExpansions);
   }
 
+  void RebuildLambdaExprImpl(SourceLocation StartLoc, SourceLocation EndLoc,
+                             LambdaScopeInfo *LSI) {}
+
+  ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
+                               LambdaScopeInfo *LSI) {
+    CXXRecordDecl *Class = LSI->Lambda;
+    CXXMethodDecl *CallOperator = LSI->CallOperator;
+    CallOperator->setLexicalDeclContext(Class);
+    Decl *TemplateOrNonTemplateCallOperatorDecl =
+        CallOperator->getDescribedFunctionTemplate()
+            ? CallOperator->getDescribedFunctionTemplate()
+            : cast<Decl>(CallOperator);
+    // FIXME: Is this really the best choice? Keeping the lexical decl context
+    // set as CurContext seems more faithful to the source.
+    TemplateOrNonTemplateCallOperatorDecl->setLexicalDeclContext(Class);
----------------
zyn0217 wrote:

I copied these lines from `BuildLambdaExpr()` because the default argument instantiation needs the function decl context to be set to get a correct name mangling.

The code is not organized perfectly. However, I didn't devise another approach for propagating the flag after the instantiation.

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


More information about the cfe-commits mailing list