aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__filesystem/filesystem_error.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /libcxx/include/__filesystem/filesystem_error.h
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'libcxx/include/__filesystem/filesystem_error.h')
-rw-r--r--libcxx/include/__filesystem/filesystem_error.h63
1 files changed, 25 insertions, 38 deletions
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index effe6998338c..713cc357ee82 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -14,11 +14,13 @@
#include <__config>
#include <__filesystem/path.h>
#include <__memory/shared_ptr.h>
+#include <__system_error/error_code.h>
+#include <__system_error/system_error.h>
#include <__utility/forward.h>
+#include <__verbose_abort>
#include <iosfwd>
#include <new>
-#include <system_error>
-#include <type_traits>
+#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,50 +30,38 @@
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
-class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
+class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error {
public:
- _LIBCPP_INLINE_VISIBILITY
- filesystem_error(const string& __what, error_code __ec)
- : system_error(__ec, __what),
- __storage_(make_shared<_Storage>(path(), path())) {
+ _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec)
+ : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) {
__create_what(0);
}
- _LIBCPP_INLINE_VISIBILITY
- filesystem_error(const string& __what, const path& __p1, error_code __ec)
- : system_error(__ec, __what),
- __storage_(make_shared<_Storage>(__p1, path())) {
+ _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, error_code __ec)
+ : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, path())) {
__create_what(1);
}
- _LIBCPP_INLINE_VISIBILITY
- filesystem_error(const string& __what, const path& __p1, const path& __p2,
- error_code __ec)
- : system_error(__ec, __what),
- __storage_(make_shared<_Storage>(__p1, __p2)) {
+ _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, const path& __p1, const path& __p2, error_code __ec)
+ : system_error(__ec, __what), __storage_(make_shared<_Storage>(__p1, __p2)) {
__create_what(2);
}
- _LIBCPP_INLINE_VISIBILITY
- const path& path1() const noexcept { return __storage_->__p1_; }
+ _LIBCPP_HIDE_FROM_ABI const path& path1() const noexcept { return __storage_->__p1_; }
- _LIBCPP_INLINE_VISIBILITY
- const path& path2() const noexcept { return __storage_->__p2_; }
+ _LIBCPP_HIDE_FROM_ABI const path& path2() const noexcept { return __storage_->__p2_; }
- filesystem_error(const filesystem_error&) = default;
+ _LIBCPP_HIDE_FROM_ABI filesystem_error(const filesystem_error&) = default;
~filesystem_error() override; // key function
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
- const char* what() const noexcept override {
- return __storage_->__what_.c_str();
- }
+ const char* what() const noexcept override { return __storage_->__what_.c_str(); }
void __create_what(int __num_paths);
private:
struct _LIBCPP_HIDDEN _Storage {
- _LIBCPP_INLINE_VISIBILITY
- _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
+ _LIBCPP_HIDE_FROM_ABI _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
path __p1_;
path __p2_;
@@ -80,22 +70,19 @@ private:
shared_ptr<_Storage> __storage_;
};
-// TODO(ldionne): We need to pop the pragma and push it again after
-// filesystem_error to work around PR41078.
-_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
-
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
template <class... _Args>
-_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_NO_EXCEPTIONS
-void __throw_filesystem_error(_Args&&... __args) {
+_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
+__throw_filesystem_error(_Args&&... __args) {
throw filesystem_error(_VSTD::forward<_Args>(__args)...);
}
-#else
-void __throw_filesystem_error(_Args&&...) {
- _VSTD::abort();
+# else
+template <class... _Args>
+_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
+__throw_filesystem_error(_Args&&...) {
+ _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");
}
-#endif
-_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+# endif
_LIBCPP_END_NAMESPACE_FILESYSTEM