avoid compiling-to-C++ for functions potentially influenced by conditionals

This commit is contained in:
Vern Paxson 2021-11-24 15:19:21 -08:00
parent e73351a6e1
commit a4b9218771

View file

@ -1,5 +1,6 @@
// See the file "COPYING" in the main distribution directory for copyright.
#include "zeek/script_opt/StmtOptInfo.h"
#include "zeek/script_opt/CPP/Util.h"
#include <errno.h>
@ -50,6 +51,14 @@ bool is_CPP_compilable(const ProfileFunc* pf, const char** reason)
return false;
}
auto body = pf->ProfiledBody();
if ( body && ! body->GetOptInfo()->is_free_of_conditionals )
{
if ( reason )
*reason = "body may be affected by @if conditional";
return false;
}
return true;
}