Message ID | 20220105134759.1639818-1-jwakely@redhat.com |
---|---|
State | New |
Headers | show |
Series | [committed] libstdc++: Reduce template instantiations in <regex> | expand |
On 05/01/2022 14:47, Jonathan Wakely via Libstdc++ wrote: > Tested powerpc64le-linux, pushed to trunk. > > > This moves the last two template parameters of __regex_algo_impl to be > runtime function parameters instead, so that we don't need four > different instantiations for the possible ways to call it. Most of the > function (and what it instantiates) is the same in all cases, so making > them compile-time choices doesn't really have much benefit. > > Use 'if constexpr' for conditions that check template parameters, so > that when we do depend on a compile-time condition we only instantiate > what we need to. > > libstdc++-v3/ChangeLog: > > * include/bits/regex.h (__regex_algo_impl): Change __policy and > __match_mode template parameters to be function parameters. > (regex_match, regex_search): Pass policy and match mode as > function arguments. > * include/bits/regex.tcc (__regex_algo_impl): Change template > parameters to function parameters. > * include/bits/regex_compiler.h (_RegexTranslatorBase): Use > 'if constexpr' for conditions using template parameters. > (_RegexTranslator): Likewise. > * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): > Likewise. > * testsuite/util/testsuite_regex.h (regex_match_debug) > (regex_search_debug): Move template arguments to function > arguments. > --- > libstdc++-v3/include/bits/regex.h | 33 +++++++++---------- > libstdc++-v3/include/bits/regex.tcc | 8 ++--- > libstdc++-v3/include/bits/regex_compiler.h | 9 ++--- > libstdc++-v3/include/bits/regex_executor.tcc | 2 +- > libstdc++-v3/testsuite/util/testsuite_regex.h | 24 +++++++------- > 5 files changed, 37 insertions(+), 39 deletions(-) Clang now fails #include <regex> with > In file included from gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/regex:66: > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:799:9: error: unknown type name '_RegexExecutorPolicy'; did you mean '__detail::_RegexExecutorPolicy'? > _RegexExecutorPolicy, bool); > ^ > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: note: '__detail::_RegexExecutorPolicy' declared here > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; > ^ > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:2070:9: error: unknown type name '_RegexExecutorPolicy'; did you mean '__detail::_RegexExecutorPolicy'? > _RegexExecutorPolicy, bool); > ^ > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: note: '__detail::_RegexExecutorPolicy' declared here > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; > ^ and > diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h > index 7480b0a5f97..46c168010bf 100644 > --- a/libstdc++-v3/include/bits/regex.h > +++ b/libstdc++-v3/include/bits/regex.h > @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, > const basic_regex<_Cp, _Rp>&, > regex_constants::match_flag_type, > - _RegexExecutorPolicy, bool); > + __detail::_RegexExecutorPolicy, bool); > > template<typename, typename, typename, bool> > friend class __detail::_Executor; > @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, > const basic_regex<_Cp, _Rp>&, > regex_constants::match_flag_type, > - _RegexExecutorPolicy, bool); > + __detail::_RegexExecutorPolicy, bool); > > // Reset contents to __size unmatched sub_match objects > // (plus additional objects for prefix, suffix and unmatched sub). would fix that.
On Thu, 6 Jan 2022 at 10:00, Stephan Bergmann <sbergman@redhat.com> wrote: > On 05/01/2022 14:47, Jonathan Wakely via Libstdc++ wrote: > > Tested powerpc64le-linux, pushed to trunk. > > > > > > This moves the last two template parameters of __regex_algo_impl to be > > runtime function parameters instead, so that we don't need four > > different instantiations for the possible ways to call it. Most of the > > function (and what it instantiates) is the same in all cases, so making > > them compile-time choices doesn't really have much benefit. > > > > Use 'if constexpr' for conditions that check template parameters, so > > that when we do depend on a compile-time condition we only instantiate > > what we need to. > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/regex.h (__regex_algo_impl): Change __policy and > > __match_mode template parameters to be function parameters. > > (regex_match, regex_search): Pass policy and match mode as > > function arguments. > > * include/bits/regex.tcc (__regex_algo_impl): Change template > > parameters to function parameters. > > * include/bits/regex_compiler.h (_RegexTranslatorBase): Use > > 'if constexpr' for conditions using template parameters. > > (_RegexTranslator): Likewise. > > * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): > > Likewise. > > * testsuite/util/testsuite_regex.h (regex_match_debug) > > (regex_search_debug): Move template arguments to function > > arguments. > > --- > > libstdc++-v3/include/bits/regex.h | 33 +++++++++---------- > > libstdc++-v3/include/bits/regex.tcc | 8 ++--- > > libstdc++-v3/include/bits/regex_compiler.h | 9 ++--- > > libstdc++-v3/include/bits/regex_executor.tcc | 2 +- > > libstdc++-v3/testsuite/util/testsuite_regex.h | 24 +++++++------- > > 5 files changed, 37 insertions(+), 39 deletions(-) > > Clang now fails #include <regex> with > > > In file included from > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/regex:66: > > > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:799:9: > error: unknown type name '_RegexExecutorPolicy'; did you mean > '__detail::_RegexExecutorPolicy'? > > _RegexExecutorPolicy, bool); > > ^ > > > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: > note: '__detail::_RegexExecutorPolicy' declared here > > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; > > ^ > > > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:2070:9: > error: unknown type name '_RegexExecutorPolicy'; did you mean > '__detail::_RegexExecutorPolicy'? > > _RegexExecutorPolicy, bool); > > ^ > > > gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: > note: '__detail::_RegexExecutorPolicy' declared here > > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; > > ^ > > and > > > diff --git a/libstdc++-v3/include/bits/regex.h > b/libstdc++-v3/include/bits/regex.h > > index 7480b0a5f97..46c168010bf 100644 > > --- a/libstdc++-v3/include/bits/regex.h > > +++ b/libstdc++-v3/include/bits/regex.h > > @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, > > const basic_regex<_Cp, _Rp>&, > > regex_constants::match_flag_type, > > - _RegexExecutorPolicy, bool); > > + __detail::_RegexExecutorPolicy, > bool); > > > > template<typename, typename, typename, bool> > > friend class __detail::_Executor; > > @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, > > const basic_regex<_Cp, _Rp>&, > > regex_constants::match_flag_type, > > - _RegexExecutorPolicy, bool); > > + __detail::_RegexExecutorPolicy, > bool); > > > > // Reset contents to __size unmatched sub_match objects > > // (plus additional objects for prefix, suffix and unmatched sub). > > would fix that. > I'll make the change, but this looks like a clang bug: https://godbolt.org/z/bozxYErrc
On Thu, 6 Jan 2022 at 10:33, Jonathan Wakely <jwakely@redhat.com> wrote: > > > On Thu, 6 Jan 2022 at 10:00, Stephan Bergmann <sbergman@redhat.com> wrote: > >> On 05/01/2022 14:47, Jonathan Wakely via Libstdc++ wrote: >> > Tested powerpc64le-linux, pushed to trunk. >> > >> > >> > This moves the last two template parameters of __regex_algo_impl to be >> > runtime function parameters instead, so that we don't need four >> > different instantiations for the possible ways to call it. Most of the >> > function (and what it instantiates) is the same in all cases, so making >> > them compile-time choices doesn't really have much benefit. >> > >> > Use 'if constexpr' for conditions that check template parameters, so >> > that when we do depend on a compile-time condition we only instantiate >> > what we need to. >> > >> > libstdc++-v3/ChangeLog: >> > >> > * include/bits/regex.h (__regex_algo_impl): Change __policy and >> > __match_mode template parameters to be function parameters. >> > (regex_match, regex_search): Pass policy and match mode as >> > function arguments. >> > * include/bits/regex.tcc (__regex_algo_impl): Change template >> > parameters to function parameters. >> > * include/bits/regex_compiler.h (_RegexTranslatorBase): Use >> > 'if constexpr' for conditions using template parameters. >> > (_RegexTranslator): Likewise. >> > * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): >> > Likewise. >> > * testsuite/util/testsuite_regex.h (regex_match_debug) >> > (regex_search_debug): Move template arguments to function >> > arguments. >> > --- >> > libstdc++-v3/include/bits/regex.h | 33 +++++++++---------- >> > libstdc++-v3/include/bits/regex.tcc | 8 ++--- >> > libstdc++-v3/include/bits/regex_compiler.h | 9 ++--- >> > libstdc++-v3/include/bits/regex_executor.tcc | 2 +- >> > libstdc++-v3/testsuite/util/testsuite_regex.h | 24 +++++++------- >> > 5 files changed, 37 insertions(+), 39 deletions(-) >> >> Clang now fails #include <regex> with >> >> > In file included from >> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/regex:66: >> > >> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:799:9: >> error: unknown type name '_RegexExecutorPolicy'; did you mean >> '__detail::_RegexExecutorPolicy'? >> > _RegexExecutorPolicy, bool); >> > ^ >> > >> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >> note: '__detail::_RegexExecutorPolicy' declared here >> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >> > ^ >> > >> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:2070:9: >> error: unknown type name '_RegexExecutorPolicy'; did you mean >> '__detail::_RegexExecutorPolicy'? >> > _RegexExecutorPolicy, bool); >> > ^ >> > >> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >> note: '__detail::_RegexExecutorPolicy' declared here >> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >> > ^ >> >> and >> >> > diff --git a/libstdc++-v3/include/bits/regex.h >> b/libstdc++-v3/include/bits/regex.h >> > index 7480b0a5f97..46c168010bf 100644 >> > --- a/libstdc++-v3/include/bits/regex.h >> > +++ b/libstdc++-v3/include/bits/regex.h >> > @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >> > const basic_regex<_Cp, _Rp>&, >> > regex_constants::match_flag_type, >> > - _RegexExecutorPolicy, bool); >> > + __detail::_RegexExecutorPolicy, >> bool); >> > >> > template<typename, typename, typename, bool> >> > friend class __detail::_Executor; >> > @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >> > const basic_regex<_Cp, _Rp>&, >> > regex_constants::match_flag_type, >> > - _RegexExecutorPolicy, bool); >> > + __detail::_RegexExecutorPolicy, >> bool); >> > >> > // Reset contents to __size unmatched sub_match objects >> > // (plus additional objects for prefix, suffix and unmatched >> sub). >> >> would fix that. >> > > > I'll make the change, but this looks like a clang bug: > https://godbolt.org/z/bozxYErrc > Maybe this one: https://github.com/llvm/llvm-project/issues/38230
On Thu, 6 Jan 2022 at 10:43, Jonathan Wakely <jwakely@redhat.com> wrote: > > > On Thu, 6 Jan 2022 at 10:33, Jonathan Wakely <jwakely@redhat.com> wrote: > >> >> >> On Thu, 6 Jan 2022 at 10:00, Stephan Bergmann <sbergman@redhat.com> >> wrote: >> >>> On 05/01/2022 14:47, Jonathan Wakely via Libstdc++ wrote: >>> > Tested powerpc64le-linux, pushed to trunk. >>> > >>> > >>> > This moves the last two template parameters of __regex_algo_impl to be >>> > runtime function parameters instead, so that we don't need four >>> > different instantiations for the possible ways to call it. Most of the >>> > function (and what it instantiates) is the same in all cases, so making >>> > them compile-time choices doesn't really have much benefit. >>> > >>> > Use 'if constexpr' for conditions that check template parameters, so >>> > that when we do depend on a compile-time condition we only instantiate >>> > what we need to. >>> > >>> > libstdc++-v3/ChangeLog: >>> > >>> > * include/bits/regex.h (__regex_algo_impl): Change __policy and >>> > __match_mode template parameters to be function parameters. >>> > (regex_match, regex_search): Pass policy and match mode as >>> > function arguments. >>> > * include/bits/regex.tcc (__regex_algo_impl): Change template >>> > parameters to function parameters. >>> > * include/bits/regex_compiler.h (_RegexTranslatorBase): Use >>> > 'if constexpr' for conditions using template parameters. >>> > (_RegexTranslator): Likewise. >>> > * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): >>> > Likewise. >>> > * testsuite/util/testsuite_regex.h (regex_match_debug) >>> > (regex_search_debug): Move template arguments to function >>> > arguments. >>> > --- >>> > libstdc++-v3/include/bits/regex.h | 33 >>> +++++++++---------- >>> > libstdc++-v3/include/bits/regex.tcc | 8 ++--- >>> > libstdc++-v3/include/bits/regex_compiler.h | 9 ++--- >>> > libstdc++-v3/include/bits/regex_executor.tcc | 2 +- >>> > libstdc++-v3/testsuite/util/testsuite_regex.h | 24 +++++++------- >>> > 5 files changed, 37 insertions(+), 39 deletions(-) >>> >>> Clang now fails #include <regex> with >>> >>> > In file included from >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/regex:66: >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:799:9: >>> error: unknown type name '_RegexExecutorPolicy'; did you mean >>> '__detail::_RegexExecutorPolicy'? >>> > _RegexExecutorPolicy, bool); >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >>> note: '__detail::_RegexExecutorPolicy' declared here >>> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:2070:9: >>> error: unknown type name '_RegexExecutorPolicy'; did you mean >>> '__detail::_RegexExecutorPolicy'? >>> > _RegexExecutorPolicy, bool); >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >>> note: '__detail::_RegexExecutorPolicy' declared here >>> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >>> > ^ >>> >>> and >>> >>> > diff --git a/libstdc++-v3/include/bits/regex.h >>> b/libstdc++-v3/include/bits/regex.h >>> > index 7480b0a5f97..46c168010bf 100644 >>> > --- a/libstdc++-v3/include/bits/regex.h >>> > +++ b/libstdc++-v3/include/bits/regex.h >>> > @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >>> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >>> > const basic_regex<_Cp, _Rp>&, >>> > regex_constants::match_flag_type, >>> > - _RegexExecutorPolicy, bool); >>> > + __detail::_RegexExecutorPolicy, >>> bool); >>> > >>> > template<typename, typename, typename, bool> >>> > friend class __detail::_Executor; >>> > @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >>> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >>> > const basic_regex<_Cp, _Rp>&, >>> > regex_constants::match_flag_type, >>> > - _RegexExecutorPolicy, bool); >>> > + __detail::_RegexExecutorPolicy, >>> bool); >>> > >>> > // Reset contents to __size unmatched sub_match objects >>> > // (plus additional objects for prefix, suffix and unmatched >>> sub). >>> >>> would fix that. >>> >> >> >> I'll make the change, but this looks like a clang bug: >> https://godbolt.org/z/bozxYErrc >> > > Maybe this one: https://github.com/llvm/llvm-project/issues/38230 > I've pushed the fix now, thanks for the report. commit ec12ddd1e7f7d6b48a593df865e7846039e7d62e Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Jan 6 11:11:52 2022 libstdc++: Adjust friend declarations to work with Clang I think this code is valid but it fails with Clang, possibly due to https://llvm.org/PR38882 Qualifying the names makes it work for all compilers. libstdc++-v3/ChangeLog: * include/bits/regex.h (basic_regex, match_results): Qualify name in friend declaration, to work around Clang bug. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 7480b0a5f97..46c168010bf 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Rp>&, regex_constants::match_flag_type, - _RegexExecutorPolicy, bool); + __detail::_RegexExecutorPolicy, bool); template<typename, typename, typename, bool> friend class __detail::_Executor; @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Rp>&, regex_constants::match_flag_type, - _RegexExecutorPolicy, bool); + __detail::_RegexExecutorPolicy, bool); // Reset contents to __size unmatched sub_match objects // (plus additional objects for prefix, suffix and unmatched sub).
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index ff09f49f9e8..7480b0a5f97 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -45,15 +45,14 @@ namespace __detail enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; template<typename _BiIter, typename _Alloc, - typename _CharT, typename _TraitsT, - _RegexExecutorPolicy __policy, - bool __match_mode> + typename _CharT, typename _TraitsT> bool - __regex_algo_impl(_BiIter __s, - _BiIter __e, + __regex_algo_impl(_BiIter __s, _BiIter __e, match_results<_BiIter, _Alloc>& __m, const basic_regex<_CharT, _TraitsT>& __re, - regex_constants::match_flag_type __flags); + regex_constants::match_flag_type __flags, + _RegexExecutorPolicy __policy, + bool __match_mode); template<typename, typename, typename, bool> class _Executor; @@ -792,12 +791,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_flags = __f; } - template<typename _Bp, typename _Ap, typename _Cp, typename _Rp, - __detail::_RegexExecutorPolicy, bool> + template<typename _Bp, typename _Ap, typename _Cp, typename _Rp> friend bool __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Rp>&, - regex_constants::match_flag_type); + regex_constants::match_flag_type, + _RegexExecutorPolicy, bool); template<typename, typename, typename, bool> friend class __detail::_Executor; @@ -2063,12 +2062,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template<typename, typename, typename, bool> friend class __detail::_Executor; - template<typename _Bp, typename _Ap, typename _Cp, typename _Rp, - __detail::_RegexExecutorPolicy, bool> + template<typename _Bp, typename _Ap, typename _Cp, typename _Rp> friend bool __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Rp>&, - regex_constants::match_flag_type); + regex_constants::match_flag_type, + _RegexExecutorPolicy, bool); // Reset contents to __size unmatched sub_match objects // (plus additional objects for prefix, suffix and unmatched sub). @@ -2206,9 +2205,8 @@ _GLIBCXX_END_NAMESPACE_CXX11 regex_constants::match_flag_type __flags = regex_constants::match_default) { - return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - __detail::_RegexExecutorPolicy::_S_auto, true> - (__s, __e, __m, __re, __flags); + return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags, + __detail::_RegexExecutorPolicy::_S_auto, true); } /** @@ -2363,9 +2361,8 @@ _GLIBCXX_END_NAMESPACE_CXX11 regex_constants::match_flag_type __flags = regex_constants::match_default) { - return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - __detail::_RegexExecutorPolicy::_S_auto, false> - (__s, __e, __m, __re, __flags); + return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags, + __detail::_RegexExecutorPolicy::_S_auto, false); } /** diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc index 7d720ca7b42..2b90b04c560 100644 --- a/libstdc++-v3/include/bits/regex.tcc +++ b/libstdc++-v3/include/bits/regex.tcc @@ -43,15 +43,15 @@ namespace __detail // // That __match_mode is true means regex_match, else regex_search. template<typename _BiIter, typename _Alloc, - typename _CharT, typename _TraitsT, - _RegexExecutorPolicy __policy, - bool __match_mode> + typename _CharT, typename _TraitsT> bool __regex_algo_impl(_BiIter __s, _BiIter __e, match_results<_BiIter, _Alloc>& __m, const basic_regex<_CharT, _TraitsT>& __re, - regex_constants::match_flag_type __flags) + regex_constants::match_flag_type __flags, + _RegexExecutorPolicy __policy, + bool __match_mode) { if (__re._M_automaton == nullptr) return false; diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h index 6a9af358c4b..174aefe75f7 100644 --- a/libstdc++-v3/include/bits/regex_compiler.h +++ b/libstdc++-v3/include/bits/regex_compiler.h @@ -221,9 +221,9 @@ namespace __detail _CharT _M_translate(_CharT __ch) const { - if (__icase) + if _GLIBCXX17_CONSTEXPR (__icase) return _M_traits.translate_nocase(__ch); - else if (__collate) + else if _GLIBCXX17_CONSTEXPR (__collate) return _M_traits.translate(__ch); else return __ch; @@ -285,9 +285,10 @@ namespace __detail bool _M_match_range(_CharT __first, _CharT __last, _CharT __ch) const { - if (!__icase) + if _GLIBCXX17_CONSTEXPR (!__icase) return __first <= __ch && __ch <= __last; - return this->_M_in_range_icase(__first, __last, __ch); + else + return this->_M_in_range_icase(__first, __last, __ch); } }; diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc index b3e2726a55f..b93e958075e 100644 --- a/libstdc++-v3/include/bits/regex_executor.tcc +++ b/libstdc++-v3/include/bits/regex_executor.tcc @@ -425,7 +425,7 @@ namespace __detail void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: _M_handle_accept(_Match_mode __match_mode, _StateIdT) { - if (__dfs_mode) + if _GLIBCXX17_CONSTEXPR (__dfs_mode) { __glibcxx_assert(!_M_has_sol); if (__match_mode == _Match_mode::_Exact) diff --git a/libstdc++-v3/testsuite/util/testsuite_regex.h b/libstdc++-v3/testsuite/util/testsuite_regex.h index f2bb068024d..4e163c3a3f8 100644 --- a/libstdc++-v3/testsuite/util/testsuite_regex.h +++ b/libstdc++-v3/testsuite/util/testsuite_regex.h @@ -143,13 +143,13 @@ namespace __gnu_test = std::regex_constants::match_default) { using namespace std::__detail; - auto __res1 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - _RegexExecutorPolicy::_S_auto, true> - (__s, __e, __m, __re, __flags); + auto __res1 = __regex_algo_impl(__s, __e, __m, __re, __flags, + _RegexExecutorPolicy::_S_auto, + true); match_results<_Bi_iter, _Alloc> __mm; - auto __res2 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - _RegexExecutorPolicy::_S_alternate, true> - (__s, __e, __mm, __re, __flags); + auto __res2 = __regex_algo_impl(__s, __e, __mm, __re, __flags, + _RegexExecutorPolicy::_S_alternate, + true); if (__res1 == __res2 && __m == __mm) return __res1; throw std::exception(); @@ -229,13 +229,13 @@ namespace __gnu_test = std::regex_constants::match_default) { using namespace std::__detail; - auto __res1 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - _RegexExecutorPolicy::_S_auto, false> - (__s, __e, __m, __re, __flags); + auto __res1 = __regex_algo_impl(__s, __e, __m, __re, __flags, + _RegexExecutorPolicy::_S_auto, + false); match_results<_Bi_iter, _Alloc> __mm; - auto __res2 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, - _RegexExecutorPolicy::_S_alternate, false> - (__s, __e, __mm, __re, __flags); + auto __res2 = __regex_algo_impl(__s, __e, __mm, __re, __flags, + _RegexExecutorPolicy::_S_alternate, + false); if (__res1 == __res2 && __m == __mm) return __res1; throw(std::exception()); // Let test fail. Give it a name.