mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
EventHandler: Deprecate SetUsed() and Used() as well.
Seems the latter isn't used outside of the functions that were deprecated in the previous commit and with UsageAnalyzer not making use of this information unclear why we should keep it around. Relates to #3187.
This commit is contained in:
parent
398122206e
commit
ff34a4aa7f
5 changed files with 35 additions and 2 deletions
|
@ -41,8 +41,12 @@ public:
|
|||
// Returns true if there is at least one local or remote handler.
|
||||
explicit operator bool() const;
|
||||
|
||||
void SetUsed() { used = true; }
|
||||
bool Used() const { return used; }
|
||||
[[deprecated("Remove in v7.1 - Unused event handlers are now found via UsageAnalyzer.")]] void SetUsed() {
|
||||
used = true;
|
||||
}
|
||||
[[deprecated("Remove in v7.1 - Unused event handlers are now found via UsageAnalyzer.")]] bool Used() const {
|
||||
return used;
|
||||
}
|
||||
|
||||
// Handlers marked as error handlers will not be called recursively to
|
||||
// avoid infinite loops if they trigger a similar error themselves.
|
||||
|
|
|
@ -21,14 +21,22 @@ EventHandlerPtr EventRegistry::Register(std::string_view name, bool is_from_scri
|
|||
if ( ! is_from_script )
|
||||
not_only_from_script.insert(std::string(name));
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Remove in v7.1
|
||||
h->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
return h;
|
||||
}
|
||||
|
||||
h = new EventHandler(std::string(name));
|
||||
event_registry->Register(h, is_from_script);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Remove in v7.1
|
||||
h->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
return h;
|
||||
}
|
||||
|
@ -71,8 +79,11 @@ EventRegistry::string_list EventRegistry::UnusedHandlers() {
|
|||
|
||||
for ( const auto& entry : handlers ) {
|
||||
EventHandler* v = entry.second.get();
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
if ( v->GetFunc() && ! v->Used() )
|
||||
names.push_back(entry.first);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
return names;
|
||||
|
@ -83,8 +94,11 @@ EventRegistry::string_list EventRegistry::UsedHandlers() {
|
|||
|
||||
for ( const auto& entry : handlers ) {
|
||||
EventHandler* v = entry.second.get();
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
if ( v->GetFunc() && v->Used() )
|
||||
names.push_back(entry.first);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
return names;
|
||||
|
|
|
@ -402,7 +402,10 @@ NameExpr::NameExpr(IDPtr arg_id, bool const_init) : Expr(EXPR_NAME), id(std::mov
|
|||
|
||||
EventHandler* h = event_registry->Lookup(id->Name());
|
||||
if ( h )
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
h->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
// This isn't in-lined to avoid needing to pull in ID.h.
|
||||
|
@ -4265,7 +4268,10 @@ EventExpr::EventExpr(const char* arg_name, ListExprPtr arg_args)
|
|||
event_registry->Register(h, true);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
h->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
handler = h;
|
||||
|
||||
|
|
|
@ -133,7 +133,10 @@ void activate_bodies__CPP(const char* fn, const char* module, bool exported, Typ
|
|||
|
||||
for ( const auto& e : events ) {
|
||||
auto eh = event_registry->Register(e);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
eh->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +193,10 @@ FuncValPtr lookup_func__CPP(string name, int num_bodies, vector<p_hash_type> has
|
|||
// the semantics for Register explicitly allow it.
|
||||
for ( auto& e : f.events ) {
|
||||
auto eh = event_registry->Register(e);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
eh->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,7 +386,10 @@ static void use_CPP() {
|
|||
|
||||
for ( auto& e : s->second.events ) {
|
||||
auto h = event_registry->Register(e);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
h->SetUsed();
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
auto finish = s->second.finish_init_func;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue