Author: d0k Date: Tue Oct 6 09:45:16 2015 New Revision: 249409 URL: http://llvm.org/viewvc/llvm-project?rev=249409&view=rev Log: [VFS] Put the incoming name in the file status to make InMemoryFS behave more like a real FS.
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249409&r1=249408&r2=249409&view=diff ============================================================================== --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Tue Oct 6 09:45:16 2015 @@ -501,7 +501,7 @@ void InMemoryFileSystem::addFile(const T if (I == E) { // End of the path, create a new file. // FIXME: expose the status details in the interface. - Status Stat(Path, getNextVirtualUniqueID(), + Status Stat(P.str(), getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime, 0), 0, 0, Buffer->getBufferSize(), llvm::sys::fs::file_type::regular_file, Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=249409&r1=249408&r2=249409&view=diff ============================================================================== --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Tue Oct 6 09:45:16 2015 @@ -602,6 +602,19 @@ TEST_F(InMemoryFileSystemTest, Directory ASSERT_EQ(vfs::directory_iterator(), I); } +TEST_F(InMemoryFileSystemTest, WorkingDirectory) { + FS.setCurrentWorkingDirectory("/b"); + FS.addFile("c", 0, MemoryBuffer::getMemBuffer("")); + + auto Stat = FS.status("/b/c"); + ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); + ASSERT_EQ("c", Stat->getName()); + ASSERT_EQ("/b", *FS.getCurrentWorkingDirectory()); + + Stat = FS.status("c"); + ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); +} + // NOTE: in the tests below, we use '//root/' as our root directory, since it is // a legal *absolute* path on Windows as well as *nix. class VFSFromYAMLTest : public ::testing::Test { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits