From 142692006bb824796ea3ddf1907db81af7956fd8 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Wed, 1 Dec 2010 03:18:17 +0000 Subject: [PATCH] Support/PathV2: Add filename implementation. llvm-svn: 120546 --- llvm/lib/Support/PathV2.cpp | 5 +++++ llvm/unittests/Support/Path.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp index 7bb79887a3fa..9c343ea00600 100644 --- a/llvm/lib/Support/PathV2.cpp +++ b/llvm/lib/Support/PathV2.cpp @@ -553,6 +553,11 @@ error_code native(const Twine &path, SmallVectorImpl &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/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 8570047af849..0dae960f48fe 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/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))