[clangd] Collect the refs when the main file is header.
authorHaojian Wu <hokein@google.com>
Tue, 2 Jul 2019 09:16:21 +0000 (09:16 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 2 Jul 2019 09:16:21 +0000 (09:16 +0000)
commit7c251fa069a6f87be237fcd13191d7d0a95da0e4
treef3af3bd9d5a5409f6d8c360a1a7939af6089d57f
parent8d568d044cdc1d4e69f151f475a11dbb4b786ced
[clangd] Collect the refs when the main file is header.

Summary:
Previously, we only collect refs of the symbols which are declared in
the preamble and referenced in the main file, it works well when the
main file is .cpp file.

However, when the main file is .h file (when opening a .h file in the
editor), we don't collect refs of the symbol declared in this file, so we miss
these refs in our dynamic index.

A typical scenario:

1. Open Foo.h (which contains class Foo)
2. Open Foo.cpp, call find references for Foo

And we only get refs from Foo.cpp.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63818

llvm-svn: 364893
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp