[llvm-commits] [llvm] r120513 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp unittests/Support/Path.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Tue Nov 30 16:52:28 PST 2010
Author: mspencer
Date: Tue Nov 30 18:52:28 2010
New Revision: 120513
URL: http://llvm.org/viewvc/llvm-project?rev=120513&view=rev
Log:
Support/PathV2: Add remove_filename implementation.
Modified:
llvm/trunk/include/llvm/Support/PathV2.h
llvm/trunk/lib/Support/PathV2.cpp
llvm/trunk/unittests/Support/Path.cpp
Modified: llvm/trunk/include/llvm/Support/PathV2.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=120513&r1=120512&r2=120513&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PathV2.h (original)
+++ llvm/trunk/include/llvm/Support/PathV2.h Tue Nov 30 18:52:28 2010
@@ -140,7 +140,7 @@
/// @brief Remove the last component from \a path if it exists.
///
/// directory/filename.cpp => directory/
-/// directory/ => directory/
+/// directory/ => directory
///
/// @param path A path that is modified to not have a file component.
/// @returns errc::success if \a path's file name has been removed (or there was
Modified: llvm/trunk/lib/Support/PathV2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=120513&r1=120512&r2=120513&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Tue Nov 30 18:52:28 2010
@@ -503,6 +503,14 @@
return make_error_code(errc::success);
}
+error_code remove_filename(SmallVectorImpl<char> &path) {
+ size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()));
+ if (end_pos == StringRef::npos)
+ return make_error_code(errc::success);
+ path.set_size(end_pos);
+ return make_error_code(errc::success);
+}
+
}
}
}
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=120513&r1=120512&r2=120513&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Tue Nov 30 18:52:28 2010
@@ -99,6 +99,10 @@
if (error_code ec = sys::path::make_absolute(temp_store))
ASSERT_FALSE(ec.message().c_str());
outs() << " make_absolute: " << temp_store << '\n';
+ temp_store = *i;
+ if (error_code ec = sys::path::remove_filename(temp_store))
+ ASSERT_FALSE(ec.message().c_str());
+ outs() << " remove_filename: " << temp_store << '\n';
outs().flush();
}
More information about the llvm-commits
mailing list