diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-07-31 00:58:32 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-07-31 00:58:32 +0000 |
| commit | b1716d63b0dc6c882dc4cfa983df73b34184dc3a (patch) | |
| tree | 5cb5a9e3c0f660a5efc3ede745d1696d6e2ba7e0 /lib/Basic/FileManager.cpp | |
| parent | d50fd8aa0d9d35689ae70ed56f9245625d3456d2 (diff) | |
[modules] Fix issue where building a module from a relative path when -working-directory option is set, results in error.
The error was "module '<name>' was built in directory '<path>' but now resides in directory '<path>'
rdar://21330027
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/FileManager.cpp')
| -rw-r--r-- | lib/Basic/FileManager.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 4c84f1b6ad..034ebc5c88 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -389,16 +389,28 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size, return UFE; } -void FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const { +bool FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const { StringRef pathRef(path.data(), path.size()); if (FileSystemOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(pathRef)) - return; + return false; SmallString<128> NewPath(FileSystemOpts.WorkingDir); llvm::sys::path::append(NewPath, pathRef); path = NewPath; + return true; +} + +bool FileManager::makeAbsolutePath(SmallVectorImpl<char> &Path) const { + bool Changed = FixupRelativePath(Path); + + if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) { + llvm::sys::fs::make_absolute(Path); + Changed = true; + } + + return Changed; } llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> |
