From: Jonathan Wakely Date: Sat, 9 Feb 2019 00:25:39 +0000 (+0000) Subject: Add noexcept to filesystem::path query functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4fe5c8c730ead2286103b95a4226f9d23b95a68a;p=gcc.git Add noexcept to filesystem::path query functions In the standard these member functions are specified in terms of the potentially-throwing path decompositions functions, but we implement them without constructing any new paths or doing anything else that can throw. PR libstdc++/71044 * include/bits/fs_path.h (path::has_root_name) (path::has_root_directory, path::has_root_path) (path::has_relative_path, path::has_parent_path) (path::has_filename, path::has_stem, path::has_extension) (path::is_absolute, path::is_relative, path::_M_find_extension): Add noexcept. * src/c++17/fs_path.cc (path::has_root_name) (path::has_root_directory, path::has_root_path) (path::has_relative_path, path::has_parent_path) (path::has_filename, path::_M_find_extension): Add noexcept. From-SVN: r268713 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 32061270c7a..972a098950b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,17 @@ +2019-02-09 Jonathan Wakely + + PR libstdc++/71044 + * include/bits/fs_path.h (path::has_root_name) + (path::has_root_directory, path::has_root_path) + (path::has_relative_path, path::has_parent_path) + (path::has_filename, path::has_stem, path::has_extension) + (path::is_absolute, path::is_relative, path::_M_find_extension): Add + noexcept. + * src/c++17/fs_path.cc (path::has_root_name) + (path::has_root_directory, path::has_root_path) + (path::has_relative_path, path::has_parent_path) + (path::has_filename, path::_M_find_extension): Add noexcept. + 2019-02-06 Jonathan Wakely PR libstdc++/89102 (partial) diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 37dcfc16703..98b8dc08a6e 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -359,16 +359,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // query [[nodiscard]] bool empty() const noexcept { return _M_pathname.empty(); } - bool has_root_name() const; - bool has_root_directory() const; - bool has_root_path() const; - bool has_relative_path() const; - bool has_parent_path() const; - bool has_filename() const; - bool has_stem() const; - bool has_extension() const; - bool is_absolute() const; - bool is_relative() const { return !is_absolute(); } + bool has_root_name() const noexcept; + bool has_root_directory() const noexcept; + bool has_root_path() const noexcept; + bool has_relative_path() const noexcept; + bool has_parent_path() const noexcept; + bool has_filename() const noexcept; + bool has_stem() const noexcept; + bool has_extension() const noexcept; + bool is_absolute() const noexcept; + bool is_relative() const noexcept { return !is_absolute(); } // generation path lexically_normal() const; @@ -433,7 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void _M_append(basic_string_view); void _M_concat(basic_string_view); - pair _M_find_extension() const; + pair _M_find_extension() const noexcept; template struct _Cvt; @@ -1102,21 +1102,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } inline bool - path::has_stem() const + path::has_stem() const noexcept { auto ext = _M_find_extension(); return ext.first && ext.second != 0; } inline bool - path::has_extension() const + path::has_extension() const noexcept { auto ext = _M_find_extension(); return ext.first && ext.second != string_type::npos; } inline bool - path::is_absolute() const + path::is_absolute() const noexcept { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return has_root_name() && has_root_directory(); diff --git a/libstdc++-v3/src/c++17/fs_path.cc b/libstdc++-v3/src/c++17/fs_path.cc index db6a1cb29d8..268b5621509 100644 --- a/libstdc++-v3/src/c++17/fs_path.cc +++ b/libstdc++-v3/src/c++17/fs_path.cc @@ -1530,7 +1530,7 @@ path::parent_path() const } bool -path::has_root_name() const +path::has_root_name() const noexcept { if (_M_type() == _Type::_Root_name) return true; @@ -1540,7 +1540,7 @@ path::has_root_name() const } bool -path::has_root_directory() const +path::has_root_directory() const noexcept { if (_M_type() == _Type::_Root_dir) return true; @@ -1556,7 +1556,7 @@ path::has_root_directory() const } bool -path::has_root_path() const +path::has_root_path() const noexcept { if (_M_type() == _Type::_Root_name || _M_type() == _Type::_Root_dir) return true; @@ -1570,7 +1570,7 @@ path::has_root_path() const } bool -path::has_relative_path() const +path::has_relative_path() const noexcept { if (_M_type() == _Type::_Filename && !_M_pathname.empty()) return true; @@ -1589,7 +1589,7 @@ path::has_relative_path() const bool -path::has_parent_path() const +path::has_parent_path() const noexcept { if (!has_relative_path()) return !empty(); @@ -1597,7 +1597,7 @@ path::has_parent_path() const } bool -path::has_filename() const +path::has_filename() const noexcept { if (empty()) return false; @@ -1783,7 +1783,7 @@ path::lexically_proximate(const path& base) const } std::pair -path::_M_find_extension() const +path::_M_find_extension() const noexcept { const string_type* s = nullptr;