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

Ivo Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 21: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
----------------
ipopov wrote:

I've tried to reduce this to the cases that seem to matter to Sema. Does this seem like less overhead?

An alternative idea is to avoid fixing this bug for C++20 modules, but only do it for header-modules, in this PR; revert changes to ASTWriter.cpp here; and move them to another pull request. LMK what you would prefer!

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


More information about the cfe-commits mailing list