[clang] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 9 19:32:06 PDT 2025


================
@@ -9180,6 +9180,12 @@ bool Sema::hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
   if (!getLangOpts().Modules && !getLangOpts().ModulesLocalVisibility)
     return true;
 
+  // The external source may have additional definitions of this entity that are
+  // visible, so complete the redeclaration chain now.
+  if (auto *Source = Context.getExternalSource()) {
+    Source->CompleteRedeclChain(D);
+  }
----------------
ChuanqiXu9 wrote:

@mpark thanks for the analysis. It is pretty clear. And I am wondering, why it was not a problem but it is after we delay pending the complete decl chain? Maybe this can help us to understand the problem better.

>  it seems like the decls inside DC should be notified of the fact that there have been new additions made to Lookups[DC].Table... but on the other hand, it's not clear to me whether this is an expected sequence of events in the first place.

I did similar experiments but it shows it has a pretty bad performance. And I don't feel it is wanted. We have similar (but not the same mechanism for `hasNeedToReconcileExternalVisibleStorage()`)

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


More information about the cfe-commits mailing list