summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp5
-rw-r--r--llvm/include/llvm/Support/FileSystem.h5
-rw-r--r--llvm/lib/Support/Path.cpp33
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp3
-rw-r--r--llvm/tools/llvm-opt-report/OptReport.cpp9
-rw-r--r--llvm/unittests/Support/Path.cpp2
6 files changed, 24 insertions, 33 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 5b827b13c07..c65fb47c0fe 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1678,9 +1678,8 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
StringRef Dir = SearchDirs[I].getDir()->getName();
llvm::SmallString<32> DirPath(Dir.begin(), Dir.end());
if (!WorkingDir.empty() && !path::is_absolute(Dir)) {
- auto err = fs::make_absolute(WorkingDir, DirPath);
- if (!err)
- path::remove_dots(DirPath, /*remove_dot_dot=*/true);
+ fs::make_absolute(WorkingDir, DirPath);
+ path::remove_dots(DirPath, /*remove_dot_dot=*/true);
Dir = DirPath;
}
for (auto NI = path::begin(File), NE = path::end(File),
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h
index 827e2e91eea..d2042f51d8c 100644
--- a/llvm/include/llvm/Support/FileSystem.h
+++ b/llvm/include/llvm/Support/FileSystem.h
@@ -302,10 +302,7 @@ public:
/// relative/../path => <current-directory>/relative/../path
///
/// @param path A path that is modified to be an absolute path.
-/// @returns errc::success if \a path has been made absolute, otherwise a
-/// platform-specific error_code.
-std::error_code make_absolute(const Twine &current_directory,
- SmallVectorImpl<char> &path);
+void make_absolute(const Twine &current_directory, SmallVectorImpl<char> &path);
/// Make \a path an absolute path.
///
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index a3e6941bd62..5ce2f50ebda 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -849,9 +849,8 @@ getPotentiallyUniqueTempFileName(const Twine &Prefix, StringRef Suffix,
return createTemporaryFile(Prefix, Suffix, Dummy, ResultPath, FS_Name);
}
-static std::error_code make_absolute(const Twine &current_directory,
- SmallVectorImpl<char> &path,
- bool use_current_directory) {
+void make_absolute(const Twine &current_directory,
+ SmallVectorImpl<char> &path) {
StringRef p(path.data(), path.size());
bool rootDirectory = path::has_root_directory(p);
@@ -860,14 +859,11 @@ static std::error_code make_absolute(const Twine &current_directory,
// Already absolute.
if (rootName && rootDirectory)
- return std::error_code();
+ return;
// All of the following conditions will need the current directory.
SmallString<128> current_dir;
- if (use_current_directory)
- current_directory.toVector(current_dir);
- else if (std::error_code ec = current_path(current_dir))
- return ec;
+ current_directory.toVector(current_dir);
// Relative path. Prepend the current directory.
if (!rootName && !rootDirectory) {
@@ -875,7 +871,7 @@ static std::error_code make_absolute(const Twine &current_directory,
path::append(current_dir, p);
// Set path to the result.
path.swap(current_dir);
- return std::error_code();
+ return;
}
if (!rootName && rootDirectory) {
@@ -884,7 +880,7 @@ static std::error_code make_absolute(const Twine &current_directory,
path::append(curDirRootName, p);
// Set path to the result.
path.swap(curDirRootName);
- return std::error_code();
+ return;
}
if (rootName && !rootDirectory) {
@@ -896,20 +892,23 @@ static std::error_code make_absolute(const Twine &current_directory,
SmallString<128> res;
path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath);
path.swap(res);
- return std::error_code();
+ return;
}
llvm_unreachable("All rootName and rootDirectory combinations should have "
"occurred above!");
}
-std::error_code make_absolute(const Twine &current_directory,
- SmallVectorImpl<char> &path) {
- return make_absolute(current_directory, path, true);
-}
-
std::error_code make_absolute(SmallVectorImpl<char> &path) {
- return make_absolute(Twine(), path, false);
+ if (path::is_absolute(path))
+ return {};
+
+ SmallString<128> current_dir;
+ if (std::error_code ec = current_path(current_dir))
+ return ec;
+
+ make_absolute(current_dir, path);
+ return {};
}
std::error_code create_directories(const Twine &Path, bool IgnoreExisting,
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 29730272055..f2a8a1bb27a 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -128,7 +128,8 @@ std::error_code FileSystem::makeAbsolute(SmallVectorImpl<char> &Path) const {
if (!WorkingDir)
return WorkingDir.getError();
- return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+ llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+ return {};
}
std::error_code FileSystem::getRealPath(const Twine &Path,
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp
index 071f779a9e6..0c4bc94d8e4 100644
--- a/llvm/tools/llvm-opt-report/OptReport.cpp
+++ b/llvm/tools/llvm-opt-report/OptReport.cpp
@@ -231,13 +231,8 @@ static bool writeReport(LocationInfoTy &LocationInfo) {
bool FirstFile = true;
for (auto &FI : LocationInfo) {
SmallString<128> FileName(FI.first);
- if (!InputRelDir.empty()) {
- if (std::error_code EC = sys::fs::make_absolute(InputRelDir, FileName)) {
- WithColor::error() << "Can't resolve file path to " << FileName << ": "
- << EC.message() << "\n";
- return false;
- }
- }
+ if (!InputRelDir.empty())
+ sys::fs::make_absolute(InputRelDir, FileName);
const auto &FileInfo = FI.second;
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 21a6aab73af..97b77e2dfed 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -187,7 +187,7 @@ TEST(Support, Path) {
}
SmallString<32> Relative("foo.cpp");
- ASSERT_NO_ERROR(sys::fs::make_absolute("/root", Relative));
+ sys::fs::make_absolute("/root", Relative);
Relative[5] = '/'; // Fix up windows paths.
ASSERT_EQ("/root/foo.cpp", Relative);
}
OpenPOWER on IntegriCloud