[PATCH] D21706: [libcxx] refactor for throw

Noel Grandin via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 00:15:43 PDT 2016


grandinj added inline comments.

================
Comment at: include/array:209
@@ -211,7 +208,3 @@
     if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("array::at");
-#else
-        assert(!"array::at out_of_range");
-#endif
+        __libcpp_throw(out_of_range("array::at"));
     return __elems_[__n];
----------------
the error message of the assert was perhaps better?

================
Comment at: include/array:219
@@ -225,7 +218,3 @@
     if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("array::at");
-#else
-        assert(!"array::at out_of_range");
-#endif
+        __libcpp_throw(out_of_range("array::at"));
     return __elems_[__n];
----------------
the error message of the assert was perhaps better?

================
Comment at: include/experimental/dynarray:279
@@ -286,7 +278,3 @@
     {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("dynarray::at");
-#else
-        assert(!"dynarray::at out_of_range");
-#endif
+        __libcpp_throw(out_of_range("dynarray::at"));
     }
----------------
the error message of the assert was perhaps better?

================
Comment at: include/experimental/dynarray:291
@@ -302,7 +290,3 @@
     {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("dynarray::at");
-#else
-        assert(!"dynarray::at out_of_range");
-#endif
+        __libcpp_throw(out_of_range("dynarray::at"));
     }
----------------
ditto

================
Comment at: include/map:1446
@@ -1446,4 +1445,3 @@
     if (__child == nullptr)
-        throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __libcpp_throw(out_of_range("map::at:  key not found"));
     return static_cast<__node_pointer>(__child)->__value_.__cc.second;
----------------
looks like extra spaces in this message (which was there in the original, I know)

================
Comment at: include/map:1457
@@ -1459,4 +1456,3 @@
     if (__child == nullptr)
-        throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __libcpp_throw(out_of_range("map::at:  key not found"));
     return static_cast<__node_pointer>(__child)->__value_.__cc.second;
----------------
extra spaces here too


http://reviews.llvm.org/D21706





More information about the cfe-commits mailing list