aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-05-02 11:27:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-05-02 11:28:35 +0200
commitaa44a864777e9896956ff6dae8fd66ddbaae6db8 (patch)
treeec062fa82bc265ec6558e5bcdc221fce216d841e /libbuild2
parent48707e16dd0c8806e99387b0718a078ecf092f69 (diff)
Don't verify parser replay integrity if exception is being thrown
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/parser.hxx24
1 files changed, 21 insertions, 3 deletions
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 <exception> // uncaught_exception[s]()
+
+#include <libbutl/ft/exception.hxx> // uncaught_exceptions
+
#include <libbuild2/types.hxx>
#include <libbuild2/forward.hxx>
#include <libbuild2/utility.hxx>
@@ -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_;
};