[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 3 12:14:37 PDT 2018


simark added a comment.

In https://reviews.llvm.org/D48687#1150960, @hokein wrote:

> After taking a look closely, I figured why there are two candidates here -- one is from AST (the one with ".." path); the other one is from dynamic index, the deduplication failed because of the different paths :(
>
> I think the fixing way is to normalize the file path from AST (making it absolute).
>
> > +1 to sharing the code. I guess we're struggling with similar problems here. Any pointers to the functions we should use?
>
> Yeah, we struggled this problem in SymbolCollector. We cleanup the file path manually. I'd suggest abstract that logic from `toURI` (https://github.com/llvm-mirror/clang-tools-extra/blob/master/clangd/index/SymbolCollector.cpp#L80), and use it here.
>
> > I tried to make it as close as possible to the example in the bug report, but don't manage to reproduce the bug.
>
> To reproduce the issue, I think you'd also need to enable the dynamic index.


Thanks for looking into it.  In my unit test, the only path I receive is one without "..", although I don't use the dynamic index.  Still, I tried to enable the dynamic index using:

  auto Opts = ClangdServer::optsForTest();
  Opts.BuildDynamicSymbolIndex = true;
  ClangdServer Server(CDB, FS, DiagConsumer, Opts);

but it didn't change the result.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687





More information about the cfe-commits mailing list