diff options
author | Jan Korous <jkorous@apple.com> | 2019-02-14 23:02:35 +0000 |
---|---|---|
committer | Jan Korous <jkorous@apple.com> | 2019-02-14 23:02:35 +0000 |
commit | 85eb363d56d40b83880d310a1b53855a68e873c9 (patch) | |
tree | 0961300b38a0edd27ce2606e2d47a2a6627f6f1b /clang/unittests/Basic/FileManagerTest.cpp | |
parent | d5b017d601b483553f314db36c23aa1c11e0bb78 (diff) | |
download | bcm5719-llvm-85eb363d56d40b83880d310a1b53855a68e873c9.tar.gz bcm5719-llvm-85eb363d56d40b83880d310a1b53855a68e873c9.zip |
[clang][FileManager] fillRealPathName even if we aren't opening the file
The pathname wasn't previously filled when the getFile() method was called with openFile = false.
We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused the problem.
This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
rdar://47536127
Differential Revision: https://reviews.llvm.org/D58213
llvm-svn: 354075
Diffstat (limited to 'clang/unittests/Basic/FileManagerTest.cpp')
-rw-r--r-- | clang/unittests/Basic/FileManagerTest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 9f051976ca0..14c7879a091 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) { EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult); } +TEST_F(FileManagerTest, getFileDontOpenRealPath) { + auto statCache = llvm::make_unique<FakeStatCache>(); + statCache->InjectDirectory("/tmp/abc", 42); + SmallString<64> Path("/tmp/abc/foo.cpp"); + statCache->InjectFile(Path.str().str().c_str(), 43); + manager.setStatCache(std::move(statCache)); + + const FileEntry *file = manager.getFile(Path, /*openFile=*/false); + + ASSERT_TRUE(file != nullptr); + + ASSERT_EQ(file->tryGetRealPathName(), Path); +} + } // anonymous namespace |