Merge remote-tracking branch 'origin/topic/vern/script-opt-keep-asserts'

* origin/topic/vern/script-opt-keep-asserts:
  ZAM documentation updates for asserts and event handler run-time errors
  BTest updates for ZAM support of (optionally) keeping "assert" statements
  command-line options for controlling script optimization: keeping asserts, avoiding event handler coalescence
  ZAM support for option to not coalesce event handlers
  ZAM support for keeping "assert" statements
  internal support for script optimization options for keeping asserts, not consolidating event handlers
  ZAM operations to support asserts
  simplified "assert" by not trying to catch messages that themselves have errors

Fixed some TEST-REQUIRES "${ZEEK_ZAM}" == "1" to use "=" instead to
be /bin/sh compatible.
This commit is contained in:
Arne Welzel 2024-12-05 21:43:26 +01:00
commit 93a3a11d36
63 changed files with 312 additions and 75 deletions

View file

@ -1069,11 +1069,36 @@ StmtPtr InitStmt::DoReduce(Reducer* c) {
return ThisPtr();
}
StmtPtr AssertStmt::Duplicate() { return SetSucc(new AssertStmt(cond->Duplicate(), msg ? msg->Duplicate() : nullptr)); }
StmtPtr AssertStmt::Duplicate() { return SetSucc(new AssertStmt(e->Duplicate(), msg ? msg->Duplicate() : nullptr)); }
bool AssertStmt::IsReduced(Reducer* c) const { return false; }
bool AssertStmt::IsReduced(Reducer* c) const {
if ( ! analysis_options.keep_asserts )
return false;
StmtPtr AssertStmt::DoReduce(Reducer* c) { return TransformMe(make_intrusive<NullStmt>(), c); }
return e->IsSingleton(c) && (! msg || msg->IsSingleton(c));
}
StmtPtr AssertStmt::DoReduce(Reducer* c) {
if ( ! analysis_options.keep_asserts )
return TransformMe(make_intrusive<NullStmt>(), c);
if ( c->Optimizing() ) {
e = c->OptExpr(e);
if ( msg )
msg = c->OptExpr(msg);
return ThisPtr();
}
else if ( IsReduced(c) )
return ThisPtr();
StmtPtr red_stmt;
e = e->ReduceToSingleton(c, red_stmt);
if ( msg )
msg = msg->ReduceToSingleton(c, msg_setup_stmt);
auto sl = with_location_of(make_intrusive<StmtList>(red_stmt, ThisPtr()), this);
return sl->Reduce(c);
}
bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
for ( auto& cp : *cl ) {