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
This commit is contained in:
parent
5b0bf81512
commit
4fe5c8c730
3 changed files with 35 additions and 21 deletions
|
@ -1,3 +1,17 @@
|
|||
2019-02-09 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
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 <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/89102 (partial)
|
||||
|
|
|
@ -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<value_type>);
|
||||
void _M_concat(basic_string_view<value_type>);
|
||||
|
||||
pair<const string_type*, size_t> _M_find_extension() const;
|
||||
pair<const string_type*, size_t> _M_find_extension() const noexcept;
|
||||
|
||||
template<typename _CharT>
|
||||
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();
|
||||
|
|
|
@ -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<const path::string_type*, std::size_t>
|
||||
path::_M_find_extension() const
|
||||
path::_M_find_extension() const noexcept
|
||||
{
|
||||
const string_type* s = nullptr;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue