From 85eb363d56d40b83880d310a1b53855a68e873c9 Mon Sep 17 00:00:00 2001 From: Jan Korous Date: Thu, 14 Feb 2019 23:02:35 +0000 Subject: [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 --- clang/unittests/Basic/FileManagerTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang/unittests/Basic/FileManagerTest.cpp') diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 9f05197..14c7879 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(); + 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 -- cgit v1.1