mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Fixes from review, post-rebase
This commit is contained in:
parent
9f05fe5bfa
commit
5ca0bb79c8
15 changed files with 59 additions and 30 deletions
|
@ -520,7 +520,7 @@ static void analyze_scripts_for_ZAM(std::unique_ptr<ProfileFuncs>& pfs)
|
|||
finalize_functions(funcs);
|
||||
}
|
||||
|
||||
void analyze_scripts(bool no_usage_warnings)
|
||||
void analyze_scripts(bool no_unused_warnings)
|
||||
{
|
||||
static bool did_init = false;
|
||||
|
||||
|
@ -531,7 +531,7 @@ void analyze_scripts(bool no_usage_warnings)
|
|||
}
|
||||
|
||||
std::unique_ptr<UsageAnalyzer> ua;
|
||||
if ( ! no_usage_warnings )
|
||||
if ( ! no_unused_warnings )
|
||||
ua = std::make_unique<UsageAnalyzer>(funcs);
|
||||
|
||||
auto& ofuncs = analysis_options.only_funcs;
|
||||
|
|
|
@ -184,7 +184,7 @@ extern bool should_analyze(const ScriptFuncPtr& f, const StmtPtr& body);
|
|||
|
||||
// Analyze all of the parsed scripts collectively for usage issues (unless
|
||||
// suppressed by the flag) and optimization.
|
||||
extern void analyze_scripts(bool no_usage_warnings);
|
||||
extern void analyze_scripts(bool no_unused_warnings);
|
||||
|
||||
// Called when Zeek is terminating.
|
||||
extern void finish_script_execution();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "zeek/script_opt/UsageAnalyzer.h"
|
||||
|
||||
#include "zeek/EventRegistry.h"
|
||||
#include "zeek/module_util.h"
|
||||
#include "zeek/script_opt/IDOptInfo.h"
|
||||
|
||||
|
@ -19,6 +20,15 @@ void register_new_event(const IDPtr& id)
|
|||
|
||||
UsageAnalyzer::UsageAnalyzer(std::vector<FuncInfo>& funcs)
|
||||
{
|
||||
// First, prune the script events to only those that were never
|
||||
// registered in a non-script context.
|
||||
auto script_events_orig = script_events;
|
||||
script_events.clear();
|
||||
|
||||
for ( auto& ev : script_events_orig )
|
||||
if ( ! event_registry->NotOnlyRegisteredFromScript(ev) )
|
||||
script_events.insert(ev);
|
||||
|
||||
// Setting a scope cues ID::Traverse to delve into function values.
|
||||
current_scope = global_scope();
|
||||
|
||||
|
@ -52,8 +62,7 @@ UsageAnalyzer::UsageAnalyzer(std::vector<FuncInfo>& funcs)
|
|||
auto flavor = t->AsFuncType()->FlavorString();
|
||||
auto loc = id->GetLocationInfo();
|
||||
|
||||
reporter->Warning("%s %s (%s:%d): cannot be invoked", flavor.c_str(), id->Name(),
|
||||
loc->filename, loc->first_line);
|
||||
id->Warn(util::fmt("handler for non-existing %s cannot be invoked", flavor.c_str()));
|
||||
|
||||
// Don't ding any functions that are reachable via this
|
||||
// identifier. This will also suppress flagging other events
|
||||
|
@ -77,8 +86,7 @@ UsageAnalyzer::UsageAnalyzer(std::vector<FuncInfo>& funcs)
|
|||
|
||||
auto loc = id->GetLocationInfo();
|
||||
|
||||
reporter->Warning("function %s (%s:%d): cannot be called", id->Name(), loc->filename,
|
||||
loc->first_line);
|
||||
id->Warn("function does not have any callers");
|
||||
|
||||
// Unlike for events/hooks above, we don't add the function to
|
||||
// the reachables. This is because an orphan function is a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue