Consolidate a bunch of #ifdef _LIBCPP_NO_EXCEPTIONS .. #endif blocks into a single template function. NFC

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow 2015-07-28 13:30:47 +00:00
parent dd29a02911
commit 2576c29dab

View File

@ -955,6 +955,15 @@ public:
regex_constants::error_type code() const {return __code_;} regex_constants::error_type code() const {return __code_;}
}; };
template <regex_constants::error_type _Ev>
_LIBCPP_ALWAYS_INLINE
void __throw_regex_error()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(_Ev);
#endif
}
template <class _CharT> template <class _CharT>
struct _LIBCPP_TYPE_VIS_ONLY regex_traits struct _LIBCPP_TYPE_VIS_ONLY regex_traits
{ {
@ -2256,10 +2265,8 @@ public:
} }
else else
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__b.size() != 1 || __e.size() != 1) if (__b.size() != 1 || __e.size() != 1)
throw regex_error(regex_constants::error_collate); __throw_regex_error<regex_constants::error_collate>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (__icase_) if (__icase_)
{ {
__b[0] = __traits_.translate_nocase(__b[0]); __b[0] = __traits_.translate_nocase(__b[0]);
@ -3012,10 +3019,8 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
case egrep: case egrep:
__first = __parse_egrep(__first, __last); __first = __parse_egrep(__first, __last);
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::__re_err_grammar); __throw_regex_error<regex_constants::__re_err_grammar>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
return __first; return __first;
} }
@ -3046,10 +3051,8 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
} }
} }
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first != __last) if (__first != __last)
throw regex_error(regex_constants::__re_err_empty); __throw_regex_error<regex_constants::__re_err_empty>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
return __first; return __first;
} }
@ -3062,19 +3065,15 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
{ {
__owns_one_state<_CharT>* __sa = __end_; __owns_one_state<_CharT>* __sa = __end_;
_ForwardIterator __temp = __parse_ERE_branch(__first, __last); _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); __throw_regex_error<regex_constants::__re_err_empty>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = __temp; __first = __temp;
while (__first != __last && *__first == '|') while (__first != __last && *__first == '|')
{ {
__owns_one_state<_CharT>* __sb = __end_; __owns_one_state<_CharT>* __sb = __end_;
__temp = __parse_ERE_branch(++__first, __last); __temp = __parse_ERE_branch(++__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); __throw_regex_error<regex_constants::__re_err_empty>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_alternation(__sa, __sb); __push_alternation(__sa, __sb);
__first = __temp; __first = __temp;
} }
@ -3088,10 +3087,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
_ForwardIterator __last) _ForwardIterator __last)
{ {
_ForwardIterator __temp = __parse_ERE_expression(__first, __last); _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); __throw_regex_error<regex_constants::__re_err_empty>();
#endif // _LIBCPP_NO_EXCEPTIONS
do do
{ {
__first = __temp; __first = __temp;
@ -3126,10 +3123,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
++__open_count_; ++__open_count_;
__temp = __parse_extended_reg_exp(++__temp, __last); __temp = __parse_extended_reg_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
--__open_count_; --__open_count_;
++__temp; ++__temp;
@ -3194,10 +3189,8 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
__first = __parse_RE_expression(__temp, __last); __first = __parse_RE_expression(__temp, __last);
__temp = __parse_Back_close_paren(__first, __last); __temp = __parse_Back_close_paren(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
__first = __temp; __first = __temp;
} }
@ -3511,22 +3504,16 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __min = 0; int __min = 0;
__first = __temp; __first = __temp;
__temp = __parse_DUP_COUNT(__first, __last, __min); __temp = __parse_DUP_COUNT(__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (*__first != ',') if (*__first != ',')
{ {
__temp = __parse_Back_close_brace(__first, __last); __temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end, __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
true); true);
__first = __temp; __first = __temp;
@ -3537,18 +3524,14 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __max = -1; int __max = -1;
__first = __parse_DUP_COUNT(__first, __last, __max); __first = __parse_DUP_COUNT(__first, __last, __max);
__temp = __parse_Back_close_brace(__first, __last); __temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (__max == -1) if (__max == -1)
__push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
else else
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min) if (__max < __min)
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end, __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
true); true);
} }
@ -3608,15 +3591,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{ {
int __min; int __min;
_ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
switch (*__first) switch (*__first)
{ {
case '}': case '}':
@ -3631,10 +3610,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
break; break;
case ',': case ',':
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (*__first == '}') if (*__first == '}')
{ {
++__first; ++__first;
@ -3650,20 +3627,14 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{ {
int __max = -1; int __max = -1;
__temp = __parse_DUP_COUNT(__first, __last, __max); __temp = __parse_DUP_COUNT(__first, __last, __max);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != '}') if (__first == __last || *__first != '}')
throw regex_error(regex_constants::error_brace); __throw_regex_error<regex_constants::error_brace>();
#endif // _LIBCPP_NO_EXCEPTIONS
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min) if (__max < __min)
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (__grammar == ECMAScript && __first != __last && *__first == '?') if (__grammar == ECMAScript && __first != __last && *__first == '?')
{ {
++__first; ++__first;
@ -3673,10 +3644,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end); __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
} }
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_badbrace); __throw_regex_error<regex_constants::error_badbrace>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
} }
break; break;
@ -3694,10 +3663,8 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
if (__first != __last && *__first == '[') if (__first != __last && *__first == '[')
{ {
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
bool __negate = false; bool __negate = false;
if (*__first == '^') if (*__first == '^')
{ {
@ -3706,29 +3673,23 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
} }
__bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
// __ml owned by *this // __ml owned by *this
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
{ {
__ml->__add_char(']'); __ml->__add_char(']');
++__first; ++__first;
} }
__first = __parse_follow_list(__first, __last, __ml); __first = __parse_follow_list(__first, __last, __ml);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
if (*__first == '-') if (*__first == '-')
{ {
__ml->__add_char('-'); __ml->__add_char('-');
++__first; ++__first;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ']') if (__first == __last || *__first != ']')
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
++__first; ++__first;
} }
return __first; return __first;
@ -3848,10 +3809,8 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
basic_string<_CharT>& __str, basic_string<_CharT>& __str,
__bracket_expression<_CharT, _Traits>* __ml) __bracket_expression<_CharT, _Traits>* __ml)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
switch (*__first) switch (*__first)
{ {
case 0: case 0:
@ -3892,10 +3851,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
_ForwardIterator __last, _ForwardIterator __last,
basic_string<_CharT>* __str) basic_string<_CharT>* __str)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
switch (*__first) switch (*__first)
{ {
case '\\': case '\\':
@ -3963,10 +3920,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
else else
__push_char(_CharT(__val)); __push_char(_CharT(__val));
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else else
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
return __first; return __first;
} }
@ -3982,18 +3937,14 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
value_type _Equal_close[2] = {'=', ']'}; value_type _Equal_close[2] = {'=', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close, _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
_Equal_close+2); _Equal_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
// [__first, __temp) contains all text in [= ... =] // [__first, __temp) contains all text in [= ... =]
typedef typename _Traits::string_type string_type; typedef typename _Traits::string_type string_type;
string_type __collate_name = string_type __collate_name =
__traits_.lookup_collatename(__first, __temp); __traits_.lookup_collatename(__first, __temp);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__collate_name.empty()) if (__collate_name.empty())
throw regex_error(regex_constants::error_collate); __throw_regex_error<regex_constants::error_collate>();
#endif // _LIBCPP_NO_EXCEPTIONS
string_type __equiv_name = string_type __equiv_name =
__traits_.transform_primary(__collate_name.begin(), __traits_.transform_primary(__collate_name.begin(),
__collate_name.end()); __collate_name.end());
@ -4009,10 +3960,8 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
case 2: case 2:
__ml->__add_digraph(__collate_name[0], __collate_name[1]); __ml->__add_digraph(__collate_name[0], __collate_name[1]);
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_collate); __throw_regex_error<regex_constants::error_collate>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
} }
__first = _VSTD::next(__temp, 2); __first = _VSTD::next(__temp, 2);
@ -4031,18 +3980,14 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
value_type _Colon_close[2] = {':', ']'}; value_type _Colon_close[2] = {':', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close, _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
_Colon_close+2); _Colon_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
// [__first, __temp) contains all text in [: ... :] // [__first, __temp) contains all text in [: ... :]
typedef typename _Traits::char_class_type char_class_type; typedef typename _Traits::char_class_type char_class_type;
char_class_type __class_type = char_class_type __class_type =
__traits_.lookup_classname(__first, __temp, __flags_ & icase); __traits_.lookup_classname(__first, __temp, __flags_ & icase);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__class_type == 0) if (__class_type == 0)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
__ml->__add_class(__class_type); __ml->__add_class(__class_type);
__first = _VSTD::next(__temp, 2); __first = _VSTD::next(__temp, 2);
return __first; return __first;
@ -4060,10 +4005,8 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
value_type _Dot_close[2] = {'.', ']'}; value_type _Dot_close[2] = {'.', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close, _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
_Dot_close+2); _Dot_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); __throw_regex_error<regex_constants::error_brack>();
#endif // _LIBCPP_NO_EXCEPTIONS
// [__first, __temp) contains all text in [. ... .] // [__first, __temp) contains all text in [. ... .]
__col_sym = __traits_.lookup_collatename(__first, __temp); __col_sym = __traits_.lookup_collatename(__first, __temp);
switch (__col_sym.size()) switch (__col_sym.size())
@ -4071,10 +4014,8 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
case 1: case 1:
case 2: case 2:
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_collate); __throw_regex_error<regex_constants::error_collate>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
__first = _VSTD::next(__temp, 2); __first = _VSTD::next(__temp, 2);
return __first; return __first;
@ -4218,10 +4159,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
unsigned __mexp = __exp.__marked_count_; unsigned __mexp = __exp.__marked_count_;
__push_lookahead(_VSTD::move(__exp), false, __marked_count_); __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
__marked_count_ += __mexp; __marked_count_ += __mexp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = ++__temp; __first = ++__temp;
} }
break; break;
@ -4233,10 +4172,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
unsigned __mexp = __exp.__marked_count_; unsigned __mexp = __exp.__marked_count_;
__push_lookahead(_VSTD::move(__exp), true, __marked_count_); __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
__marked_count_ += __mexp; __marked_count_ += __mexp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
__first = ++__temp; __first = ++__temp;
} }
break; break;
@ -4273,19 +4210,15 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
case '(': case '(':
{ {
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
_ForwardIterator __temp = _VSTD::next(__first); _ForwardIterator __temp = _VSTD::next(__first);
if (__temp != __last && *__first == '?' && *__temp == ':') if (__temp != __last && *__first == '?' && *__temp == ':')
{ {
++__open_count_; ++__open_count_;
__first = __parse_ecma_exp(++__temp, __last); __first = __parse_ecma_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')') if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
--__open_count_; --__open_count_;
++__first; ++__first;
} }
@ -4295,10 +4228,8 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
++__open_count_; ++__open_count_;
__first = __parse_ecma_exp(__first, __last); __first = __parse_ecma_exp(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')') if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren); __throw_regex_error<regex_constants::error_paren>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
--__open_count_; --__open_count_;
++__first; ++__first;
@ -4309,9 +4240,7 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
case '+': case '+':
case '?': case '?':
case '{': case '{':
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_regex_error<regex_constants::error_badrepeat>();
throw regex_error(regex_constants::error_badrepeat);
#endif
break; break;
default: default:
__first = __parse_pattern_character(__first, __last); __first = __parse_pattern_character(__first, __last);
@ -4367,10 +4296,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
unsigned __v = *__first - '0'; unsigned __v = *__first - '0';
for (++__first; '0' <= *__first && *__first <= '9'; ++__first) for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
__v = 10 * __v + *__first - '0'; __v = 10 * __v + *__first - '0';
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__v > mark_count()) if (__v > mark_count())
throw regex_error(regex_constants::error_backref); __throw_regex_error<regex_constants::error_backref>();
#endif // _LIBCPP_NO_EXCEPTIONS
__push_back_ref(__v); __push_back_ref(__v);
} }
} }
@ -4486,62 +4413,42 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(_CharT(*__t % 32)); __push_char(_CharT(*__t % 32));
__first = ++__t; __first = ++__t;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else else
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else else
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
break; break;
case 'u': case 'u':
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__sum = 16 * __sum + static_cast<unsigned>(__hd); __sum = 16 * __sum + static_cast<unsigned>(__hd);
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__sum = 16 * __sum + static_cast<unsigned>(__hd); __sum = 16 * __sum + static_cast<unsigned>(__hd);
// drop through // drop through
case 'x': case 'x':
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__sum = 16 * __sum + static_cast<unsigned>(__hd); __sum = 16 * __sum + static_cast<unsigned>(__hd);
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
__sum = 16 * __sum + static_cast<unsigned>(__hd); __sum = 16 * __sum + static_cast<unsigned>(__hd);
if (__str) if (__str)
*__str = _CharT(__sum); *__str = _CharT(__sum);
@ -4565,10 +4472,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(*__first); __push_char(*__first);
++__first; ++__first;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else else
throw regex_error(regex_constants::error_escape); __throw_regex_error<regex_constants::error_escape>();
#endif // _LIBCPP_NO_EXCEPTIONS
break; break;
} }
} }
@ -5655,9 +5560,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_regex_error<regex_constants::__re_err_unknown>();
throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
@ -5727,9 +5630,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_regex_error<regex_constants::__re_err_unknown>();
throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
} while (!__states.empty()); } while (!__states.empty());
@ -5815,9 +5716,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_regex_error<regex_constants::__re_err_unknown>();
throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
} while (!__states.empty()); } while (!__states.empty());