[PATCH] D36155: Use VFS operations in FileManager::makeAbsolutePath.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 2 00:26:07 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL309795: Use VFS operations in FileManager::makeAbsolutePath. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D36155

Files:
  cfe/trunk/lib/Basic/FileManager.cpp
  cfe/trunk/unittests/Basic/FileManagerTest.cpp


Index: cfe/trunk/lib/Basic/FileManager.cpp
===================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp
+++ cfe/trunk/lib/Basic/FileManager.cpp
@@ -408,7 +408,7 @@
   bool Changed = FixupRelativePath(Path);
 
   if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) {
-    llvm::sys::fs::make_absolute(Path);
+    FS->makeAbsolute(Path);
     Changed = true;
   }
 
Index: cfe/trunk/unittests/Basic/FileManagerTest.cpp
===================================================================
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/FileSystemStatCache.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Path.h"
@@ -296,4 +297,30 @@
 
 #endif  // !LLVM_ON_WIN32
 
+TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
+  SmallString<64> CustomWorkingDir;
+#ifdef LLVM_ON_WIN32
+  CustomWorkingDir = "C:";
+#else
+  CustomWorkingDir = "/";
+#endif
+  llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path");
+
+  auto FS =
+      IntrusiveRefCntPtr<vfs::InMemoryFileSystem>(new vfs::InMemoryFileSystem);
+  // setCurrentworkingdirectory must finish without error.
+  ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
+
+  FileSystemOptions Opts;
+  FileManager Manager(Opts, FS);
+
+  SmallString<64> Path("a/foo.cpp");
+
+  SmallString<64> ExpectedResult(CustomWorkingDir);
+  llvm::sys::path::append(ExpectedResult, Path);
+
+  ASSERT_TRUE(Manager.makeAbsolutePath(Path));
+  EXPECT_EQ(Path, ExpectedResult);
+}
+
 } // anonymous namespace


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36155.109286.patch
Type: text/x-patch
Size: 1793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170802/1de1139d/attachment.bin>


More information about the cfe-commits mailing list