0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::spirit: Add nothrow/noexcept overload to force no EH at callsite.

This commit is contained in:
Jason Volk 2022-05-14 14:22:18 -07:00
parent b1f1e003d2
commit 03c69de789

View file

@ -35,6 +35,10 @@ __attribute__((visibility("internal")))
class gen, class gen,
class... attr> class... attr>
bool parse(const char *&start, const char *const &stop, gen&&, attr&&...); bool parse(const char *&start, const char *const &stop, gen&&, attr&&...);
template<class gen,
class... attr>
bool parse(std::nothrow_t, const char *&start, const char *const &stop, gen&&, attr&&...) noexcept;
}} }}
namespace boost { namespace boost {
@ -145,6 +149,32 @@ struct ircd::spirit::substring_view
{} {}
}; };
/// Execute the parse. The start pointer is advanced upon successful execution.
/// Failures must not throw: If the grammar contains any epsilon expressions or
/// callbacks which throw it is UB. This overload exists to force suppression
/// of EH from the base of a complex/opaque rule tree.
template<class gen,
class... attr>
[[using gnu: always_inline, gnu_inline, artificial]]
extern inline bool
ircd::spirit::parse(std::nothrow_t,
const char *&start,
const char *const &stop,
gen&& g,
attr&&... a)
noexcept try
{
return ircd::spirit::parse(start, stop, std::forward<gen>(g), std::forward<attr>(a)...);
}
catch(...)
{
assert(false);
__builtin_unreachable();
}
/// Execute the parse. The start pointer is advanced upon successful execution.
/// Failures may throw depending on the grammar. Boost's expectation_failure is
/// translated into our expectation_failure describing the failure.
template<class parent_error, template<class parent_error,
size_t error_show_max, size_t error_show_max,
class gen, class gen,
@ -157,7 +187,7 @@ ircd::spirit::parse(const char *&start,
attr&&... a) attr&&... a)
try try
{ {
return qi::parse(start, stop, std::forward<gen>(g), std::forward<attr>(a)...); return ircd::spirit::parse(start, stop, std::forward<gen>(g), std::forward<attr>(a)...);
} }
catch(const qi::expectation_failure<const char *> &e) catch(const qi::expectation_failure<const char *> &e)
{ {
@ -167,6 +197,8 @@ catch(const qi::expectation_failure<const char *> &e)
}; };
} }
/// Low-level qi::parse entry point. Throws boost's qi::expectation_failure;
/// Try not to allow this exception to escape the calling unit.
template<class gen, template<class gen,
class... attr> class... attr>
[[using gnu: always_inline, gnu_inline, artificial]] [[using gnu: always_inline, gnu_inline, artificial]]