mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
option handling for new -u/-uu flag for reporting usage issues
This commit is contained in:
parent
989cc6f607
commit
732633ebb4
4 changed files with 31 additions and 8 deletions
|
@ -12,6 +12,8 @@
|
|||
namespace zeek::detail {
|
||||
|
||||
|
||||
AnalyOpt analysis_options;
|
||||
|
||||
std::unordered_set<const Func*> non_recursive_funcs;
|
||||
|
||||
// Tracks all of the loaded functions (including event handlers and hooks).
|
||||
|
@ -104,10 +106,8 @@ static void check_env_opt(const char* opt, bool& opt_flag)
|
|||
opt_flag = true;
|
||||
}
|
||||
|
||||
void analyze_scripts(Options& opts)
|
||||
void analyze_scripts()
|
||||
{
|
||||
auto& analysis_options = opts.analysis_options;
|
||||
|
||||
static bool did_init = false;
|
||||
|
||||
if ( ! did_init )
|
||||
|
@ -116,6 +116,11 @@ void analyze_scripts(Options& opts)
|
|||
check_env_opt("ZEEK_INLINE", analysis_options.inliner);
|
||||
check_env_opt("ZEEK_XFORM", analysis_options.activate);
|
||||
|
||||
auto usage = getenv("ZEEK_USAGE_ISSUES");
|
||||
|
||||
if ( usage )
|
||||
analysis_options.usage_issues = atoi(usage) > 1 ? 2 : 1;
|
||||
|
||||
if ( ! analysis_options.only_func )
|
||||
{
|
||||
auto zo = getenv("ZEEK_ONLY");
|
||||
|
@ -123,7 +128,8 @@ void analyze_scripts(Options& opts)
|
|||
analysis_options.only_func = zo;
|
||||
}
|
||||
|
||||
if ( analysis_options.only_func )
|
||||
if ( analysis_options.only_func ||
|
||||
analysis_options.usage_issues > 0 )
|
||||
analysis_options.activate = true;
|
||||
|
||||
did_init = true;
|
||||
|
|
|
@ -36,8 +36,18 @@ struct AnalyOpt {
|
|||
// If true, report which functions are directly and indirectly
|
||||
// recursive, and exit. Only germane if running the inliner.
|
||||
bool report_recursive = false;
|
||||
|
||||
// If non-zero, looks for variables that are used-but-possibly-not-set,
|
||||
// or set-but-not-used.
|
||||
//
|
||||
// If > 1, also reports on uses of uninitialized record fields and
|
||||
// analyzes nested records in depth. Warning: with the current
|
||||
// data structures this greatly increases analysis time.
|
||||
int usage_issues = 0;
|
||||
};
|
||||
|
||||
extern AnalyOpt analysis_options;
|
||||
|
||||
|
||||
class ProfileFunc;
|
||||
|
||||
|
@ -81,7 +91,7 @@ extern std::unordered_set<const Func*> non_recursive_funcs;
|
|||
extern void analyze_func(ScriptFuncPtr f);
|
||||
|
||||
// Analyze all of the parsed scripts collectively for optimization.
|
||||
extern void analyze_scripts(Options& opts);
|
||||
extern void analyze_scripts();
|
||||
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue