r309795 - Use VFS operations in FileManager::makeAbsolutePath.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 2 00:25:24 PDT 2017
Author: ibiryukov
Date: Wed Aug 2 00:25:24 2017
New Revision: 309795
URL: http://llvm.org/viewvc/llvm-project?rev=309795&view=rev
Log:
Use VFS operations in FileManager::makeAbsolutePath.
Summary: It used to call into llvm::sys::fs::make_absolute.
Reviewers: akyrtzi, erikjv, bkramer, krasimir, klimek
Reviewed By: klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D36155
Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp
Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=309795&r1=309794&r2=309795&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Wed Aug 2 00:25:24 2017
@@ -408,7 +408,7 @@ bool FileManager::makeAbsolutePath(Small
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;
}
Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=309795&r1=309794&r2=309795&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Wed Aug 2 00:25:24 2017
@@ -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 @@ TEST_F(FileManagerTest, getVirtualFileWi
#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
More information about the cfe-commits
mailing list