summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-15 22:37:42 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-15 22:37:42 +0000
commit87ee8a0adb05dd695c7b5e84302ae43a57c0f417 (patch)
tree056eb7e82c88bc0b92ea50dfe915cd9ef8fea5b2
parent8ea0246e93a29095dd8a0ea5e40bb3aa157d3611 (diff)
downloadbcm5719-llvm-87ee8a0adb05dd695c7b5e84302ae43a57c0f417.tar.gz
bcm5719-llvm-87ee8a0adb05dd695c7b5e84302ae43a57c0f417.zip
Implement modified LWG 2665
llvm-svn: 284313
-rw-r--r--libcxx/include/experimental/filesystem13
-rw-r--r--libcxx/src/experimental/filesystem/path.cpp10
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp8
-rw-r--r--libcxx/www/upcoming_meeting.html4
4 files changed, 31 insertions, 4 deletions
diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem
index 45de0d19cb5..c1427c880e2 100644
--- a/libcxx/include/experimental/filesystem
+++ b/libcxx/include/experimental/filesystem
@@ -863,7 +863,15 @@ public:
}
path& make_preferred() { return *this; }
- path& remove_filename() { return *this = parent_path(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ path& remove_filename() {
+ if (__pn_.size() == __root_path_raw().size())
+ clear();
+ else
+ __pn_ = __parent_path();
+ return *this;
+ }
path& replace_filename(const path& __replacement) {
remove_filename();
@@ -925,6 +933,7 @@ private:
_LIBCPP_FUNC_VIS int __compare(__string_view) const;
_LIBCPP_FUNC_VIS __string_view __root_name() const;
_LIBCPP_FUNC_VIS __string_view __root_directory() const;
+ _LIBCPP_FUNC_VIS __string_view __root_path_raw() const;
_LIBCPP_FUNC_VIS __string_view __relative_path() const;
_LIBCPP_FUNC_VIS __string_view __parent_path() const;
_LIBCPP_FUNC_VIS __string_view __filename() const;
@@ -953,7 +962,7 @@ public:
_LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); }
- _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !(__root_name().empty() && __root_directory().empty()); }
+ _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !__root_path_raw().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { return !__relative_path().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { return !__parent_path().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_filename() const { return !__filename().empty(); }
diff --git a/libcxx/src/experimental/filesystem/path.cpp b/libcxx/src/experimental/filesystem/path.cpp
index 22ad23b42fe..64da30217fb 100644
--- a/libcxx/src/experimental/filesystem/path.cpp
+++ b/libcxx/src/experimental/filesystem/path.cpp
@@ -277,6 +277,16 @@ string_view_t path::__root_directory() const
return parser::extract_preferred(__pn_, start_i);
}
+string_view_t path::__root_path_raw() const
+{
+ size_t e = parser::root_directory_end(__pn_);
+ if (!parser::good(e))
+ e = parser::root_name_end(__pn_);
+ if (parser::good(e))
+ return string_view_t{__pn_}.substr(0, e + 1);
+ return {};
+}
+
string_view_t path::__relative_path() const
{
if (empty()) {
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
index 4ad9084dbf8..e414202bf8f 100644
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
@@ -35,16 +35,24 @@ const RemoveFilenameTestcase TestCases[] =
{
{"", ""}
, {"/", ""}
+ , {"//", ""}
+ , {"///", ""}
, {"\\", ""}
, {".", ""}
, {"..", ""}
, {"/foo", "/"}
+ , {"//foo", ""}
+ , {"//foo/", ""}
+ , {"//foo///", ""}
+ , {"///foo", "/"}
+ , {"///foo/", "///foo"}
, {"/foo/", "/foo"}
, {"/foo/.", "/foo"}
, {"/foo/..", "/foo"}
, {"/foo/////", "/foo"}
, {"/foo\\\\", "/"}
, {"/foo//\\/", "/foo//\\"}
+ , {"///foo", "/"}
, {"file.txt", ""}
, {"bar/../baz/./file.txt", "bar/../baz/."}
};
diff --git a/libcxx/www/upcoming_meeting.html b/libcxx/www/upcoming_meeting.html
index e0d53bdb053..4b58c7e4857 100644
--- a/libcxx/www/upcoming_meeting.html
+++ b/libcxx/www/upcoming_meeting.html
@@ -89,7 +89,7 @@
<tr><td><a href="http://wg21.link/LWG2591">2591</a></td><td>std::function's member template target() should not lead to undefined behaviour</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2598">2598</a></td><td>addressof works on temporaries</td><td>Issaquah</td><td>Patch ready</td></tr>
<tr><td><a href="http://wg21.link/LWG2664">2664</a></td><td>operator/ (and other append) semantics not useful if argument has root</td><td>Issaquah</td><td>Nothing to do</td></tr>
- <tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Issaquah</td><td></td></tr>
+ <tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Issaquah</td><td>See Below</td></tr>
<tr><td><a href="http://wg21.link/LWG2672">2672</a></td><td>Should is_empty use error_code in its specification?</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2678">2678</a></td><td>std::filesystem enum classes overspecified</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2679">2679</a></td><td>Inconsistent Use of Effects and Equivalent To</td><td>Issaquah</td><td>Nothing to do</td></tr>
@@ -167,7 +167,7 @@
<li>2591 - I <b>suspect</b> that this is just better specification of the existing structure. Probably need more tests for this.</li>
<li>2598 - Patch and tests ready</li>
<li>2664 - No change needed. _LIBCPP_DEBUG mode tests the new requirements.</li>
-<li>2665 - File System; Eric?</li>
+<li>2665 - PR is incorrect as-is. We implement a modified version</li>
<li>2672 - File System; Eric?</li>
<li>2678 - File System; Eric?</li>
<li>2679 - This is just wording cleanup. </li>
OpenPOWER on IntegriCloud