Author: ericwf Date: Sat Oct 15 17:37:42 2016 New Revision: 284313 URL: http://llvm.org/viewvc/llvm-project?rev=284313&view=rev Log: Implement modified LWG 2665
Modified: libcxx/trunk/include/experimental/filesystem libcxx/trunk/src/experimental/filesystem/path.cpp libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp libcxx/trunk/www/upcoming_meeting.html Modified: libcxx/trunk/include/experimental/filesystem URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=284313&r1=284312&r2=284313&view=diff ============================================================================== --- libcxx/trunk/include/experimental/filesystem (original) +++ libcxx/trunk/include/experimental/filesystem Sat Oct 15 17:37:42 2016 @@ -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(); } Modified: libcxx/trunk/src/experimental/filesystem/path.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=284313&r1=284312&r2=284313&view=diff ============================================================================== --- libcxx/trunk/src/experimental/filesystem/path.cpp (original) +++ libcxx/trunk/src/experimental/filesystem/path.cpp Sat Oct 15 17:37:42 2016 @@ -277,6 +277,16 @@ string_view_t path::__root_directory() c 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()) { Modified: libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp?rev=284313&r1=284312&r2=284313&view=diff ============================================================================== --- libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp Sat Oct 15 17:37:42 2016 @@ -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/."} }; Modified: libcxx/trunk/www/upcoming_meeting.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=284313&r1=284312&r2=284313&view=diff ============================================================================== --- libcxx/trunk/www/upcoming_meeting.html (original) +++ libcxx/trunk/www/upcoming_meeting.html Sat Oct 15 17:37:42 2016 @@ -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> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits