HighCommander4 wrote:

I debugged this some more.

> somehow the references are lost when information collected while indexing one 
> translation unit is merged with information collected while indexing others

This hypothesis was wrong. Things already fail at the SymbolCollector level: 
whether the codepath that discovers the reference in the first place is hit, 
can depend on what **other** translation units have been indexed previously.

This time, the reason **is** related to the "skip function body" stuff that we 
discussed 
[earlier](https://github.com/llvm/llvm-project/pull/169742#issuecomment-3652029909).
 Basically, if a previously indexed translation unit has included the header 
that defines the forwarding function, then the header gets marked as "already 
indexed", and during SymbolCollector runs for subsequent translation units, the 
parsing of function bodies in this header is skipped. As a result, the 
forwarding function (the template itself, not just the instantiation) can be 
missing its function body when we need it.

The relevant logic for skipping function bodies is 
[here](https://searchfox.org/llvm/rev/42b3483ac4987cae1bdb632398e8a3ce2dea6633/clang-tools-extra/clangd/index/IndexAction.cpp#143-153).
 Adding a carveout for likely-forwarding-functions there (to traverse them 
without regard to what `shouldIndexFile` says) seems to fix the issue.

https://github.com/llvm/llvm-project/pull/169742
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to