[clang] [C++20][Modules] Fix incomplete decl chains (PR #129982)

Michael Park via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 6 00:42:27 PST 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);
+  }
----------------
mpark wrote:

Hm, is that right? when I step through `getDefinition` for [4]:
```cpp
CXXRecordDecl *getDefinition() const {
  // We only need an update if we don't already know which
  // declaration is the definition.
  auto *DD = DefinitionData ? DefinitionData : dataPtr();
  return DD ? DD->Definition : nullptr;
}
```
I see that `DefinitionData` is `nullptr`, followed by `DD` also being `nullptr`.

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


More information about the cfe-commits mailing list