codekingpro/portable-devtools
114k
1// -*- C++ -*-2//===--------------------------- stdexcept --------------------------------===//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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_STDEXCEPT11#define _LIBCUDACXX_STDEXCEPT12 13/*14 stdexcept synopsis15 16namespace std17{18 19class logic_error;20 class domain_error;21 class invalid_argument;22 class length_error;23 class out_of_range;24class runtime_error;25 class range_error;26 class overflow_error;27 class underflow_error;28 29for each class xxx_error:30 31class xxx_error : public exception // at least indirectly32{33public:34 explicit xxx_error(const string& what_arg);35 explicit xxx_error(const char* what_arg);36 37 virtual const char* what() const noexcept // returns what_arg38};39 40} // std41 42*/43 44#ifndef __cuda_std__45#include <__config>46#include <exception>47#ifdef _LIBCUDACXX_NO_EXCEPTIONS48#include <cstdlib>49#endif50#endif //__cuda_std__51 52#include "__assert" // all public C++ headers provide the assertion handler53#include "cstdlib"54#include "iosfwd"55 56#ifndef __cuda_std__57#include <__pragma_push>58#endif //__cuda_std__59 60#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)61# pragma GCC system_header62#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)63# pragma clang system_header64#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)65# pragma system_header66#endif // no system header67 68_LIBCUDACXX_BEGIN_NAMESPACE_STD69 70#ifndef _LIBCUDACXX_ABI_VCRUNTIME71class _LIBCUDACXX_HIDDEN __libcpp_refstring72{73 const char* __imp_;74 75 _LIBCUDACXX_HOST_DEVICE bool __uses_refcount() const;76public:77 _LIBCUDACXX_HOST_DEVICE explicit __libcpp_refstring(const char* __msg);78 _LIBCUDACXX_HOST_DEVICE __libcpp_refstring(const __libcpp_refstring& __s) noexcept;79 _LIBCUDACXX_HOST_DEVICE __libcpp_refstring& operator=(const __libcpp_refstring& __s) noexcept;80 _LIBCUDACXX_HOST_DEVICE ~__libcpp_refstring();81 82 _LIBCUDACXX_HOST_DEVICE const char* c_str() const noexcept {return __imp_;}83};84#endif // !_LIBCUDACXX_ABI_VCRUNTIME85 86_LIBCUDACXX_END_NAMESPACE_STD87 88#ifndef __cuda_std__89#ifdef _LIBCUDACXX_BEGIN_NAMESPACE_STD_NOVERSION90_LIBCUDACXX_BEGIN_NAMESPACE_STD_NOVERSION91#else92namespace std // purposefully not versioned93{94#endif //_LIBCUDACXX_BEGIN_NAMESPACE_STD_NOVERSION95 96class _LIBCUDACXX_EXCEPTION_ABI logic_error97 : public exception98{99#ifndef _LIBCUDACXX_ABI_VCRUNTIME100private:101 _CUDA_VSTD::__libcpp_refstring __imp_;102public:103 explicit logic_error(const string&);104 explicit logic_error(const char*);105 106 logic_error(const logic_error&) noexcept;107 logic_error& operator=(const logic_error&) noexcept;108 109 virtual ~logic_error() noexcept;110 111 virtual const char* what() const noexcept;112#else113public:114 explicit logic_error(const _CUDA_VSTD::string&); // Symbol uses versioned std::string115 _LIBCUDACXX_INLINE_VISIBILITY explicit logic_error(const char* __s) : exception(__s) {}116#endif117};118 119class _LIBCUDACXX_EXCEPTION_ABI runtime_error120 : public exception121{122#ifndef _LIBCUDACXX_ABI_VCRUNTIME123private:124 _CUDA_VSTD::__libcpp_refstring __imp_;125public:126 explicit runtime_error(const string&);127 explicit runtime_error(const char*);128 129 runtime_error(const runtime_error&) noexcept;130 runtime_error& operator=(const runtime_error&) noexcept;131 132 virtual ~runtime_error() noexcept;133 134 virtual const char* what() const noexcept;135#else136public:137 explicit runtime_error(const _CUDA_VSTD::string&); // Symbol uses versioned std::string138 _LIBCUDACXX_INLINE_VISIBILITY explicit runtime_error(const char* __s) : exception(__s) {}139#endif // _LIBCUDACXX_ABI_VCRUNTIME140};141 142class _LIBCUDACXX_EXCEPTION_ABI domain_error143 : public logic_error144{145public:146 _LIBCUDACXX_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}147 _LIBCUDACXX_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {}148 149#ifndef _LIBCUDACXX_ABI_VCRUNTIME150 virtual ~domain_error() noexcept;151#endif152};153 154class _LIBCUDACXX_EXCEPTION_ABI invalid_argument155 : public logic_error156{157public:158 _LIBCUDACXX_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}159 _LIBCUDACXX_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {}160 161#ifndef _LIBCUDACXX_ABI_VCRUNTIME162 virtual ~invalid_argument() noexcept;163#endif164};165 166class _LIBCUDACXX_EXCEPTION_ABI length_error167 : public logic_error168{169public:170 _LIBCUDACXX_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}171 _LIBCUDACXX_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}172#ifndef _LIBCUDACXX_ABI_VCRUNTIME173 virtual ~length_error() noexcept;174#endif175};176 177class _LIBCUDACXX_EXCEPTION_ABI out_of_range178 : public logic_error179{180public:181 _LIBCUDACXX_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}182 _LIBCUDACXX_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {}183 184#ifndef _LIBCUDACXX_ABI_VCRUNTIME185 virtual ~out_of_range() noexcept;186#endif187};188 189class _LIBCUDACXX_EXCEPTION_ABI range_error190 : public runtime_error191{192public:193 _LIBCUDACXX_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}194 _LIBCUDACXX_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {}195 196#ifndef _LIBCUDACXX_ABI_VCRUNTIME197 virtual ~range_error() noexcept;198#endif199};200 201class _LIBCUDACXX_EXCEPTION_ABI overflow_error202 : public runtime_error203{204public:205 _LIBCUDACXX_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}206 _LIBCUDACXX_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {}207 208#ifndef _LIBCUDACXX_ABI_VCRUNTIME209 virtual ~overflow_error() noexcept;210#endif211};212 213class _LIBCUDACXX_EXCEPTION_ABI underflow_error214 : public runtime_error215{216public:217 _LIBCUDACXX_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}218 _LIBCUDACXX_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {}219 220#ifndef _LIBCUDACXX_ABI_VCRUNTIME221 virtual ~underflow_error() noexcept;222#endif223};224 225#ifdef _LIBCUDACXX_END_NAMESPACE_STD_NOVERSION226_LIBCUDACXX_END_NAMESPACE_STD_NOVERSION227#else228}229#endif //_LIBCUDACXX_END_NAMESPACE_STD_NOVERSION230#endif //__cuda_std__231 232_LIBCUDACXX_BEGIN_NAMESPACE_STD233 234// in the dylib235_LIBCUDACXX_NORETURN _LIBCUDACXX_FUNC_VIS void __throw_runtime_error(const char*);236 237_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY238void __throw_logic_error(const char*__msg)239{240#ifndef _LIBCUDACXX_NO_EXCEPTIONS241 throw logic_error(__msg);242#else243 ((void)__msg);244 _LIBCUDACXX_UNREACHABLE();245#endif246}247 248_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY249void __throw_domain_error(const char*__msg)250{251#ifndef _LIBCUDACXX_NO_EXCEPTIONS252 throw domain_error(__msg);253#else254 ((void)__msg);255 _LIBCUDACXX_UNREACHABLE();256#endif257}258 259_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY260void __throw_invalid_argument(const char*__msg)261{262#ifndef _LIBCUDACXX_NO_EXCEPTIONS263 throw invalid_argument(__msg);264#else265 ((void)__msg);266 _LIBCUDACXX_UNREACHABLE();267#endif268}269 270_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY271void __throw_length_error(const char*__msg)272{273#ifndef _LIBCUDACXX_NO_EXCEPTIONS274 throw length_error(__msg);275#else276 ((void)__msg);277 _LIBCUDACXX_UNREACHABLE();278#endif279}280 281_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY282void __throw_out_of_range(const char*__msg)283{284#ifndef _LIBCUDACXX_NO_EXCEPTIONS285 throw out_of_range(__msg);286#else287 ((void)__msg);288 _LIBCUDACXX_UNREACHABLE();289#endif290}291 292_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY293void __throw_range_error(const char*__msg)294{295#ifndef _LIBCUDACXX_NO_EXCEPTIONS296 throw range_error(__msg);297#else298 ((void)__msg);299 _LIBCUDACXX_UNREACHABLE();300#endif301}302 303_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY304void __throw_overflow_error(const char*__msg)305{306#ifndef _LIBCUDACXX_NO_EXCEPTIONS307 throw overflow_error(__msg);308#else309 ((void)__msg);310 _LIBCUDACXX_UNREACHABLE();311#endif312}313 314_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY315void __throw_underflow_error(const char*__msg)316{317#ifndef _LIBCUDACXX_NO_EXCEPTIONS318 throw underflow_error(__msg);319#else320 ((void)__msg);321 _LIBCUDACXX_UNREACHABLE();322#endif323}324 325_LIBCUDACXX_END_NAMESPACE_STD326 327#ifndef __cuda_std__328#include <__pragma_pop>329#endif //__cuda_std__330 331#endif // _LIBCUDACXX_STDEXCEPT332 