[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 21 02:37:56 PST 2025


================
@@ -1571,9 +1571,10 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
     } else {
       Record.push_back(0);
     }
-    // For lambdas inside canonical FunctionDecl remember the mapping.
+    // For lambdas inside template functions, remember the mapping to
+    // deserialize them together.
     if (auto FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
-        FD && FD->isCanonicalDecl()) {
+        FD && FD->isDependentContext() && FD->isThisDeclarationADefinition()) {
----------------
dmpolukhin wrote:

But types are different and `isThisDeclarationADefinition` is not a virtual function. Moreover I'm not sure that conditions will be the same in future so extracting them to a function might be a wrong hint.

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


More information about the cfe-commits mailing list