r250021 - [VFS] remove handling of '..' for now.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 02:22:07 PDT 2015


Author: d0k
Date: Mon Oct 12 04:22:07 2015
New Revision: 250021

URL: http://llvm.org/viewvc/llvm-project?rev=250021&view=rev
Log:
[VFS] remove handling of '..' for now.

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.

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=250021&r1=250020&r2=250021&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct 12 04:22:07 2015
@@ -497,7 +497,7 @@ void InMemoryFileSystem::addFile(const T
   assert(!EC);
   (void)EC;
 
-  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
   if (Path.empty())
     return;
 
@@ -556,7 +556,7 @@ lookupInMemoryNode(const InMemoryFileSys
   assert(!EC);
   (void)EC;
 
-  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
   if (Path.empty())
     return Dir;
 

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=250021&r1=250020&r2=250021&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Mon Oct 12 04:22:07 2015
@@ -569,7 +569,6 @@ TEST_F(InMemoryFileSystemTest, OverlayFi
 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, OpenFileF
   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) {




More information about the cfe-commits mailing list