Support/PathV2: Add filename implementation.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 1 Dec 2010 03:18:17 +0000 (03:18 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 1 Dec 2010 03:18:17 +0000 (03:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120546 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/PathV2.cpp
unittests/Support/Path.cpp

index 7bb79887a3fa5981575c0b59aa8f772edbe020d9..9c343ea0060027c79bcffb8bf3012ce8c6ebd68b 100644 (file)
@@ -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);
+}
+
 }
 }
 }
index 8570047af849593c2ac96b518e051373b5e53d5e..0dae960f48fec95763cea9e36a5d172760062f6b 100644 (file)
@@ -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))