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

2018-08-23 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments. Herald added a subscriber: kadircet. Comment at: clangd/SourceCode.cpp:209 + llvm::SmallString<128> RealPath; + if (SourceMgr.getFileManager().getVirtualFileSystem()->getRealPath( + Path, RealPath)) { With the recent perfo

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

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
simark added inline comments. Comment at: clangd/SourceCode.h:65 /// Get the absolute file path of a given file entry. TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M, hokein wrote: > nit: this comment is not needed. Woops, merge mistake.

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

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE339483: [clangd] Avoid duplicates in findDefinitions response (authored by simark, committed by ). Changed prior to commit: https://reviews.llvm.org/D48687?vs=160175&id=160197#toc Repository: rCTE

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

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 160175. simark marked 4 inline comments as done. simark added a comment. Latest update. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 Files: clangd/FindSymbols.cpp clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp u

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

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
simark marked an inline comment as done. simark added a comment. In https://reviews.llvm.org/D48687#1195840, @hokein wrote: > Looks good with a few nits. Looks like you didn't update the patch correctly. > You have marked comments done, but your code doesn't get changed accordingly. > Please do

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

2018-08-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. Looks good with a few nits. Looks like you didn't update the patch correctly. You have marked comments done, but your code doesn't get changed accordingly. Please double check with it. I trie

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

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 8 inline comments as done. simark added inline comments. Comment at: clangd/SourceCode.h:69 +llvm::Optional getRealPath(const FileEntry *F, +const SourceManager &SourceMgr); ilya-biryukov wrote: > This funct

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

2018-08-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. Only a few NITs from my side. Excited for this fix to get in, have been seeing duplicate in other cases too :-) Comment at: clangd/SourceCode.h:69 +llvm::Optional getRealPath(const FileEntry *F, +const So

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

2018-08-09 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 159972. simark marked an inline comment as done. simark added a comment. Replace RelPathPrefix == StringRef() with RelPathPrefix.empty() Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 Files: clangd/FindSymbols.cpp clangd/Sou

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

2018-08-09 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 3 inline comments as done. simark added a comment. In https://reviews.llvm.org/D48687#1193470, @hokein wrote: > Sorry for the delay. I thought there was a dependent patch of this patch, but > it seems resolved, right? > > A rough round of review. Right, the patch this one depends

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

2018-08-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment. Sorry for the delay. I thought there was a dependent patch of this patch, but it seems resolved, right? A rough round of review. > New version. I tried to share the code between this and SymbolCollector, but > didn't find a good clean way. Do you have concrete suggestio

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

2018-08-08 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 159768. simark added a comment. Formatting. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 Files: clangd/FindSymbols.cpp clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp unittests/clangd/TestFS.cpp unittests/clang

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

2018-08-08 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 159764. simark added a comment. Herald added a subscriber: arphaman. New version. I tried to share the code between this and SymbolCollector, but didn't find a good clean way. Do you have concrete suggestions on how to do this? Otherwise, would it be accepta

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

2018-07-11 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 155057. simark added a comment. This is an update of my work in progress. I haven't done any sharing with SymbolCollector, as it's not clear to me how to proceed with that. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 Files: clang

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

2018-07-10 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment. Herald added a subscriber: omtcyfz. I took a look at `SymbolCollector`'s `toURI`, and I am not sure what to get from it. It seems like a lot of it could be replaced with a call to `FileSystem::getRealPath`. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/

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

2018-07-04 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. > I think the fixing way is to normalize the file path from AST (making it > absolute). Totally agree. Could we run the code used to get the URI to store in the dynamic index? Should we expose and reuse code in `getSymbolLocation()` from `SymbolCollector.cpp`?

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

2018-07-03 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment. An update, I traced the difference in behavior to the difference in how `RealFileSystem` and `InMemoryFileSystem` return `Status`es. I uploaded a patch to change `InMemoryFileSystem` to work like `RealFileSystem`: https://reviews.llvm.org/D48903 With this patch applied

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

2018-07-03 Thread Simon Marchi via Phabricator via cfe-commits
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 p

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

2018-07-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment. 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

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

2018-06-28 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment. FYI, I have uploaded my attempt at writing a unit test here: https://reviews.llvm.org/D48726 I tried to make it as close as possible to the example in the bug report, but don't manage to reproduce the bug. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/

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

2018-06-28 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment. Btw, this seems to happen only when the included header is in the preamble. If I put a variable declaration before `#include "first.h"`, things work as expected, we have not duplicates and the path is normalized. Repository: rCTE Clang Tools Extra https://reviews.ll

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

2018-06-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. I'm somewhat familiar with the internals of clang around the FileManager/VFS, so I could try creating the repro of this issue. The bugreport has enough info to get started. (Probably tomorrow, I certainly won't get to it today). In https://reviews.llvm.org/D48687#

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

2018-06-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment. > Could we try to figure out why the duplicates were there in the first place > and why the paths were different? +1, I think there are two issues here: 1. the result contains two candidates, which should be one, IIUC. 2. the absolute file path problem, we encountered si

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

2018-06-28 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment. In https://reviews.llvm.org/D48687#1146515, @simark wrote: > In https://reviews.llvm.org/D48687#1146308, @ilya-biryukov wrote: > > > Thanks for the patch! > > Could we try to figure out why the duplicates were there in the first > > place and why the paths were diffe

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

2018-06-28 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment. In https://reviews.llvm.org/D48687#1146308, @ilya-biryukov wrote: > Thanks for the patch! > Could we try to figure out why the duplicates were there in the first place > and why the paths were different? I tried to do that, but it goes deep in the clang internals with

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

2018-06-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. Also some heads-up: this would probably conflict https://reviews.llvm.org/D47846 that moves the same function into a different file. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 ___ cfe-commi

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

2018-06-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. Thanks for the patch! Could we try to figure out why the duplicates were there in the first place and why the paths were different? It should be easy to mock exactly the same setup you have in #37963, i.e. create a vfs with three files and compilation database tha

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

2018-06-27 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision. Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov. When compile_commands.json contains some source files expressed as relative paths, we can get duplicate responses to findDefinitions. The responses only differ by the URI, which are diffe