[PATCH] D23855: Make exception-throwing from a noexcept build `abort()`.
Sebastian Pop via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 24 19:47:56 PDT 2016
sebpop added a comment.
I like the patch.
Thanks for removing #ifdefs from the code: it improves readability in general.
Would it be possible to move the __throw_* functions in a same .h file to avoid having them all over?
================
Comment at: include/array:212
@@ -214,3 +211,3 @@
#else
- assert(!"array::at out_of_range");
+ _VSTD::abort();
#endif
----------------
Maybe you can use __throw_out_of_range?
Fewer #ifdefs in the code is better.
================
Comment at: include/array:226
@@ -228,3 +225,3 @@
#else
- assert(!"array::at out_of_range");
+ _VSTD::abort();
#endif
----------------
__throw_out_of_range
================
Comment at: include/bitset:218
@@ +217,3 @@
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw overflow_error(__msg);
----------------
To improve readability, could you please avoid the double negation by turning around the clauses:
#ifdef _LIBCPP_NO_EXCEPTIONS
_VSTD::abort();
#else
throw overflow_error(__msg);
#endif
And the same below in all the __throw_* functions. Thanks!
================
Comment at: include/deque:909
@@ -908,1 +908,3 @@
+#else
+ _VSTD::abort();
#endif
----------------
Maybe you can add another function for this one:
__throw_length_error
================
Comment at: include/deque:920
@@ -917,1 +919,3 @@
+#else
+ _VSTD::abort();
#endif
----------------
__throw_out_of_range
================
Comment at: include/experimental/any:106
@@ -106,3 +105,3 @@
#else
- assert(!"bad_any_cast");
+ _VSTD::abort();
#endif
----------------
Maybe add a new function __throw_bad_any_cast?
================
Comment at: include/experimental/dynarray:145
@@ -148,3 +144,3 @@
#else
- assert(!"dynarray::allocation");
+ _VSTD::abort();
#endif
----------------
New function: __throw_bad_array_length?
================
Comment at: include/experimental/dynarray:286
@@ -289,3 +285,3 @@
#else
- assert(!"dynarray::at out_of_range");
+ _VSTD::abort();
#endif
----------------
__throw_out_of_range
================
Comment at: include/experimental/dynarray:302
@@ -305,3 +301,3 @@
#else
- assert(!"dynarray::at out_of_range");
+ _VSTD::abort();
#endif
----------------
__throw_out_of_range
https://reviews.llvm.org/D23855
More information about the cfe-commits
mailing list