[clang] [C++20][Modules] Fix incomplete decl chains (PR #129982)
Michael Park via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 5 21:02:05 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:
Yes, calling `redecls` or `getMostRecentDecl` (similar to [CXXRecordDecl::dataPtr](https://github.com/llvm/llvm-project/blob/e4c3d258b7a1f335cfd3a90bcf3d28ea220c999d/clang/include/clang/AST/DeclCXX.h#L457-L461) here would work as well. The reason I used this "pattern" here is because of [this code](https://github.com/llvm/llvm-project/blob/d6dbfd6f01710b8fed2303e66f60903efd2283f2/clang/lib/Sema/SemaType.cpp#L9257-L9262) at the end of the same function.
I'm very much open to refining the solution. I wanted to submit this PR now because the unit-test-level repro was something we were missing from #126973
https://github.com/llvm/llvm-project/pull/129982
More information about the cfe-commits
mailing list