[clangd] Use expansion location when the ref is inside macros.
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 9 Dec 2019 11:00:42 +0000 (12:00 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Mon, 9 Dec 2019 15:34:01 +0000 (16:34 +0100)
commitdecdbc1155f5120554269319b1c77675bac9151c
tree47c80bd662141f2795e671ebdd76bdc67f910341
parent6626e5a06a99b29b388f2dffde2c16f8eb5ded46
[clangd] Use expansion location when the ref is inside macros.

Summary:
Previously, xrefs has inconsistent behavior when the reference is inside
macro body:
- AST-based xrefs (for main file) uses the expansion location;
- our index uses the spelling location;

This patch makes our index use file locations for references, which is
consistent with AST-based xrefs, and kythe as well.

After this patch, memory usage of static index on LLVM increases ~5%.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70480
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp