[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
Wed Jan 22 04:17:13 PST 2025


================
@@ -799,14 +817,12 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   }
 
   if (D->getFriendObjectKind()) {
-    // For a function defined inline within a class template, we have to force
-    // the canonical definition to be the one inside the canonical definition of
-    // the template. Remember this relation to deserialize them together.
-    if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent()))
-      if (RD->isDependentContext() && RD->isThisDeclarationADefinition()) {
-        Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
-            Writer.GetDeclRef(D));
-      }
+    // For a friend function defined inline within a class template, we have to
+    // force the definition to be the one inside the definition of the template
+    // class. Remember this relation to deserialize them together.
+    if (auto *RD = getDependentDeclContext<CXXRecordDecl>(D))
----------------
dmpolukhin wrote:

You are right, it was unintended change in behaviour, reverted to tested version. Thank you for catching it!

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


More information about the cfe-commits mailing list