[clangd] findNearbyIdentifier(): guaranteed to give up after 2^N lines
authorAleksandr Platonov <platonov.aleksandr@huawei.com>
Tue, 29 Sep 2020 16:54:33 +0000 (19:54 +0300)
committerAleksandr Platonov <platonov.aleksandr@huawei.com>
Tue, 29 Sep 2020 16:54:55 +0000 (19:54 +0300)
commitd8ba6b4ab3eceb6bbcdf4371d4ffaab9d1a5cebe
treedc0968b6ede3bf2680bd638c7e40af8d30f37389
parent2159ed811f96cb1aefecf3369d80e69e06fd32a3
[clangd] findNearbyIdentifier(): guaranteed to give up after 2^N lines

As @kadircet mentions in D84912#2184144, `findNearbyIdentifier()` traverses the whole file if there is no identifier for the word.
This patch ensures give up after 2^N lines in any case.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D87891
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp