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 <cstdlib> 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 > 17 24 25class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error { 26public: 27 _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s) 28 : runtime_error(__s) {} 29 _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s) 30 : runtime_error(__s) {} 31 // TODO FMT Remove when format is no longer experimental. 32 // Avoids linker errors when building the Clang-cl Windows DLL which doesn't 33 // support the experimental library. 34# ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR 35 ~format_error() noexcept override; 36# else 37 ~format_error() noexcept override {} 38# endif 39}; 40 41_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void 42__throw_format_error(const char* __s) { 43#ifndef _LIBCPP_NO_EXCEPTIONS 44 throw format_error(__s); 45#else 46 (void)__s; 47 _VSTD::abort(); 48#endif 49} 50 51#endif //_LIBCPP_STD_VER > 17 52 53_LIBCPP_END_NAMESPACE_STD 54 55#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H 56