From cd8607db2d25f96c36b5eac6406f39ac15ac8894 Mon Sep 17 00:00:00 2001 From: Jan Korous Date: Mon, 18 Feb 2019 22:33:40 +0000 Subject: Reland "[clang][FileManager] fillRealPathName even if we aren't opening the file" This reverts commit e2bb3121fd4ab5b01f9ec1d2e3e9877db9c6a54c. + fixed test for Windows llvm-svn: 354291 --- clang/unittests/Basic/FileManagerTest.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'clang/unittests/Basic/FileManagerTest.cpp') diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 9f05197..5262dad 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -346,4 +346,33 @@ TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) { EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult); } +TEST_F(FileManagerTest, getFileDontOpenRealPath) { + SmallString<64> CustomWorkingDir; +#ifdef _WIN32 + CustomWorkingDir = "C:/"; +#else + CustomWorkingDir = "/"; +#endif + + auto FS = IntrusiveRefCntPtr( + new llvm::vfs::InMemoryFileSystem); + // setCurrentworkingdirectory must finish without error. + ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir)); + + FileSystemOptions Opts; + FileManager Manager(Opts, FS); + + 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