From aa44a864777e9896956ff6dae8fd66ddbaae6db8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 2 May 2022 11:27:17 +0200 Subject: Don't verify parser replay integrity if exception is being thrown --- libbuild2/parser.hxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'libbuild2/parser.hxx') diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx index 4f105e5..a6060d5 100644 --- a/libbuild2/parser.hxx +++ b/libbuild2/parser.hxx @@ -4,6 +4,10 @@ #ifndef LIBBUILD2_PARSER_HXX #define LIBBUILD2_PARSER_HXX +#include // uncaught_exception[s]() + +#include // uncaught_exceptions + #include #include #include @@ -735,9 +739,10 @@ namespace build2 } void - replay_stop () + replay_stop (bool verify = true) { - assert (!peeked_); + if (verify) + assert (!peeked_); if (replay_ == replay::play) path_ = replay_path_; // Restore old path. @@ -765,10 +770,23 @@ namespace build2 ~replay_guard () { if (p_ != nullptr) - p_->replay_stop (); + p_->replay_stop (!uncaught_exception ()); } private: + // C++17 deprecated uncaught_exception() so use uncaught_exceptions() if + // available. + // + static bool + uncaught_exception () + { +#ifdef __cpp_lib_uncaught_exceptions + return std::uncaught_exceptions () != 0; +#else + return std::uncaught_exception (); +#endif + } + parser* p_; }; -- cgit v1.1