]> granicus.if.org Git - clang/commitdiff
[VFS] remove handling of '..' for now.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 12 Oct 2015 09:22:07 +0000 (09:22 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 12 Oct 2015 09:22:07 +0000 (09:22 +0000)
This can fail badly if we're overlaying a real file system and there are
symlinks there. Just keep the path as-is for now.

This essentially reverts r249830.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250021 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/VirtualFileSystem.cpp
unittests/Basic/VirtualFileSystemTest.cpp

index ced370c6f3577f0090b68d190315c89813b2b3a9..cb09e2ec84f326e9f1bc16a06c9cc68ee8a8ee99 100644 (file)
@@ -497,7 +497,7 @@ void InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
   assert(!EC);
   (void)EC;
 
-  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
   if (Path.empty())
     return;
 
@@ -556,7 +556,7 @@ lookupInMemoryNode(const InMemoryFileSystem &FS, detail::InMemoryDirectory *Dir,
   assert(!EC);
   (void)EC;
 
-  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
   if (Path.empty())
     return Dir;
 
index b98e999cd6018c26791eee11fe70a08e3c29283d..6ed811f22f3f9725b95d101534623841935b0a01 100644 (file)
@@ -569,7 +569,6 @@ TEST_F(InMemoryFileSystemTest, OverlayFileNoOwn) {
 TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
   FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
   FS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
-  FS.addFile("./d/../d", 0, MemoryBuffer::getMemBuffer("d"));
   auto File = FS.openFileForRead("/a");
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/a"); // Open again.
@@ -582,8 +581,6 @@ TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
   ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) << FS.toString();
   File = FS.openFileForRead("./c");
   ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer());
-  File = FS.openFileForRead("e/../d");
-  ASSERT_EQ("d", (*(*File)->getBuffer("ignored"))->getBuffer());
 }
 
 TEST_F(InMemoryFileSystemTest, DirectoryIteration) {