• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef _LIBCPP___FORMAT_FORMAT_ERROR_H
11 #define _LIBCPP___FORMAT_FORMAT_ERROR_H
12 
13 #include <__config>
14 #include <__verbose_abort>
15 #include <stdexcept>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #  pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if _LIBCPP_STD_VER >= 20
24 
25 _LIBCPP_DIAGNOSTIC_PUSH
26 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
27 class _LIBCPP_EXPORTED_FROM_ABI format_error : public runtime_error {
28 public:
format_error(const string & __s)29   _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s)
30       : runtime_error(__s) {}
format_error(const char * __s)31   _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
32       : runtime_error(__s) {}
33   _LIBCPP_HIDE_FROM_ABI format_error(const format_error&) = default;
34   _LIBCPP_HIDE_FROM_ABI format_error& operator=(const format_error&) = default;
35   _LIBCPP_HIDE_FROM_ABI_VIRTUAL
36   ~format_error() noexcept override = default;
37 };
38 _LIBCPP_DIAGNOSTIC_POP
39 
40 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
__throw_format_error(const char * __s)41 __throw_format_error(const char* __s) {
42 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
43   throw format_error(__s);
44 #else
45   _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s);
46 #endif
47 }
48 
49 #endif //_LIBCPP_STD_VER >= 20
50 
51 _LIBCPP_END_NAMESPACE_STD
52 
53 #endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
54