[PATCH] D49197: FileManager: Try to compute RealPathName in getVirtualFile

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 12 06:17:04 PDT 2018


simark added a comment.

In https://reviews.llvm.org/D49197#1159704, @ioeric wrote:

> In https://reviews.llvm.org/D49197#1158972, @simark wrote:
>
> > Background:  I'm trying to fix the cases why we receive a FileEntry without a real path computed in clangd, so we can avoid having to compute it ourselves.
>
>
> I'm curious how you use `getVirtualFile` in your clangd tests. In general, I'd highly recommend virtual file system in favor of remapped files for clangd tests.


I don't use getVirtualFile directly.  I just use `ClangdServer` and look at the paths it outputs.  It just happens that for some file, clang first opened it internally using `getVirtualFile` before using `getFile`, so the real path ends up missing`.  Patch https://reviews.llvm.org/D48687 adds code to compensate that, but I added some logging to know when it happens, so we can try to fix it at the root (ideally, clang could always give us the real path so we don't have to compute it ourselves):

  ./tools/clang/tools/extra/unittests/clangd/ClangdTests --gtest_filter='*RelPathsInCompileCommand*'
  Note: Google Test filter = *RelPathsInCompileCommand*
  [==========] Running 1 test from 1 test case.
  [----------] Global test environment set-up.
  [----------] 1 test from GoToDefinition
  [ RUN      ] GoToDefinition.RelPathsInCompileCommand
  Updating file /clangd-test/src/foo.cpp with command [/clangd-test/build] clang -ffreestanding ../src/foo.cpp -resource-dir=/home/emaisin/build/llvm/tools/clang/tools/extra/unittests/clangd/../lib/clang/7.0.0
  Preamble for file /clangd-test/src/foo.cpp cannot be reused. Attempting to rebuild it.
  Built preamble of size 171284 for file /clangd-test/src/foo.cpp
  FileEntry for ../src/foo.cpp did not contain the real path.     <<<<< HERE
  FileEntry for /clangd-test/src/header_in_preamble.h did not contain the real path.     <<<<< AND HERE
  [       OK ] GoToDefinition.RelPathsInCompileCommand (42 ms)
  [----------] 1 test from GoToDefinition (42 ms total)
  
  [----------] Global test environment tear-down
  [==========] 1 test from 1 test case ran. (43 ms total)
  [  PASSED  ] 1 test.

I'm investigating why clang failed to provide that to us in these two cases.


Repository:
  rC Clang

https://reviews.llvm.org/D49197





More information about the cfe-commits mailing list