aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Support/PathV2.cpp5
-rw-r--r--unittests/Support/Path.cpp3
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp
index 7bb7988..9c343ea 100644
--- a/lib/Support/PathV2.cpp
+++ b/lib/Support/PathV2.cpp
@@ -553,6 +553,11 @@ error_code native(const Twine &path, SmallVectorImpl<char> &result) {
return make_error_code(errc::success);
}
+error_code filename(const StringRef &path, StringRef &result) {
+ result = *(--end(path));
+ return make_error_code(errc::success);
+}
+
}
}
}
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 8570047..0dae960 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -94,6 +94,9 @@ TEST(Support, Path) {
if (error_code ec = sys::path::parent_path(*i, res))
ASSERT_FALSE(ec.message().c_str());
outs() << " parent_path: " << res << '\n';
+ if (error_code ec = sys::path::filename(*i, res))
+ ASSERT_FALSE(ec.message().c_str());
+ outs() << " filename: " << res << '\n';
temp_store = *i;
if (error_code ec = sys::path::make_absolute(temp_store))