From b7c9940221f634fb501613be9e73be1dc778adc3 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sun, 30 May 2021 17:48:14 -0700 Subject: [PATCH] gracefully deal with "eval" exceptions that occur during AST reduction --- src/script_opt/Reduce.cc | 14 ++++++++++++++ src/script_opt/Reduce.h | 6 +----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/script_opt/Reduce.cc b/src/script_opt/Reduce.cc index f3d0603879..cd4ba8d9ca 100644 --- a/src/script_opt/Reduce.cc +++ b/src/script_opt/Reduce.cc @@ -14,6 +14,20 @@ namespace zeek::detail { +StmtPtr Reducer::Reduce(StmtPtr s) + { + reduction_root = std::move(s); + + try + { + return reduction_root->Reduce(this); + } + catch ( InterpreterException& e ) + { + /* Already reported. */ + return reduction_root; + } + } ExprPtr Reducer::GenTemporaryExpr(const TypePtr& t, ExprPtr rhs) { diff --git a/src/script_opt/Reduce.h b/src/script_opt/Reduce.h index ac62a61c0b..3df88d2913 100644 --- a/src/script_opt/Reduce.h +++ b/src/script_opt/Reduce.h @@ -18,11 +18,7 @@ class Reducer { public: Reducer() { } - StmtPtr Reduce(StmtPtr s) - { - reduction_root = std::move(s); - return reduction_root->Reduce(this); - } + StmtPtr Reduce(StmtPtr s); const DefSetsMgr* GetDefSetsMgr() const { return mgr; } void SetDefSetsMgr(const DefSetsMgr* _mgr) { mgr = _mgr; }