[clang] [Clang][Modules] Fix generic lambda local capture mapping mismatch in template instantiation (PR #202248)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 14 18:55:30 PDT 2026


================
@@ -3454,9 +3454,21 @@ uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
   if (DC->decls_empty())
     return 0;
 
-  // In reduced BMI, we don't care the declarations in functions.
-  if (GeneratingReducedBMI && DC->isFunctionOrMethod())
-    return 0;
+  // In reduced BMI, we don't care the declarations in functions, unless they
+  // are templated functions, because their bodies may contain nested class/lambda
+  // definitions that are canonicalized and need mapping of local declarations.
+  if (GeneratingReducedBMI && DC->isFunctionOrMethod()) {
----------------
ChuanqiXu9 wrote:

It is possible to mix clang headers and named modules. My question is to understand the underlying problem. The code snippet is to avoid something to occur in the lexical lookup table. And my question is why we can't filter declarations in lexical lookup table.

If we can't understand this, we are not going to fix the real problem.

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


More information about the cfe-commits mailing list