================
@@ -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, okay... so the `DC->lookup(Name)` have different behaviors because of
[`Source->FindExternalVisibleDeclsByName(...)`](https://github.com/llvm/llvm-project/blob/release/20.x/clang/lib/AST/DeclBase.cpp#L1913).
In `ASTReader::FindExternalVisibleDeclsByName`, we get to
[here](https://github.com/llvm/llvm-project/blob/c6d95c441a29a45782ff72d6cb82839b86fd0e4a/clang/lib/Serialization/ASTReader.cpp#L8494-L8501)
looking through `Lookups` data structure. In the first call,
`Lookups[DC].Table[Name]` has 1 entry (just a decl), whereas in the second call
it has 2 entries (the decl and a defn).
In summary, we have `LazyGenerationalUpdatePtr::get` calling
`CompleteRedeclChain` where `Lookups` isn't populated with the definition, and
updates the generation number. The second time `LazyGenerationUpdatePtr::get`
is called, `Lookups` **is** populated with the definition, but the generation
number matches, and so it doesn't call `CompleteRedeclChain` even though it
would yield a different result.
https://github.com/llvm/llvm-project/pull/129982
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits