Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit d7be359

Browse files
committed
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309795 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b24e937 commit d7be359

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Diff for: lib/Basic/FileManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ bool FileManager::makeAbsolutePath(SmallVectorImpl<char> &Path) const {
408408
bool Changed = FixupRelativePath(Path);
409409

410410
if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) {
411-
llvm::sys::fs::make_absolute(Path);
411+
FS->makeAbsolute(Path);
412412
Changed = true;
413413
}
414414

Diff for: unittests/Basic/FileManagerTest.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/Basic/FileManager.h"
1111
#include "clang/Basic/FileSystemOptions.h"
1212
#include "clang/Basic/FileSystemStatCache.h"
13+
#include "clang/Basic/VirtualFileSystem.h"
1314
#include "llvm/ADT/STLExtras.h"
1415
#include "llvm/Config/llvm-config.h"
1516
#include "llvm/Support/Path.h"
@@ -296,4 +297,30 @@ TEST_F(FileManagerTest, getVirtualFileWithDifferentName) {
296297

297298
#endif // !LLVM_ON_WIN32
298299

300+
TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
301+
SmallString<64> CustomWorkingDir;
302+
#ifdef LLVM_ON_WIN32
303+
CustomWorkingDir = "C:";
304+
#else
305+
CustomWorkingDir = "/";
306+
#endif
307+
llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path");
308+
309+
auto FS =
310+
IntrusiveRefCntPtr<vfs::InMemoryFileSystem>(new vfs::InMemoryFileSystem);
311+
// setCurrentworkingdirectory must finish without error.
312+
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
313+
314+
FileSystemOptions Opts;
315+
FileManager Manager(Opts, FS);
316+
317+
SmallString<64> Path("a/foo.cpp");
318+
319+
SmallString<64> ExpectedResult(CustomWorkingDir);
320+
llvm::sys::path::append(ExpectedResult, Path);
321+
322+
ASSERT_TRUE(Manager.makeAbsolutePath(Path));
323+
EXPECT_EQ(Path, ExpectedResult);
324+
}
325+
299326
} // anonymous namespace

0 commit comments

Comments
 (0)