mirror of
https://github.com/zeek/zeek.git
synced 2025-10-01 22:28:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/readability-container-contains'
* origin/topic/timw/readability-container-contains: Fix a few more random clang-tidy findings Use std::numbers::pi instead of hard-coded value Use std::scoped_lock instead of std::lock_guard Use .contains() instead of .find() or .count()
This commit is contained in:
commit
deeca84332
74 changed files with 225 additions and 220 deletions
|
@ -3,6 +3,7 @@ Checks: [-*,
|
||||||
performance-*,
|
performance-*,
|
||||||
modernize-*,
|
modernize-*,
|
||||||
readability-isolate-declaration,
|
readability-isolate-declaration,
|
||||||
|
readability-container-contains,
|
||||||
|
|
||||||
# Enable a very limited number of the cppcoreguidelines checkers.
|
# Enable a very limited number of the cppcoreguidelines checkers.
|
||||||
# See the notes for some of the rest of them below.
|
# See the notes for some of the rest of them below.
|
||||||
|
|
10
CHANGES
10
CHANGES
|
@ -1,3 +1,13 @@
|
||||||
|
8.1.0-dev.490 | 2025-09-02 11:47:44 -0700
|
||||||
|
|
||||||
|
* Fix a few more random clang-tidy findings (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Use std::numbers::pi instead of hard-coded value (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Use std::scoped_lock instead of std::lock_guard (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Use .contains() instead of .find() or .count() (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
8.1.0-dev.484 | 2025-08-29 21:53:19 -0700
|
8.1.0-dev.484 | 2025-08-29 21:53:19 -0700
|
||||||
|
|
||||||
* Bump zeek-testing-cluster to pull in WebSocket TLS updates (Christian Kreibich, Corelight)
|
* Bump zeek-testing-cluster to pull in WebSocket TLS updates (Christian Kreibich, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
8.1.0-dev.484
|
8.1.0-dev.490
|
||||||
|
|
|
@ -473,20 +473,20 @@ void DNS_Mgr::Done() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNS_Mgr::RegisterSocket(int fd, bool read, bool write) {
|
void DNS_Mgr::RegisterSocket(int fd, bool read, bool write) {
|
||||||
if ( read && socket_fds.count(fd) == 0 ) {
|
if ( read && ! socket_fds.contains(fd) ) {
|
||||||
socket_fds.insert(fd);
|
socket_fds.insert(fd);
|
||||||
iosource_mgr->RegisterFd(fd, this, IOSource::READ);
|
iosource_mgr->RegisterFd(fd, this, IOSource::READ);
|
||||||
}
|
}
|
||||||
else if ( ! read && socket_fds.count(fd) != 0 ) {
|
else if ( ! read && socket_fds.contains(fd) ) {
|
||||||
socket_fds.erase(fd);
|
socket_fds.erase(fd);
|
||||||
iosource_mgr->UnregisterFd(fd, this, IOSource::READ);
|
iosource_mgr->UnregisterFd(fd, this, IOSource::READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( write && write_socket_fds.count(fd) == 0 ) {
|
if ( write && ! write_socket_fds.contains(fd) ) {
|
||||||
write_socket_fds.insert(fd);
|
write_socket_fds.insert(fd);
|
||||||
iosource_mgr->RegisterFd(fd, this, IOSource::WRITE);
|
iosource_mgr->RegisterFd(fd, this, IOSource::WRITE);
|
||||||
}
|
}
|
||||||
else if ( ! write && write_socket_fds.count(fd) != 0 ) {
|
else if ( ! write && write_socket_fds.contains(fd) ) {
|
||||||
write_socket_fds.erase(fd);
|
write_socket_fds.erase(fd);
|
||||||
iosource_mgr->UnregisterFd(fd, this, IOSource::WRITE);
|
iosource_mgr->UnregisterFd(fd, this, IOSource::WRITE);
|
||||||
}
|
}
|
||||||
|
@ -1323,7 +1323,7 @@ double DNS_Mgr::GetNextTimeout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNS_Mgr::ProcessFd(int fd, int flags) {
|
void DNS_Mgr::ProcessFd(int fd, int flags) {
|
||||||
if ( socket_fds.count(fd) != 0 ) {
|
if ( socket_fds.contains(fd) ) {
|
||||||
int read_fd = (flags & IOSource::ProcessFlags::READ) != 0 ? fd : ARES_SOCKET_BAD;
|
int read_fd = (flags & IOSource::ProcessFlags::READ) != 0 ? fd : ARES_SOCKET_BAD;
|
||||||
int write_fd = (flags & IOSource::ProcessFlags::WRITE) != 0 ? fd : ARES_SOCKET_BAD;
|
int write_fd = (flags & IOSource::ProcessFlags::WRITE) != 0 ? fd : ARES_SOCKET_BAD;
|
||||||
ares_process_fd(channel, read_fd, write_fd);
|
ares_process_fd(channel, read_fd, write_fd);
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool DebugLogger::CheckStreams(const std::set<std::string>& plugin_names) {
|
||||||
if ( ! stream.starts_with("plugin-") )
|
if ( ! stream.starts_with("plugin-") )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( available_plugin_streams.count(stream) == 0 ) {
|
if ( ! available_plugin_streams.contains(stream) ) {
|
||||||
reporter->Error("No plugin debug stream '%s' found", stream.c_str());
|
reporter->Error("No plugin debug stream '%s' found", stream.c_str());
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ void DebugLogger::Log(DebugStream stream, const char* fmt, ...) {
|
||||||
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...) {
|
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...) {
|
||||||
if ( ! all ) {
|
if ( ! all ) {
|
||||||
std::string tok = PluginStreamName(plugin.Name());
|
std::string tok = PluginStreamName(plugin.Name());
|
||||||
if ( enabled_streams.find(tok) == enabled_streams.end() )
|
if ( ! enabled_streams.contains(tok) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ EventHandler* EventRegistry::Lookup(std::string_view name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventRegistry::NotOnlyRegisteredFromScript(std::string_view name) {
|
bool EventRegistry::NotOnlyRegisteredFromScript(std::string_view name) {
|
||||||
return not_only_from_script.count(std::string(name)) > 0;
|
return not_only_from_script.contains(std::string(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
EventRegistry::string_list EventRegistry::Match(RE_Matcher* pattern) {
|
EventRegistry::string_list EventRegistry::Match(RE_Matcher* pattern) {
|
||||||
|
@ -174,12 +174,12 @@ namespace {
|
||||||
class EventMetadataTypeRejector : public detail::TraversalCallback {
|
class EventMetadataTypeRejector : public detail::TraversalCallback {
|
||||||
public:
|
public:
|
||||||
detail::TraversalCode PreType(const Type* t) override {
|
detail::TraversalCode PreType(const Type* t) override {
|
||||||
if ( visited.count(t) > 0 )
|
if ( visited.contains(t) )
|
||||||
return detail::TC_ABORTSTMT;
|
return detail::TC_ABORTSTMT;
|
||||||
|
|
||||||
visited.insert(t);
|
visited.insert(t);
|
||||||
|
|
||||||
if ( reject.count(t->Tag()) )
|
if ( reject.contains(t->Tag()) )
|
||||||
rejected.push_back(t);
|
rejected.push_back(t);
|
||||||
|
|
||||||
return detail::TC_CONTINUE;
|
return detail::TC_CONTINUE;
|
||||||
|
|
|
@ -732,7 +732,7 @@ void ValTraceMgr::TraceEventValues(std::shared_ptr<EventTrace> et, const zeek::A
|
||||||
// remember them so we can catch uses of them in future events.
|
// remember them so we can catch uses of them in future events.
|
||||||
for ( auto i = num_vals; i < vals.size(); ++i ) {
|
for ( auto i = num_vals; i < vals.size(); ++i ) {
|
||||||
processed_vals.insert(vals[i].get());
|
processed_vals.insert(vals[i].get());
|
||||||
ASSERT(val_names.count(vals[i].get()) > 0);
|
ASSERT(val_names.contains(vals[i].get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,8 +794,8 @@ void ValTraceMgr::NewVal(ValPtr v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValTraceMgr::ValUsed(const ValPtr& v) {
|
void ValTraceMgr::ValUsed(const ValPtr& v) {
|
||||||
ASSERT(val_names.count(v.get()) > 0);
|
ASSERT(val_names.contains(v.get()));
|
||||||
if ( processed_vals.count(v.get()) > 0 )
|
if ( processed_vals.contains(v.get()) )
|
||||||
// We saw this value when processing a previous event.
|
// We saw this value when processing a previous event.
|
||||||
globals.insert(v.get());
|
globals.insert(v.get());
|
||||||
}
|
}
|
||||||
|
@ -818,17 +818,17 @@ void ValTraceMgr::AssessChange(const ValTrace* vt, const ValTrace* prev_vt) {
|
||||||
bool needs_lhs = d->NeedsLHS();
|
bool needs_lhs = d->NeedsLHS();
|
||||||
bool is_first_def = false;
|
bool is_first_def = false;
|
||||||
|
|
||||||
if ( needs_lhs && val_names.count(v) == 0 ) {
|
if ( needs_lhs && ! val_names.contains(v) ) {
|
||||||
TrackVar(v);
|
TrackVar(v);
|
||||||
is_first_def = true;
|
is_first_def = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(val_names.count(v) > 0);
|
ASSERT(val_names.contains(v));
|
||||||
|
|
||||||
// The "/" in the following is just to have a delimiter
|
// The "/" in the following is just to have a delimiter
|
||||||
// to make sure the string is unambiguous.
|
// to make sure the string is unambiguous.
|
||||||
auto full_delta = val_names[v] + "/" + rhs;
|
auto full_delta = val_names[v] + "/" + rhs;
|
||||||
if ( previous_deltas.count(full_delta) > 0 )
|
if ( previous_deltas.contains(full_delta) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
previous_deltas.insert(std::move(full_delta));
|
previous_deltas.insert(std::move(full_delta));
|
||||||
|
@ -849,7 +849,7 @@ void ValTraceMgr::TrackVar(const Val* v) {
|
||||||
|
|
||||||
std::string ValTraceMgr::GenValName(const ValPtr& v) {
|
std::string ValTraceMgr::GenValName(const ValPtr& v) {
|
||||||
if ( IsAggr(v->GetType()) && ! IsUnspecifiedAggregate(v) ) { // Aggregate shouldn't exist; create it
|
if ( IsAggr(v->GetType()) && ! IsUnspecifiedAggregate(v) ) { // Aggregate shouldn't exist; create it
|
||||||
ASSERT(val_map.count(v.get()) == 0);
|
ASSERT(! val_map.contains(v.get()));
|
||||||
NewVal(v);
|
NewVal(v);
|
||||||
return val_names[v.get()];
|
return val_names[v.get()];
|
||||||
}
|
}
|
||||||
|
@ -1012,7 +1012,7 @@ void EventTraceMgr::Generate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
if ( script_events.count(ev->GetName()) > 0 )
|
if ( script_events.contains(ev->GetName()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto nt = run_state::network_time;
|
auto nt = run_state::network_time;
|
||||||
|
@ -1029,7 +1029,7 @@ void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
if ( script_events.count(ev->GetName()) > 0 )
|
if ( script_events.contains(ev->GetName()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( run_state::network_time > 0.0 && ev->GetName() != "zeek_init" )
|
if ( run_state::network_time > 0.0 && ev->GetName() != "zeek_init" )
|
||||||
|
|
|
@ -354,7 +354,7 @@ public:
|
||||||
|
|
||||||
// Returns true if the script variable associated with the given value
|
// Returns true if the script variable associated with the given value
|
||||||
// needs to be global (because it's used across multiple events).
|
// needs to be global (because it's used across multiple events).
|
||||||
bool IsGlobal(const ValPtr& v) const { return globals.count(v.get()) > 0; }
|
bool IsGlobal(const ValPtr& v) const { return globals.contains(v.get()); }
|
||||||
|
|
||||||
// Returns or sets the "base time" from which eligible times are
|
// Returns or sets the "base time" from which eligible times are
|
||||||
// transformed into offsets rather than maintained as absolute
|
// transformed into offsets rather than maintained as absolute
|
||||||
|
|
|
@ -2999,7 +2999,7 @@ RecordConstructorExpr::RecordConstructorExpr(RecordTypePtr known_rt, ListExprPtr
|
||||||
|
|
||||||
auto n = known_rt->NumFields();
|
auto n = known_rt->NumFields();
|
||||||
for ( i = 0; i < n; ++i )
|
for ( i = 0; i < n; ++i )
|
||||||
if ( fields_seen.count(i) == 0 ) {
|
if ( ! fields_seen.contains(i) ) {
|
||||||
const auto td_i = known_rt->FieldDecl(i);
|
const auto td_i = known_rt->FieldDecl(i);
|
||||||
if ( IsAggr(td_i->type) )
|
if ( IsAggr(td_i->type) )
|
||||||
// These are always initialized.
|
// These are always initialized.
|
||||||
|
@ -4307,7 +4307,7 @@ bool LambdaExpr::CheckCaptures(StmtPtr when_parent) {
|
||||||
// already been an error message.
|
// already been an error message.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( capture_is_matched.count(cid) > 0 ) {
|
if ( capture_is_matched.contains(cid) ) {
|
||||||
auto msg = util::fmt("%s listed multiple times in capture", cid->Name());
|
auto msg = util::fmt("%s listed multiple times in capture", cid->Name());
|
||||||
if ( when_parent )
|
if ( when_parent )
|
||||||
when_parent->Error(msg);
|
when_parent->Error(msg);
|
||||||
|
@ -4326,7 +4326,7 @@ bool LambdaExpr::CheckCaptures(StmtPtr when_parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto id : outer_ids )
|
for ( auto id : outer_ids )
|
||||||
if ( outer_is_matched.count(id) == 0 ) {
|
if ( ! outer_is_matched.contains(id) ) {
|
||||||
auto msg = util::fmt("%s is used inside %s but not captured", id->Name(), desc);
|
auto msg = util::fmt("%s is used inside %s but not captured", id->Name(), desc);
|
||||||
if ( when_parent )
|
if ( when_parent )
|
||||||
when_parent->Error(msg);
|
when_parent->Error(msg);
|
||||||
|
@ -4338,7 +4338,7 @@ bool LambdaExpr::CheckCaptures(StmtPtr when_parent) {
|
||||||
|
|
||||||
for ( const auto& c : *captures ) {
|
for ( const auto& c : *captures ) {
|
||||||
auto cid = c.Id().get();
|
auto cid = c.Id().get();
|
||||||
if ( cid && capture_is_matched.count(cid) == 0 ) {
|
if ( cid && ! capture_is_matched.contains(cid) ) {
|
||||||
auto msg = util::fmt("%s is captured but not used inside %s", cid->Name(), desc);
|
auto msg = util::fmt("%s is captured but not used inside %s", cid->Name(), desc);
|
||||||
if ( when_parent )
|
if ( when_parent )
|
||||||
when_parent->Error(msg);
|
when_parent->Error(msg);
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool LoadPolicyFileText(const char* policy_filename, const std::optional<std::st
|
||||||
if ( ! policy_filename )
|
if ( ! policy_filename )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( policy_files.find(policy_filename) != policy_files.end() )
|
if ( policy_files.contains(policy_filename) )
|
||||||
debug_msg("Policy file %s already loaded\n", policy_filename);
|
debug_msg("Policy file %s already loaded\n", policy_filename);
|
||||||
|
|
||||||
PolicyFile* pf = new PolicyFile;
|
PolicyFile* pf = new PolicyFile;
|
||||||
|
|
|
@ -292,12 +292,8 @@ private:
|
||||||
__attribute__((format(printf, 4, 5)));
|
__attribute__((format(printf, 4, 5)));
|
||||||
;
|
;
|
||||||
void UpdateWeirdStats(const char* name);
|
void UpdateWeirdStats(const char* name);
|
||||||
inline bool WeirdOnSamplingWhiteList(const char* name) {
|
inline bool WeirdOnSamplingWhiteList(const char* name) { return weird_sampling_whitelist.contains(name); }
|
||||||
return weird_sampling_whitelist.find(name) != weird_sampling_whitelist.end();
|
inline bool WeirdOnGlobalList(const char* name) { return weird_sampling_global_list.contains(name); }
|
||||||
}
|
|
||||||
inline bool WeirdOnGlobalList(const char* name) {
|
|
||||||
return weird_sampling_global_list.find(name) != weird_sampling_global_list.end();
|
|
||||||
}
|
|
||||||
bool PermitNetWeird(const char* name);
|
bool PermitNetWeird(const char* name);
|
||||||
bool PermitFlowWeird(const char* name, const IPAddr& o, const IPAddr& r);
|
bool PermitFlowWeird(const char* name, const IPAddr& o, const IPAddr& r);
|
||||||
bool PermitExpiredConnWeird(const char* name, const RecordVal& conn_id);
|
bool PermitExpiredConnWeird(const char* name, const RecordVal& conn_id);
|
||||||
|
|
|
@ -334,7 +334,7 @@ bool RuleMatcher::ReadFiles(const std::vector<SignatureFile>& files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleMatcher::AddRule(Rule* rule) {
|
void RuleMatcher::AddRule(Rule* rule) {
|
||||||
if ( rules_by_id.find(rule->ID()) != rules_by_id.end() ) {
|
if ( rules_by_id.contains(rule->ID()) ) {
|
||||||
rules_error("rule defined twice");
|
rules_error("rule defined twice");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +602,7 @@ bool RuleMatcher::AllRulePatternsMatched(const Rule* r, MatchPos matchpos, const
|
||||||
|
|
||||||
// Check whether all patterns of the rule have matched.
|
// Check whether all patterns of the rule have matched.
|
||||||
for ( const auto& pattern : r->patterns ) {
|
for ( const auto& pattern : r->patterns ) {
|
||||||
if ( ams.find(pattern->id) == ams.end() )
|
if ( ! ams.contains(pattern->id) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// See if depth is satisfied.
|
// See if depth is satisfied.
|
||||||
|
|
|
@ -158,7 +158,7 @@ void ScriptCoverageManager::TrackUsage(const Location* loc, std::string desc, ui
|
||||||
|
|
||||||
pair<string, string> location_desc(location_info.Description(), desc);
|
pair<string, string> location_desc(location_info.Description(), desc);
|
||||||
|
|
||||||
if ( usage_map.find(location_desc) != usage_map.end() )
|
if ( usage_map.contains(location_desc) )
|
||||||
usage_map[location_desc] += cnt;
|
usage_map[location_desc] += cnt;
|
||||||
else
|
else
|
||||||
usage_map[location_desc] = cnt;
|
usage_map[location_desc] = cnt;
|
||||||
|
|
|
@ -122,10 +122,10 @@ ScriptProfileMgr::~ScriptProfileMgr() {
|
||||||
BiF_stats.AddIn(p);
|
BiF_stats.AddIn(p);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ASSERT(body_to_func.count(o) > 0);
|
ASSERT(body_to_func.contains(o));
|
||||||
auto func = body_to_func[o];
|
auto func = body_to_func[o];
|
||||||
|
|
||||||
if ( func_stats.count(func) == 0 )
|
if ( ! func_stats.contains(func) )
|
||||||
func_stats[func] = ScriptProfileStats(func->GetName());
|
func_stats[func] = ScriptProfileStats(func->GetName());
|
||||||
|
|
||||||
func_stats[func].AddIn(p);
|
func_stats[func].AddIn(p);
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode PreType(const Type* t) override {
|
TraversalCode PreType(const Type* t) override {
|
||||||
if ( types_seen.count(t) > 0 )
|
if ( types_seen.contains(t) )
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
|
|
||||||
types_seen.insert(t);
|
types_seen.insert(t);
|
||||||
|
|
19
src/Type.cc
19
src/Type.cc
|
@ -415,7 +415,7 @@ static bool is_supported_index_type(const TypePtr& t, const char** tname, std::u
|
||||||
|
|
||||||
// Handle recursive calls as good: If they turn out not
|
// Handle recursive calls as good: If they turn out not
|
||||||
// to be, that should've been discovered further down.
|
// to be, that should've been discovered further down.
|
||||||
if ( seen.count(t) > 0 )
|
if ( seen.contains(t) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
seen.insert(t);
|
seen.insert(t);
|
||||||
|
@ -1006,7 +1006,7 @@ class RecordType::CreationInitsOptimizer : public detail::TraversalCallback {
|
||||||
public:
|
public:
|
||||||
detail::TraversalCode PreTypedef(const detail::ID* id) override {
|
detail::TraversalCode PreTypedef(const detail::ID* id) override {
|
||||||
const auto& t = id->GetType();
|
const auto& t = id->GetType();
|
||||||
if ( analyzed_types.count(t) > 0 )
|
if ( analyzed_types.contains(t) )
|
||||||
return detail::TC_ABORTSTMT;
|
return detail::TC_ABORTSTMT;
|
||||||
|
|
||||||
analyzed_types.emplace(t);
|
analyzed_types.emplace(t);
|
||||||
|
@ -1102,7 +1102,7 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td) {
|
||||||
// We defer error-checking until here so that we can keep deferred_inits
|
// We defer error-checking until here so that we can keep deferred_inits
|
||||||
// and managed_fields correctly tracking the associated fields.
|
// and managed_fields correctly tracking the associated fields.
|
||||||
|
|
||||||
if ( field_ids.count(td->id) != 0 ) {
|
if ( field_ids.contains(td->id) ) {
|
||||||
reporter->Error("duplicate field '%s' found in record definition", td->id);
|
reporter->Error("duplicate field '%s' found in record definition", td->id);
|
||||||
deferred_inits.push_back(nullptr);
|
deferred_inits.push_back(nullptr);
|
||||||
return;
|
return;
|
||||||
|
@ -1168,7 +1168,7 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td) {
|
||||||
deferred_inits.push_back(std::move(init));
|
deferred_inits.push_back(std::move(init));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecordType::HasField(const char* field) const { return field_ids.count(field) != 0; }
|
bool RecordType::HasField(const char* field) const { return field_ids.contains(field); }
|
||||||
|
|
||||||
ValPtr RecordType::FieldDefault(int field) const {
|
ValPtr RecordType::FieldDefault(int field) const {
|
||||||
const TypeDecl* td = FieldDecl(field);
|
const TypeDecl* td = FieldDecl(field);
|
||||||
|
@ -1654,8 +1654,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, zeek
|
||||||
// we can define an enum both in a *.bif and *.zeek for avoiding
|
// we can define an enum both in a *.bif and *.zeek for avoiding
|
||||||
// cyclic dependencies.
|
// cyclic dependencies.
|
||||||
if ( ! id->IsEnumConst() || (id->HasVal() && val != id->GetVal()->AsEnum()) ||
|
if ( ! id->IsEnumConst() || (id->HasVal() && val != id->GetVal()->AsEnum()) ||
|
||||||
GetName() != id->GetType()->GetName() ||
|
GetName() != id->GetType()->GetName() || (names.contains(fullname) && names[fullname] != val) ) {
|
||||||
(names.find(fullname) != names.end() && names[fullname] != val) ) {
|
|
||||||
auto cl = detail::GetCurrentLocation();
|
auto cl = detail::GetCurrentLocation();
|
||||||
reporter->PushLocation(&cl, id->GetLocationInfo());
|
reporter->PushLocation(&cl, id->GetLocationInfo());
|
||||||
reporter->Error("conflicting definition of enum value '%s' in type '%s'", fullname.data(),
|
reporter->Error("conflicting definition of enum value '%s' in type '%s'", fullname.data(),
|
||||||
|
@ -1668,7 +1667,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, zeek
|
||||||
|
|
||||||
AddNameInternal(module_name, name, val, is_export);
|
AddNameInternal(module_name, name, val, is_export);
|
||||||
|
|
||||||
if ( vals.find(val) == vals.end() )
|
if ( ! vals.contains(val) )
|
||||||
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
||||||
|
|
||||||
if ( ! id->HasVal() )
|
if ( ! id->HasVal() )
|
||||||
|
@ -1694,7 +1693,7 @@ void EnumType::AddNameInternal(const string& full_name, zeek_int_t val) {
|
||||||
names[full_name] = val;
|
names[full_name] = val;
|
||||||
rev_names[val] = full_name;
|
rev_names[val] = full_name;
|
||||||
|
|
||||||
if ( vals.find(val) == vals.end() )
|
if ( ! vals.contains(val) )
|
||||||
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,11 +2030,11 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
||||||
// If we get to here, then we're dealing with a type with
|
// If we get to here, then we're dealing with a type with
|
||||||
// subtypes, and thus potentially recursive.
|
// subtypes, and thus potentially recursive.
|
||||||
|
|
||||||
if ( analyzed_types.count(t1) > 0 || analyzed_types.count(t2) > 0 ) {
|
if ( analyzed_types.contains(t1) || analyzed_types.contains(t2) ) {
|
||||||
// We've analyzed at least one of the types previously.
|
// We've analyzed at least one of the types previously.
|
||||||
// Avoid infinite recursion.
|
// Avoid infinite recursion.
|
||||||
|
|
||||||
if ( analyzed_types.count(t1) > 0 && analyzed_types.count(t2) > 0 )
|
if ( analyzed_types.contains(t1) && analyzed_types.contains(t2) )
|
||||||
// We've analyzed them both. In theory, this
|
// We've analyzed them both. In theory, this
|
||||||
// could happen while the types are still different.
|
// could happen while the types are still different.
|
||||||
// Checking for that is a pain - we could do so
|
// Checking for that is a pain - we could do so
|
||||||
|
|
|
@ -1532,7 +1532,7 @@ static void find_nested_record_types(const TypePtr& t, std::set<RecordType*>* fo
|
||||||
case TYPE_RECORD: {
|
case TYPE_RECORD: {
|
||||||
auto rt = t->AsRecordType();
|
auto rt = t->AsRecordType();
|
||||||
|
|
||||||
if ( analyzed_records->count(rt) > 0 )
|
if ( analyzed_records->contains(rt) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
analyzed_records->insert(rt);
|
analyzed_records->insert(rt);
|
||||||
|
@ -2882,7 +2882,7 @@ void TableVal::RebuildParseTimeTables() {
|
||||||
|
|
||||||
for ( auto& [tv, ptts] : parse_time_table_states ) {
|
for ( auto& [tv, ptts] : parse_time_table_states ) {
|
||||||
auto* tt = tv->table_type.get();
|
auto* tt = tv->table_type.get();
|
||||||
if ( table_types.count(tt) == 0 ) {
|
if ( ! table_types.contains(tt) ) {
|
||||||
tt->RegenerateHash();
|
tt->RegenerateHash();
|
||||||
table_types.insert(tt);
|
table_types.insert(tt);
|
||||||
}
|
}
|
||||||
|
@ -4041,7 +4041,7 @@ unsigned int Val::Footprint(std::unordered_set<const Val*>* analyzed_vals) const
|
||||||
// We only need to check containers for possible recursion, as there's
|
// We only need to check containers for possible recursion, as there's
|
||||||
// no way to construct a cycle using only non-aggregates.
|
// no way to construct a cycle using only non-aggregates.
|
||||||
if ( is_aggr ) {
|
if ( is_aggr ) {
|
||||||
if ( analyzed_vals->count(this) > 0 )
|
if ( analyzed_vals->contains(this) )
|
||||||
// Footprint is 1 for generating a cycle.
|
// Footprint is 1 for generating a cycle.
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ bool IRC_Analyzer::IsValidClientCommand(const std::string& command) {
|
||||||
"SETNAME", "SILENCE", "SQUERY", "SQUIT", "STATS", "SUMMON", "TIME", "TOPIC", "TRACE",
|
"SETNAME", "SILENCE", "SQUERY", "SQUIT", "STATS", "SUMMON", "TIME", "TOPIC", "TRACE",
|
||||||
"USER", "USERHOST", "USERS", "VERSION", "WALLOPS", "WHO", "WHOIS", "WHOWAS", "STARTTLS"};
|
"USER", "USERHOST", "USERS", "VERSION", "WALLOPS", "WHO", "WHOIS", "WHOWAS", "STARTTLS"};
|
||||||
|
|
||||||
return validCommands.find(command) != validCommands.end();
|
return validCommands.contains(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) {
|
void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ refine connection SMB_Conn += {
|
||||||
|
|
||||||
function get_is_file_a_pipe(id: uint16): bool
|
function get_is_file_a_pipe(id: uint16): bool
|
||||||
%{
|
%{
|
||||||
if ( is_file_a_pipe.count(id) > 0 )
|
if ( is_file_a_pipe.contains(id) )
|
||||||
{
|
{
|
||||||
bool is_pipe = is_file_a_pipe.at(id);
|
bool is_pipe = is_file_a_pipe.at(id);
|
||||||
is_file_a_pipe.erase(id);
|
is_file_a_pipe.erase(id);
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ bool SetIterator::DoUnserializeData(BrokerDataView data) {
|
||||||
// This is not perfect, as there's no guarantee that the restored
|
// This is not perfect, as there's no guarantee that the restored
|
||||||
// container will list the elements in the same order. But it's as
|
// container will list the elements in the same order. But it's as
|
||||||
// good as we can do, and it should generally work out.
|
// good as we can do, and it should generally work out.
|
||||||
if ( x->find((*v)[1]) == x->end() )
|
if ( ! x->contains((*v)[1]) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dat = *x;
|
dat = *x;
|
||||||
|
@ -1097,7 +1097,7 @@ bool TableIterator::DoUnserializeData(BrokerDataView data) {
|
||||||
// This is not perfect, as there's no guarantee that the restored
|
// This is not perfect, as there's no guarantee that the restored
|
||||||
// container will list the elements in the same order. But it's as
|
// container will list the elements in the same order. But it's as
|
||||||
// good as we can do, and it should generally work out.
|
// good as we can do, and it should generally work out.
|
||||||
if ( x->find((*v)[1]) == x->end() )
|
if ( ! x->contains((*v)[1]) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dat = *x;
|
dat = *x;
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
// arrivals (a push, is_push == true) and departures (a pull, is_push ==
|
// arrivals (a push, is_push == true) and departures (a pull, is_push ==
|
||||||
// false) as they happen. Note that this must not touch Zeek-side Vals.
|
// false) as they happen. Note that this must not touch Zeek-side Vals.
|
||||||
void Observe(const broker::endpoint_id& peer, bool is_push) {
|
void Observe(const broker::endpoint_id& peer, bool is_push) {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
auto it = stats_map.find(peer);
|
auto it = stats_map.find(peer);
|
||||||
|
|
||||||
if ( it == stats_map.end() ) {
|
if ( it == stats_map.end() ) {
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
|
|
||||||
// Updates the internal table[string] of BrokerPeeringStats and returns it.
|
// Updates the internal table[string] of BrokerPeeringStats and returns it.
|
||||||
const zeek::TableValPtr& GetPeeringStatsTable() {
|
const zeek::TableValPtr& GetPeeringStatsTable() {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
|
|
||||||
for ( auto it = stats_map.begin(); it != stats_map.end(); ) {
|
for ( auto it = stats_map.begin(); it != stats_map.end(); ) {
|
||||||
auto& peer = it->first;
|
auto& peer = it->first;
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemovePeer(const broker::endpoint_id& peer) {
|
void RemovePeer(const broker::endpoint_id& peer) {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
if ( auto it = stats_map.find(peer); it != stats_map.end() )
|
if ( auto it = stats_map.find(peer); it != stats_map.end() )
|
||||||
it->second.is_zombie = true;
|
it->second.is_zombie = true;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public:
|
||||||
std::list<broker::event_ptr> tmp;
|
std::list<broker::event_ptr> tmp;
|
||||||
tmp.emplace_back(std::move(event));
|
tmp.emplace_back(std::move(event));
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::scoped_lock<std::mutex> lock(mutex_);
|
||||||
queue_.splice(queue_.end(), tmp);
|
queue_.splice(queue_.end(), tmp);
|
||||||
if ( queue_.size() == 1 ) {
|
if ( queue_.size() == 1 ) {
|
||||||
flare_.Fire();
|
flare_.Fire();
|
||||||
|
@ -281,7 +281,7 @@ public:
|
||||||
|
|
||||||
auto Drain() {
|
auto Drain() {
|
||||||
std::list<broker::event_ptr> events;
|
std::list<broker::event_ptr> events;
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::scoped_lock<std::mutex> lock(mutex_);
|
||||||
if ( ! queue_.empty() ) {
|
if ( ! queue_.empty() ) {
|
||||||
queue_.swap(events);
|
queue_.swap(events);
|
||||||
flare_.Extinguish();
|
flare_.Extinguish();
|
||||||
|
@ -812,12 +812,10 @@ void Manager::Unpeer(const string& addr, uint16_t port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Manager::IsOutboundPeering(const string& addr, uint16_t port) const {
|
bool Manager::IsOutboundPeering(const string& addr, uint16_t port) const {
|
||||||
return bstate->outbound_peerings.find(broker::network_info(addr, port)) != bstate->outbound_peerings.end();
|
return bstate->outbound_peerings.contains(broker::network_info(addr, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Manager::IsOutboundPeering(const broker::network_info& ni) const {
|
bool Manager::IsOutboundPeering(const broker::network_info& ni) const { return bstate->outbound_peerings.contains(ni); }
|
||||||
return bstate->outbound_peerings.find(ni) != bstate->outbound_peerings.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<broker::peer_info> Manager::Peers() const {
|
std::vector<broker::peer_info> Manager::Peers() const {
|
||||||
if ( bstate->endpoint.is_shutdown() )
|
if ( bstate->endpoint.is_shutdown() )
|
||||||
|
@ -2110,7 +2108,7 @@ const Stats& Manager::GetStatistics() {
|
||||||
TableValPtr Manager::GetPeeringStatsTable() { return bstate->peerBufferState->GetPeeringStatsTable(); }
|
TableValPtr Manager::GetPeeringStatsTable() { return bstate->peerBufferState->GetPeeringStatsTable(); }
|
||||||
|
|
||||||
bool Manager::AddForwardedStore(const std::string& name, TableValPtr table) {
|
bool Manager::AddForwardedStore(const std::string& name, TableValPtr table) {
|
||||||
if ( forwarded_stores.find(name) != forwarded_stores.end() ) {
|
if ( forwarded_stores.contains(name) ) {
|
||||||
reporter->Error("same &broker_store %s specified for two different variables", name.c_str());
|
reporter->Error("same &broker_store %s specified for two different variables", name.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2127,7 +2125,7 @@ void Manager::PrepareForwarding(const std::string& name) {
|
||||||
if ( ! handle )
|
if ( ! handle )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( forwarded_stores.find(name) == forwarded_stores.end() )
|
if ( ! forwarded_stores.contains(name) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
handle->forward_to = forwarded_stores.at(name);
|
handle->forward_to = forwarded_stores.at(name);
|
||||||
|
|
|
@ -87,7 +87,7 @@ function Broker::__set_contains%(s: Broker::Data, key: any%): bool
|
||||||
return zeek::val_mgr->False();
|
return zeek::val_mgr->False();
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeek::val_mgr->Bool(v.find(*k) != v.end());
|
return zeek::val_mgr->Bool(v.contains(*k));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Broker::__set_insert%(s: Broker::Data, key: any%): bool
|
function Broker::__set_insert%(s: Broker::Data, key: any%): bool
|
||||||
|
@ -191,7 +191,7 @@ function Broker::__table_contains%(t: Broker::Data, key: any%): bool
|
||||||
return zeek::val_mgr->False();
|
return zeek::val_mgr->False();
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeek::val_mgr->Bool(v.find(*k) != v.end());
|
return zeek::val_mgr->Bool(v.contains(*k));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::Data
|
function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::Data
|
||||||
|
|
|
@ -46,7 +46,7 @@ std::unique_ptr<LogSerializer> Manager::InstantiateLogSerializer(const zeek::Enu
|
||||||
bool Manager::ListenWebSocket(const websocket::detail::ServerOptions& options) {
|
bool Manager::ListenWebSocket(const websocket::detail::ServerOptions& options) {
|
||||||
WebSocketServerKey key{options.host, options.port};
|
WebSocketServerKey key{options.host, options.port};
|
||||||
|
|
||||||
if ( websocket_servers.count(key) != 0 ) {
|
if ( websocket_servers.contains(key) ) {
|
||||||
const auto& entry = websocket_servers[key];
|
const auto& entry = websocket_servers[key];
|
||||||
if ( entry.options == options )
|
if ( entry.options == options )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -736,7 +736,7 @@ bool ZeroMQBackend::DoProcessBackendMessage(int tag, byte_buffer_span payload) {
|
||||||
if ( tag == 1 ) {
|
if ( tag == 1 ) {
|
||||||
// If this is the first time the subscription was observed, raise
|
// If this is the first time the subscription was observed, raise
|
||||||
// the ZeroMQ internal event.
|
// the ZeroMQ internal event.
|
||||||
if ( xpub_subscriptions.count(topic) == 0 ) {
|
if ( ! xpub_subscriptions.contains(topic) ) {
|
||||||
eh = event_subscription;
|
eh = event_subscription;
|
||||||
xpub_subscriptions.insert(topic);
|
xpub_subscriptions.insert(topic);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ void WebSocketClient::SetSubscriptions(const std::vector<std::string>& topic_pre
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketClient::SetSubscriptionActive(const std::string& topic_prefix) {
|
void WebSocketClient::SetSubscriptionActive(const std::string& topic_prefix) {
|
||||||
if ( subscriptions_state.count(topic_prefix) == 0 ) {
|
if ( ! subscriptions_state.contains(topic_prefix) ) {
|
||||||
zeek::reporter->InternalWarning("Unknown topic_prefix for WebSocket client %s!", topic_prefix.c_str());
|
zeek::reporter->InternalWarning("Unknown topic_prefix for WebSocket client %s!", topic_prefix.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ bool Manager::RemoveFile(const string& file_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Manager::IsIgnored(const string& file_id) { return ignored.find(file_id) != ignored.end(); }
|
bool Manager::IsIgnored(const string& file_id) { return ignored.contains(file_id); }
|
||||||
|
|
||||||
string Manager::GetFileID(const zeek::Tag& tag, Connection* c, bool is_orig) {
|
string Manager::GetFileID(const zeek::Tag& tag, Connection* c, bool is_orig) {
|
||||||
current_file_id.clear();
|
current_file_id.clear();
|
||||||
|
|
|
@ -246,7 +246,7 @@ RecordValPtr X509::ParseCertificate(X509Val* cert_val, file_analysis::File* f) {
|
||||||
|
|
||||||
X509_STORE* X509::GetRootStore(TableVal* root_certs) {
|
X509_STORE* X509::GetRootStore(TableVal* root_certs) {
|
||||||
// If this certificate store was built previously, just reuse the old one.
|
// If this certificate store was built previously, just reuse the old one.
|
||||||
if ( x509_stores.count(root_certs) > 0 )
|
if ( x509_stores.contains(root_certs) )
|
||||||
return x509_stores[root_certs];
|
return x509_stores[root_certs];
|
||||||
|
|
||||||
X509_STORE* ctx = X509_STORE_new();
|
X509_STORE* ctx = X509_STORE_new();
|
||||||
|
|
|
@ -247,13 +247,13 @@ bool Manager::RegisterFd(int fd, IOSource* src, int flags) {
|
||||||
std::vector<struct kevent> new_events;
|
std::vector<struct kevent> new_events;
|
||||||
|
|
||||||
if ( (flags & IOSource::READ) != 0 ) {
|
if ( (flags & IOSource::READ) != 0 ) {
|
||||||
if ( fd_map.count(fd) == 0 ) {
|
if ( ! fd_map.contains(fd) ) {
|
||||||
new_events.push_back({});
|
new_events.push_back({});
|
||||||
EV_SET(&(new_events.back()), fd, EVFILT_READ, EV_ADD, 0, 0, nullptr);
|
EV_SET(&(new_events.back()), fd, EVFILT_READ, EV_ADD, 0, 0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( (flags & IOSource::WRITE) != 0 ) {
|
if ( (flags & IOSource::WRITE) != 0 ) {
|
||||||
if ( write_fd_map.count(fd) == 0 ) {
|
if ( ! write_fd_map.contains(fd) ) {
|
||||||
new_events.push_back({});
|
new_events.push_back({});
|
||||||
EV_SET(&(new_events.back()), fd, EVFILT_WRITE, EV_ADD, 0, 0, nullptr);
|
EV_SET(&(new_events.back()), fd, EVFILT_WRITE, EV_ADD, 0, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -287,13 +287,13 @@ bool Manager::UnregisterFd(int fd, IOSource* src, int flags) {
|
||||||
std::vector<struct kevent> new_events;
|
std::vector<struct kevent> new_events;
|
||||||
|
|
||||||
if ( (flags & IOSource::READ) != 0 ) {
|
if ( (flags & IOSource::READ) != 0 ) {
|
||||||
if ( fd_map.count(fd) != 0 ) {
|
if ( fd_map.contains(fd) ) {
|
||||||
new_events.push_back({});
|
new_events.push_back({});
|
||||||
EV_SET(&(new_events.back()), fd, EVFILT_READ, EV_DELETE, 0, 0, nullptr);
|
EV_SET(&(new_events.back()), fd, EVFILT_READ, EV_DELETE, 0, 0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( (flags & IOSource::WRITE) != 0 ) {
|
if ( (flags & IOSource::WRITE) != 0 ) {
|
||||||
if ( write_fd_map.count(fd) != 0 ) {
|
if ( write_fd_map.contains(fd) ) {
|
||||||
new_events.push_back({});
|
new_events.push_back({});
|
||||||
EV_SET(&(new_events.back()), fd, EVFILT_WRITE, EV_DELETE, 0, 0, nullptr);
|
EV_SET(&(new_events.back()), fd, EVFILT_WRITE, EV_DELETE, 0, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1317,7 +1317,7 @@ bool Manager::DelayFinish(const EnumValPtr& id, const RecordValPtr& record, cons
|
||||||
// Delaying has completed.
|
// Delaying has completed.
|
||||||
bool Manager::DelayCompleted(Stream* stream, detail::DelayInfo& delay_info) {
|
bool Manager::DelayCompleted(Stream* stream, detail::DelayInfo& delay_info) {
|
||||||
auto token = detail::to_internal_delay_token(delay_info.TokenVal());
|
auto token = detail::to_internal_delay_token(delay_info.TokenVal());
|
||||||
assert(stream->delay_tokens.find(token) != stream->delay_tokens.end());
|
assert(stream->delay_tokens.contains(token));
|
||||||
|
|
||||||
DBG_LOG(DBG_LOGGING, "DelayCompleted() for log record %p RefCnt=%d token=%" PRIu64, delay_info.Record().get(),
|
DBG_LOG(DBG_LOGGING, "DelayCompleted() for log record %p RefCnt=%d token=%" PRIu64, delay_info.Record().get(),
|
||||||
delay_info.Record()->RefCnt(), token);
|
delay_info.Record()->RefCnt(), token);
|
||||||
|
|
|
@ -155,7 +155,7 @@ bool IPBasedAnalyzer::IsLikelyServerPort(uint32_t port) const {
|
||||||
// We exploit our knowledge of PortVal's internal storage mechanism here.
|
// We exploit our knowledge of PortVal's internal storage mechanism here.
|
||||||
port |= server_port_mask;
|
port |= server_port_mask;
|
||||||
|
|
||||||
return port_cache.find(port) != port_cache.end();
|
return port_cache.contains(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::Connection* IPBasedAnalyzer::NewConn(IPBasedConnKeyPtr key, const Packet* pkt) {
|
zeek::Connection* IPBasedAnalyzer::NewConn(IPBasedConnKeyPtr key, const Packet* pkt) {
|
||||||
|
|
|
@ -173,14 +173,14 @@ public:
|
||||||
*
|
*
|
||||||
* @param tag The component tag to check.
|
* @param tag The component tag to check.
|
||||||
*/
|
*/
|
||||||
auto HasComponentMapping(const zeek::Tag& tag) const { return component_mapping_by_src.count(tag); }
|
bool HasComponentMapping(const zeek::Tag& tag) const { return component_mapping_by_src.contains(tag); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a given component is mapped to from a different one.
|
* Returns true if a given component is mapped to from a different one.
|
||||||
*
|
*
|
||||||
* @param tag The component tag to check.
|
* @param tag The component tag to check.
|
||||||
*/
|
*/
|
||||||
bool ProvidesComponentMapping(const zeek::Tag& tag) const { return component_mapping_by_dst.count(tag); }
|
bool ProvidesComponentMapping(const zeek::Tag& tag) const { return component_mapping_by_dst.contains(tag); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Script layer module in which component tags live. */
|
/** Script layer module in which component tags live. */
|
||||||
|
|
|
@ -81,7 +81,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir) {
|
||||||
|
|
||||||
std::string canon_path = canon.string();
|
std::string canon_path = canon.string();
|
||||||
|
|
||||||
if ( searched_dirs.count(canon_path) )
|
if ( searched_dirs.contains(canon_path) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
searched_dirs.emplace(canon_path);
|
searched_dirs.emplace(canon_path);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public:
|
||||||
|
|
||||||
// Returns true if at least one of the function bodies associated with
|
// Returns true if at least one of the function bodies associated with
|
||||||
// the function/hook/event handler of the given fname is not compilable.
|
// the function/hook/event handler of the given fname is not compilable.
|
||||||
bool NotFullyCompilable(const std::string& fname) const { return not_fully_compilable.count(fname) > 0; }
|
bool NotFullyCompilable(const std::string& fname) const { return not_fully_compilable.contains(fname); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#include "zeek/script_opt/CPP/Attrs.h"
|
#include "zeek/script_opt/CPP/Attrs.h"
|
||||||
|
|
|
@ -31,7 +31,7 @@ void CPPCompile::DeclareLambda(const LambdaExpr* l, const ProfileFunc* pf) {
|
||||||
auto& ids = l->OuterIDs();
|
auto& ids = l->OuterIDs();
|
||||||
|
|
||||||
for ( auto lid : ids ) {
|
for ( auto lid : ids ) {
|
||||||
if ( lambda_names.count(lid) > 0 ) {
|
if ( lambda_names.contains(lid) ) {
|
||||||
ASSERT(lambda_names[lid] == CaptureName(lid));
|
ASSERT(lambda_names[lid] == CaptureName(lid));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -74,7 +74,7 @@ void CPPCompile::CreateFunction(const FuncTypePtr& ft, const ProfileFunc* pf, co
|
||||||
|
|
||||||
func_index[fname] = cast;
|
func_index[fname] = cast;
|
||||||
|
|
||||||
if ( ! l && casting_index.count(cast) == 0 ) {
|
if ( ! l && ! casting_index.contains(cast) ) {
|
||||||
casting_index[cast] = func_casting_glue.size();
|
casting_index[cast] = func_casting_glue.size();
|
||||||
|
|
||||||
DispatchInfo di;
|
DispatchInfo di;
|
||||||
|
@ -314,7 +314,7 @@ void CPPCompile::GatherParamTypes(vector<string>& p_types, const FuncTypePtr& ft
|
||||||
// Native types are always pass-by-value.
|
// Native types are always pass-by-value.
|
||||||
p_types.emplace_back(tn);
|
p_types.emplace_back(tn);
|
||||||
else {
|
else {
|
||||||
if ( param_id && pf->Assignees().count(param_id) > 0 )
|
if ( param_id && pf->Assignees().contains(param_id) )
|
||||||
// We modify the parameter.
|
// We modify the parameter.
|
||||||
p_types.emplace_back(tn);
|
p_types.emplace_back(tn);
|
||||||
else
|
else
|
||||||
|
|
|
@ -138,7 +138,7 @@ void CPPCompile::Compile(bool report_uncompilable) {
|
||||||
for ( const auto& l : accessed_lambdas ) {
|
for ( const auto& l : accessed_lambdas ) {
|
||||||
const auto& n = l->Name();
|
const auto& n = l->Name();
|
||||||
const auto body = l->Ingredients()->Body().get();
|
const auto body = l->Ingredients()->Body().get();
|
||||||
if ( lambda_ASTs.count(n) > 0 )
|
if ( lambda_ASTs.contains(n) )
|
||||||
// Reuse previous body.
|
// Reuse previous body.
|
||||||
body_names[body] = body_names[lambda_ASTs[n]];
|
body_names[body] = body_names[lambda_ASTs[n]];
|
||||||
else {
|
else {
|
||||||
|
@ -157,7 +157,7 @@ void CPPCompile::Compile(bool report_uncompilable) {
|
||||||
lambda_ASTs.clear();
|
lambda_ASTs.clear();
|
||||||
for ( const auto& l : accessed_lambdas ) {
|
for ( const auto& l : accessed_lambdas ) {
|
||||||
const auto& n = l->Name();
|
const auto& n = l->Name();
|
||||||
if ( lambda_ASTs.count(n) > 0 )
|
if ( lambda_ASTs.contains(n) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CompileLambda(l, pfs->ExprProf(l).get());
|
CompileLambda(l, pfs->ExprProf(l).get());
|
||||||
|
@ -196,12 +196,12 @@ bool CPPCompile::AnalyzeFuncBody(FuncInfo& fi, unordered_set<string>& filenames_
|
||||||
string fn = body->GetLocationInfo()->FileName();
|
string fn = body->GetLocationInfo()->FileName();
|
||||||
|
|
||||||
if ( ! analysis_options.allow_cond && ! fi.ShouldSkip() ) {
|
if ( ! analysis_options.allow_cond && ! fi.ShouldSkip() ) {
|
||||||
if ( ! analysis_options.only_files.empty() && files_with_conditionals.count(fn) > 0 ) {
|
if ( ! analysis_options.only_files.empty() && files_with_conditionals.contains(fn) ) {
|
||||||
if ( report_uncompilable )
|
if ( report_uncompilable )
|
||||||
reporter->Warning("%s cannot be compiled to C++ due to source file %s having conditional code",
|
reporter->Warning("%s cannot be compiled to C++ due to source file %s having conditional code",
|
||||||
f->GetName().c_str(), fn.c_str());
|
f->GetName().c_str(), fn.c_str());
|
||||||
|
|
||||||
else if ( filenames_reported_as_skipped.count(fn) == 0 ) {
|
else if ( ! filenames_reported_as_skipped.contains(fn) ) {
|
||||||
reporter->Warning("skipping compilation of files in %s due to presence of conditional code",
|
reporter->Warning("skipping compilation of files in %s due to presence of conditional code",
|
||||||
fn.c_str());
|
fn.c_str());
|
||||||
filenames_reported_as_skipped.emplace(fn);
|
filenames_reported_as_skipped.emplace(fn);
|
||||||
|
|
|
@ -148,11 +148,11 @@ string CPPCompile::GenExpr(const Expr* e, GenType gt, bool top_level) {
|
||||||
string CPPCompile::GenNameExpr(const NameExpr* ne, GenType gt) {
|
string CPPCompile::GenNameExpr(const NameExpr* ne, GenType gt) {
|
||||||
const auto& t = ne->GetType();
|
const auto& t = ne->GetType();
|
||||||
auto n = ne->Id();
|
auto n = ne->Id();
|
||||||
bool is_global_var = global_vars.count(n) > 0;
|
bool is_global_var = global_vars.contains(n);
|
||||||
|
|
||||||
if ( t->Tag() == TYPE_FUNC && ! is_global_var ) {
|
if ( t->Tag() == TYPE_FUNC && ! is_global_var ) {
|
||||||
auto func = n->Name();
|
auto func = n->Name();
|
||||||
if ( globals.count(func) > 0 && pfs->BiFGlobals().count(n) == 0 )
|
if ( globals.contains(func) && ! pfs->BiFGlobals().contains(n) )
|
||||||
return GenericValPtrToGT(IDNameStr(n), t, gt);
|
return GenericValPtrToGT(IDNameStr(n), t, gt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +277,8 @@ string CPPCompile::GenCallExpr(const CallExpr* c, GenType gt, bool top_level) {
|
||||||
auto id_name = f_id->Name();
|
auto id_name = f_id->Name();
|
||||||
auto nargs = args_l->Exprs().length();
|
auto nargs = args_l->Exprs().length();
|
||||||
|
|
||||||
bool is_compiled = compiled_simple_funcs.count(id_name) > 0;
|
bool is_compiled = compiled_simple_funcs.contains(id_name);
|
||||||
bool was_compiled = hashed_funcs.count(id_name) > 0;
|
bool was_compiled = hashed_funcs.contains(id_name);
|
||||||
bool is_variadic = params->NumFields() == 1 && nargs != 1;
|
bool is_variadic = params->NumFields() == 1 && nargs != 1;
|
||||||
|
|
||||||
if ( ! is_async && ! is_variadic && (is_compiled || was_compiled) ) { // Can call directly.
|
if ( ! is_async && ! is_variadic && (is_compiled || was_compiled) ) { // Can call directly.
|
||||||
|
@ -303,10 +303,10 @@ string CPPCompile::GenCallExpr(const CallExpr* c, GenType gt, bool top_level) {
|
||||||
//
|
//
|
||||||
// If it is a BiF *that's also a global variable*, then
|
// If it is a BiF *that's also a global variable*, then
|
||||||
// we need to look up the BiF version of the global.
|
// we need to look up the BiF version of the global.
|
||||||
if ( pfs->BiFGlobals().count(f_id) == 0 )
|
if ( ! pfs->BiFGlobals().contains(f_id) )
|
||||||
gen += +"->AsFunc()";
|
gen += +"->AsFunc()";
|
||||||
|
|
||||||
else if ( accessed_globals.count(f_id) > 0 )
|
else if ( accessed_globals.contains(f_id) )
|
||||||
// The BiF version has an extra "_", per AddBiF(..., true).
|
// The BiF version has an extra "_", per AddBiF(..., true).
|
||||||
gen = globals[string(id_name) + "_"];
|
gen = globals[string(id_name) + "_"];
|
||||||
}
|
}
|
||||||
|
@ -1230,7 +1230,7 @@ string CPPCompile::GenField(const ExprPtr& rec, int field) {
|
||||||
int mapping_slot;
|
int mapping_slot;
|
||||||
|
|
||||||
auto rfm = record_field_mappings.find(rt);
|
auto rfm = record_field_mappings.find(rt);
|
||||||
if ( rfm != record_field_mappings.end() && rfm->second.count(field) > 0 )
|
if ( rfm != record_field_mappings.end() && rfm->second.contains(field) )
|
||||||
// We're already tracking this field.
|
// We're already tracking this field.
|
||||||
mapping_slot = rfm->second[field];
|
mapping_slot = rfm->second[field];
|
||||||
|
|
||||||
|
@ -1269,7 +1269,7 @@ string CPPCompile::GenEnum(const TypePtr& t, const ValPtr& ev) {
|
||||||
int mapping_slot;
|
int mapping_slot;
|
||||||
|
|
||||||
auto evm = enum_val_mappings.find(et);
|
auto evm = enum_val_mappings.find(et);
|
||||||
if ( evm != enum_val_mappings.end() && evm->second.count(v) > 0 )
|
if ( evm != enum_val_mappings.end() && evm->second.contains(v) )
|
||||||
// We're already tracking this value.
|
// We're already tracking this value.
|
||||||
mapping_slot = evm->second[v];
|
mapping_slot = evm->second[v];
|
||||||
|
|
||||||
|
|
|
@ -159,11 +159,11 @@ void CPPCompile::DeclareLocals(const ProfileFunc* pf, const IDPList* lambda_ids)
|
||||||
auto ln = LocalName(l);
|
auto ln = LocalName(l);
|
||||||
auto cn = CaptureName(l);
|
auto cn = CaptureName(l);
|
||||||
|
|
||||||
if ( capture_names.count(cn) > 0 )
|
if ( capture_names.contains(cn) )
|
||||||
// No need to declare these, they're passed in as parameters.
|
// No need to declare these, they're passed in as parameters.
|
||||||
ln = cn;
|
ln = cn;
|
||||||
|
|
||||||
else if ( params.count(l) == 0 && l->Offset() >= num_params ) { // Not a parameter, so must be a local.
|
else if ( ! params.contains(l) && l->Offset() >= num_params ) { // Not a parameter, so must be a local.
|
||||||
Emit("%s %s;", FullTypeName(l->GetType()), ln);
|
Emit("%s %s;", FullTypeName(l->GetType()), ln);
|
||||||
did_decl = true;
|
did_decl = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ void CPPCompile::InitializeGlobals() {
|
||||||
if ( ! ofiles.empty() && ! obj_matches_opt_files(g) )
|
if ( ! ofiles.empty() && ! obj_matches_opt_files(g) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( accessed_globals.count(g) == 0 )
|
if ( ! accessed_globals.contains(g) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto ic = ginit.IC();
|
auto ic = ginit.IC();
|
||||||
|
@ -281,7 +281,7 @@ void CPPCompile::GenStandaloneActivation() {
|
||||||
auto fname = BodyName(func);
|
auto fname = BodyName(func);
|
||||||
auto bname = Canonicalize(fname) + "_zf";
|
auto bname = Canonicalize(fname) + "_zf";
|
||||||
|
|
||||||
if ( compiled_funcs.count(bname) == 0 )
|
if ( ! compiled_funcs.contains(bname) )
|
||||||
// We didn't wind up compiling it.
|
// We didn't wind up compiling it.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ void register_lambda__CPP(CPPStmtPtr body, p_hash_type hash, const char* name, T
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_scripts__CPP(p_hash_type h, void (*callback)()) {
|
void register_scripts__CPP(p_hash_type h, void (*callback)()) {
|
||||||
ASSERT(standalone_callbacks.count(h) == 0);
|
ASSERT(! standalone_callbacks.contains(h));
|
||||||
standalone_callbacks[h] = callback;
|
standalone_callbacks[h] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ void CPPCompile::GenInitStmt(const InitStmt* init) {
|
||||||
auto type_type = TypeType(t);
|
auto type_type = TypeType(t);
|
||||||
auto type_ind = GenTypeName(t);
|
auto type_ind = GenTypeName(t);
|
||||||
|
|
||||||
if ( locals.count(aggr.get()) == 0 ) {
|
if ( ! locals.contains(aggr.get()) ) {
|
||||||
// fprintf(stderr, "aggregate %s unused\n", obj_desc(aggr.get()).c_str());
|
// fprintf(stderr, "aggregate %s unused\n", obj_desc(aggr.get()).c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ void CPPTracker<T>::AddKey(IntrusivePtr<T> key, p_hash_type h) {
|
||||||
if ( HasKey(key) )
|
if ( HasKey(key) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( map2.count(h) == 0 ) {
|
if ( ! map2.contains(h) ) {
|
||||||
auto index = keys.size();
|
auto index = keys.size();
|
||||||
keys.push_back(key);
|
keys.push_back(key);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ string CPPCompile::GenericValPtrToGT(const string& expr, const TypePtr& t, GenTy
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::GenTypeName(const Type* t) {
|
string CPPCompile::GenTypeName(const Type* t) {
|
||||||
ASSERT(processed_types.count(TypeRep(t)) > 0);
|
ASSERT(processed_types.contains(TypeRep(t)));
|
||||||
return types.KeyName(TypeRep(t));
|
return types.KeyName(TypeRep(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ using namespace std;
|
||||||
|
|
||||||
void CPPCompile::CreateGlobal(const ID* g) {
|
void CPPCompile::CreateGlobal(const ID* g) {
|
||||||
auto gn = string(g->Name());
|
auto gn = string(g->Name());
|
||||||
bool is_bif = pfs->BiFGlobals().count(g) > 0;
|
bool is_bif = pfs->BiFGlobals().contains(g);
|
||||||
|
|
||||||
if ( accessed_globals.count(g) == 0 ) {
|
if ( ! accessed_globals.contains(g) ) {
|
||||||
// Only used in the context of calls. If it's compilable,
|
// Only used in the context of calls. If it's compilable,
|
||||||
// then we'll call it directly.
|
// then we'll call it directly.
|
||||||
if ( compilable_funcs.count(gn) > 0 ) {
|
if ( compilable_funcs.contains(gn) ) {
|
||||||
AddGlobal(gn, "zf");
|
AddGlobal(gn, "zf");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ void CPPCompile::CreateGlobal(const ID* g) {
|
||||||
if ( AddGlobal(gn, "gl") ) { // We'll be creating this global.
|
if ( AddGlobal(gn, "gl") ) { // We'll be creating this global.
|
||||||
Emit("IDPtr %s;", globals[gn]);
|
Emit("IDPtr %s;", globals[gn]);
|
||||||
|
|
||||||
if ( accessed_events.count(gn) > 0 )
|
if ( accessed_events.contains(gn) )
|
||||||
// This is an event that's also used as a variable.
|
// This is an event that's also used as a variable.
|
||||||
Emit("EventHandlerPtr %s_ev;", globals[gn]);
|
Emit("EventHandlerPtr %s_ev;", globals[gn]);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ std::shared_ptr<CPP_InitInfo> CPPCompile::RegisterGlobal(const ID* g) {
|
||||||
|
|
||||||
auto gn = string(g->Name());
|
auto gn = string(g->Name());
|
||||||
|
|
||||||
if ( globals.count(gn) == 0 ) {
|
if ( ! globals.contains(gn) ) {
|
||||||
// Create a name for it.
|
// Create a name for it.
|
||||||
(void)IDNameStr(g);
|
(void)IDNameStr(g);
|
||||||
|
|
||||||
|
@ -103,12 +103,12 @@ void CPPCompile::AddBiF(const ID* b, bool is_var) {
|
||||||
if ( AddGlobal(n, "bif") )
|
if ( AddGlobal(n, "bif") )
|
||||||
Emit("Func* %s;", globals[n]);
|
Emit("Func* %s;", globals[n]);
|
||||||
|
|
||||||
ASSERT(BiFs.count(globals[n]) == 0);
|
ASSERT(! BiFs.contains(globals[n]));
|
||||||
BiFs[globals[n]] = bn;
|
BiFs[globals[n]] = bn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPPCompile::AddGlobal(const string& g, const char* suffix) {
|
bool CPPCompile::AddGlobal(const string& g, const char* suffix) {
|
||||||
if ( globals.count(g) > 0 )
|
if ( globals.contains(g) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
globals.emplace(g, GlobalName(g, suffix));
|
globals.emplace(g, GlobalName(g, suffix));
|
||||||
|
@ -120,7 +120,7 @@ void CPPCompile::RegisterEvent(string ev_name) { body_events[body_name].emplace_
|
||||||
const string& CPPCompile::IDNameStr(const ID* id) {
|
const string& CPPCompile::IDNameStr(const ID* id) {
|
||||||
if ( id->IsGlobal() ) {
|
if ( id->IsGlobal() ) {
|
||||||
auto g = string(id->Name());
|
auto g = string(id->Name());
|
||||||
if ( globals.count(g) == 0 )
|
if ( ! globals.contains(g) )
|
||||||
CreateGlobal(id);
|
CreateGlobal(id);
|
||||||
return globals[g];
|
return globals[g];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
TraversalCode PostExpr(const Expr*) override;
|
TraversalCode PostExpr(const Expr*) override;
|
||||||
|
|
||||||
TraversalCode PreType(const Type* t) override {
|
TraversalCode PreType(const Type* t) override {
|
||||||
if ( types_seen.count(t) > 0 )
|
if ( types_seen.contains(t) )
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
types_seen.insert(t);
|
types_seen.insert(t);
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ bool CmpExpr::IsHasElementsTest() const {
|
||||||
static std::set<ExprTag> rel_tags = {EXPR_EQ, EXPR_NE, EXPR_LT, EXPR_LE, EXPR_GE, EXPR_GT};
|
static std::set<ExprTag> rel_tags = {EXPR_EQ, EXPR_NE, EXPR_LT, EXPR_LE, EXPR_GE, EXPR_GT};
|
||||||
|
|
||||||
auto t = Tag(); // note, we may invert t below
|
auto t = Tag(); // note, we may invert t below
|
||||||
if ( rel_tags.count(t) == 0 )
|
if ( ! rel_tags.contains(t) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto op1 = GetOp1();
|
auto op1 = GetOp1();
|
||||||
|
@ -2396,7 +2396,7 @@ bool LambdaExpr::IsReduced(Reducer* c) const {
|
||||||
for ( auto& cp : *captures ) {
|
for ( auto& cp : *captures ) {
|
||||||
auto& cid = cp.Id();
|
auto& cid = cp.Id();
|
||||||
|
|
||||||
if ( private_captures.count(cid.get()) == 0 && ! c->ID_IsReduced(cid) )
|
if ( ! private_captures.contains(cid.get()) && ! c->ID_IsReduced(cid) )
|
||||||
return NonReduced(this);
|
return NonReduced(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2424,7 +2424,7 @@ void LambdaExpr::UpdateCaptures(Reducer* c) {
|
||||||
for ( auto& cp : *captures ) {
|
for ( auto& cp : *captures ) {
|
||||||
auto& cid = cp.Id();
|
auto& cid = cp.Id();
|
||||||
|
|
||||||
if ( private_captures.count(cid.get()) == 0 )
|
if ( ! private_captures.contains(cid.get()) )
|
||||||
cp.SetID(c->UpdateID(cid));
|
cp.SetID(c->UpdateID(cid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2955,7 +2955,7 @@ RecordFieldUpdatesExpr::RecordFieldUpdatesExpr(ExprTag t, const std::vector<cons
|
||||||
|
|
||||||
// Consistency check that the statement is indeed in the pool,
|
// Consistency check that the statement is indeed in the pool,
|
||||||
// before we remove it.
|
// before we remove it.
|
||||||
ASSERT(stmt_pool.count(s) > 0);
|
ASSERT(stmt_pool.contains(s));
|
||||||
stmt_pool.erase(s);
|
stmt_pool.erase(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ void IDOptInfo::BranchBeyond(const Stmt* end_s, const Stmt* block, bool close_al
|
||||||
printf("ID %s branching forward from %d beyond %d: %s\n", trace_ID, end_s->GetOptInfo()->stmt_num,
|
printf("ID %s branching forward from %d beyond %d: %s\n", trace_ID, end_s->GetOptInfo()->stmt_num,
|
||||||
block->GetOptInfo()->stmt_num, obj_desc(end_s).c_str());
|
block->GetOptInfo()->stmt_num, obj_desc(end_s).c_str());
|
||||||
|
|
||||||
ASSERT(pending_confluences.count(block) > 0);
|
ASSERT(pending_confluences.contains(block));
|
||||||
|
|
||||||
auto ar = ActiveRegionIndex();
|
auto ar = ActiveRegionIndex();
|
||||||
if ( ar != NO_DEF )
|
if ( ar != NO_DEF )
|
||||||
|
@ -332,12 +332,12 @@ void IDOptInfo::ConfluenceBlockEndsAfter(const Stmt* s, bool no_orig_flow) {
|
||||||
if ( ur.EndsAfter() == NO_DEF ) { // End this region.
|
if ( ur.EndsAfter() == NO_DEF ) { // End this region.
|
||||||
ur.SetEndsAfter(stmt_num);
|
ur.SetEndsAfter(stmt_num);
|
||||||
|
|
||||||
if ( ur.StartsAfter() <= cs_stmt_num && no_orig_flow && pc.count(i) == 0 )
|
if ( ur.StartsAfter() <= cs_stmt_num && no_orig_flow && ! pc.contains(i) )
|
||||||
// Don't include this region in our assessment.
|
// Don't include this region in our assessment.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( ur.EndsAfter() < cs_stmt_num || pc.count(i) == 0 )
|
else if ( ur.EndsAfter() < cs_stmt_num || ! pc.contains(i) )
|
||||||
// Irrelevant, didn't extend into confluence region.
|
// Irrelevant, didn't extend into confluence region.
|
||||||
// We test here just to avoid the set lookup in
|
// We test here just to avoid the set lookup in
|
||||||
// the next test, which presumably will sometimes
|
// the next test, which presumably will sometimes
|
||||||
|
|
|
@ -116,7 +116,7 @@ void Inliner::Analyze() {
|
||||||
for ( auto& ccc : call_set[cc] ) {
|
for ( auto& ccc : call_set[cc] ) {
|
||||||
// For each of those, if we don't
|
// For each of those, if we don't
|
||||||
// already have it, add it.
|
// already have it, add it.
|
||||||
if ( c.second.count(ccc) > 0 )
|
if ( c.second.contains(ccc) )
|
||||||
// We already have it.
|
// We already have it.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void Inliner::Analyze() {
|
||||||
if ( func->Flavor() != FUNC_FLAVOR_FUNCTION )
|
if ( func->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( non_recursive_funcs.count(func) == 0 )
|
if ( ! non_recursive_funcs.contains(func) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( ! is_ZAM_compilable(f.Profile()) )
|
if ( ! is_ZAM_compilable(f.Profile()) )
|
||||||
|
@ -202,7 +202,7 @@ void Inliner::CoalesceEventHandlers() {
|
||||||
|
|
||||||
if ( func->GetKind() == Func::SCRIPT_FUNC && func->GetBodies().size() > 1 ) {
|
if ( func->GetKind() == Func::SCRIPT_FUNC && func->GetBodies().size() > 1 ) {
|
||||||
++event_handlers[func];
|
++event_handlers[func];
|
||||||
ASSERT(body_to_info.count(body.get()) == 0);
|
ASSERT(! body_to_info.contains(body.get()));
|
||||||
body_to_info[body.get()] = i;
|
body_to_info[body.get()] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ ExprPtr Inliner::DoInline(ScriptFuncPtr sf, StmtPtr body, ListExprPtr args, Scop
|
||||||
for ( int i = 0; i < nparam; ++i ) {
|
for ( int i = 0; i < nparam; ++i ) {
|
||||||
auto& vi = vars[i];
|
auto& vi = vars[i];
|
||||||
params.emplace_back(vi);
|
params.emplace_back(vi);
|
||||||
param_is_modified.emplace_back((pf->Assignees().count(vi.get()) > 0));
|
param_is_modified.emplace_back((pf->Assignees().contains(vi.get())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively inline the body. This is safe to do because we've
|
// Recursively inline the body. This is safe to do because we've
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
ExprPtr CheckForInlining(CallExprPtr c);
|
ExprPtr CheckForInlining(CallExprPtr c);
|
||||||
|
|
||||||
// True if every instance of the function was inlined.
|
// True if every instance of the function was inlined.
|
||||||
bool WasFullyInlined(const Func* f) { return did_inline.count(f) > 0 && skipped_inlining.count(f) == 0; }
|
bool WasFullyInlined(const Func* f) { return did_inline.contains(f) && ! skipped_inlining.contains(f); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Driver routine that analyzes all of the script functions and
|
// Driver routine that analyzes all of the script functions and
|
||||||
|
|
|
@ -41,7 +41,7 @@ private:
|
||||||
class ObjMgr {
|
class ObjMgr {
|
||||||
public:
|
public:
|
||||||
void AddObj(const Obj* o) {
|
void AddObj(const Obj* o) {
|
||||||
if ( obj_collection.count(o) == 0 )
|
if ( ! obj_collection.contains(o) )
|
||||||
obj_collection.emplace(std::pair<const Obj*, ObjWrapper>{o, ObjWrapper(o)});
|
obj_collection.emplace(std::pair<const Obj*, ObjWrapper>{o, ObjWrapper(o)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ ProfileFunc::ProfileFunc(const Func* func, const StmtPtr& body, bool _abs_rec_fi
|
||||||
num_params = profiled_func_t->Params()->NumFields();
|
num_params = profiled_func_t->Params()->NumFields();
|
||||||
|
|
||||||
for ( auto l : locals ) {
|
for ( auto l : locals ) {
|
||||||
if ( captures.count(l) == 0 && l->Offset() < num_params )
|
if ( ! captures.contains(l) && l->Offset() < num_params )
|
||||||
params.insert(l);
|
params.insert(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ TraversalCode ProfileFunc::PreExpr(const Expr* e) {
|
||||||
// types if needed.
|
// types if needed.
|
||||||
auto res_type = e->GetType().get();
|
auto res_type = e->GetType().get();
|
||||||
auto orig_type = e->GetOp1()->GetType().get();
|
auto orig_type = e->GetOp1()->GetType().get();
|
||||||
if ( type_aliases.count(res_type) == 0 )
|
if ( ! type_aliases.contains(res_type) )
|
||||||
type_aliases[orig_type] = {res_type};
|
type_aliases[orig_type] = {res_type};
|
||||||
else
|
else
|
||||||
type_aliases[orig_type].insert(res_type);
|
type_aliases[orig_type].insert(res_type);
|
||||||
|
@ -541,12 +541,12 @@ void ProfileFunc::TrackID(const ID* id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileFunc::TrackAssignment(const ID* id) {
|
void ProfileFunc::TrackAssignment(const ID* id) {
|
||||||
if ( assignees.count(id) > 0 )
|
if ( assignees.contains(id) )
|
||||||
++assignees[id];
|
++assignees[id];
|
||||||
else
|
else
|
||||||
assignees[id] = 1;
|
assignees[id] = 1;
|
||||||
|
|
||||||
if ( id->IsGlobal() || captures.count(id) > 0 )
|
if ( id->IsGlobal() || captures.contains(id) )
|
||||||
non_local_assignees.insert(id);
|
non_local_assignees.insert(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ void ProfileFunc::CheckRecordConstructor(TypePtr t) {
|
||||||
auto attrs = td->attrs.get();
|
auto attrs = td->attrs.get();
|
||||||
constructor_attrs[attrs] = rt;
|
constructor_attrs[attrs] = rt;
|
||||||
|
|
||||||
if ( rec_constructor_attrs.count(rt.get()) == 0 )
|
if ( ! rec_constructor_attrs.contains(rt.get()) )
|
||||||
rec_constructor_attrs[rt.get()] = {attrs};
|
rec_constructor_attrs[rt.get()] = {attrs};
|
||||||
else
|
else
|
||||||
rec_constructor_attrs[rt.get()].insert(attrs);
|
rec_constructor_attrs[rt.get()].insert(attrs);
|
||||||
|
@ -735,7 +735,7 @@ void ProfileFuncs::MergeInProfile(ProfileFunc* pf) {
|
||||||
AnalyzeAttrs(a.first, a.second.get());
|
AnalyzeAttrs(a.first, a.second.get());
|
||||||
|
|
||||||
for ( auto& ta : pf->TypeAliases() ) {
|
for ( auto& ta : pf->TypeAliases() ) {
|
||||||
if ( type_aliases.count(ta.first) == 0 )
|
if ( ! type_aliases.contains(ta.first) )
|
||||||
type_aliases[ta.first] = std::set<const Type*>{};
|
type_aliases[ta.first] = std::set<const Type*>{};
|
||||||
type_aliases[ta.first].insert(ta.second.begin(), ta.second.end());
|
type_aliases[ta.first].insert(ta.second.begin(), ta.second.end());
|
||||||
}
|
}
|
||||||
|
@ -1294,7 +1294,7 @@ bool ProfileFuncs::AssessSideEffects(const ExprPtr& e, IDSet& non_local_ids, Typ
|
||||||
// in an attribute context indicates an implicit call.
|
// in an attribute context indicates an implicit call.
|
||||||
return GetCallSideEffects(e->AsNameExpr(), non_local_ids, aggrs, is_unknown);
|
return GetCallSideEffects(e->AsNameExpr(), non_local_ids, aggrs, is_unknown);
|
||||||
|
|
||||||
ASSERT(expr_profs.count(e.get()) != 0);
|
ASSERT(expr_profs.contains(e.get()));
|
||||||
auto pf = expr_profs[e.get()];
|
auto pf = expr_profs[e.get()];
|
||||||
return AssessSideEffects(pf.get(), non_local_ids, aggrs, is_unknown);
|
return AssessSideEffects(pf.get(), non_local_ids, aggrs, is_unknown);
|
||||||
}
|
}
|
||||||
|
@ -1342,7 +1342,7 @@ bool ProfileFuncs::AssessSideEffects(const ProfileFunc* pf, IDSet& non_local_ids
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pff = func_profs[f];
|
auto pff = func_profs[f];
|
||||||
if ( active_func_profiles.count(pff) > 0 )
|
if ( active_func_profiles.contains(pff) )
|
||||||
// We're already processing this function and arrived here via
|
// We're already processing this function and arrived here via
|
||||||
// recursion. Skip further analysis here, we'll do it instead
|
// recursion. Skip further analysis here, we'll do it instead
|
||||||
// for the original instance.
|
// for the original instance.
|
||||||
|
@ -1415,7 +1415,7 @@ bool ProfileFuncs::AssessSideEffects(const SideEffectsOp* se, SideEffectsOp::Acc
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SideEffectsOp> ProfileFuncs::GetCallSideEffects(const ScriptFunc* sf) {
|
std::shared_ptr<SideEffectsOp> ProfileFuncs::GetCallSideEffects(const ScriptFunc* sf) {
|
||||||
if ( lambda_primaries.count(sf->GetName()) > 0 )
|
if ( lambda_primaries.contains(sf->GetName()) )
|
||||||
sf = lambda_primaries[sf->GetName()];
|
sf = lambda_primaries[sf->GetName()];
|
||||||
|
|
||||||
auto sf_se = func_side_effects.find(sf);
|
auto sf_se = func_side_effects.find(sf);
|
||||||
|
@ -1427,7 +1427,7 @@ std::shared_ptr<SideEffectsOp> ProfileFuncs::GetCallSideEffects(const ScriptFunc
|
||||||
IDSet nla;
|
IDSet nla;
|
||||||
TypeSet mod_aggrs;
|
TypeSet mod_aggrs;
|
||||||
|
|
||||||
ASSERT(func_profs.count(sf) != 0);
|
ASSERT(func_profs.contains(sf));
|
||||||
auto pf = func_profs[sf];
|
auto pf = func_profs[sf];
|
||||||
if ( ! AssessSideEffects(pf.get(), nla, mod_aggrs, is_unknown) )
|
if ( ! AssessSideEffects(pf.get(), nla, mod_aggrs, is_unknown) )
|
||||||
// Can't figure it out yet.
|
// Can't figure it out yet.
|
||||||
|
@ -1450,7 +1450,7 @@ static std::unordered_map<std::string, std::string> filename_module;
|
||||||
|
|
||||||
void switch_to_module(const char* module_name) {
|
void switch_to_module(const char* module_name) {
|
||||||
auto loc = GetCurrentLocation();
|
auto loc = GetCurrentLocation();
|
||||||
if ( loc.FirstLine() != 0 && filename_module.count(loc.FileName()) == 0 )
|
if ( loc.FirstLine() != 0 && ! filename_module.contains(loc.FileName()) )
|
||||||
filename_module[loc.FileName()] = module_name;
|
filename_module[loc.FileName()] = module_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,7 +1542,7 @@ ASTBlockAnalyzer::ASTBlockAnalyzer(std::vector<FuncInfo>& funcs) {
|
||||||
|
|
||||||
static bool is_compound_stmt(const Stmt* s) {
|
static bool is_compound_stmt(const Stmt* s) {
|
||||||
static std::set<StmtTag> compound_stmts = {STMT_FOR, STMT_IF, STMT_LIST, STMT_SWITCH, STMT_WHEN, STMT_WHILE};
|
static std::set<StmtTag> compound_stmts = {STMT_FOR, STMT_IF, STMT_LIST, STMT_SWITCH, STMT_WHEN, STMT_WHILE};
|
||||||
return compound_stmts.count(s->Tag()) > 0;
|
return compound_stmts.contains(s->Tag());
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode ASTBlockAnalyzer::PreStmt(const Stmt* s) {
|
TraversalCode ASTBlockAnalyzer::PreStmt(const Stmt* s) {
|
||||||
|
@ -1580,7 +1580,7 @@ std::string ASTBlockAnalyzer::BuildExpandedDescription(const Location* loc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lk = LocKey(loc);
|
auto lk = LocKey(loc);
|
||||||
if ( exp_desc.count(lk) == 0 )
|
if ( ! exp_desc.contains(lk) )
|
||||||
exp_desc[lk] = ls;
|
exp_desc[lk] = ls;
|
||||||
|
|
||||||
return ls;
|
return ls;
|
||||||
|
|
|
@ -674,7 +674,7 @@ public:
|
||||||
// should always be true other than for certain functions with empty
|
// should always be true other than for certain functions with empty
|
||||||
// bodies that are created post-parsing. Available for debugging so
|
// bodies that are created post-parsing. Available for debugging so
|
||||||
// we can assert we have these.
|
// we can assert we have these.
|
||||||
bool HaveExpDesc(const Location* loc) const { return exp_desc.count(LocKey(loc)) > 0; }
|
bool HaveExpDesc(const Location* loc) const { return exp_desc.contains(LocKey(loc)); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Construct the full expanded description associated with the given
|
// Construct the full expanded description associated with the given
|
||||||
|
|
|
@ -327,7 +327,7 @@ bool Reducer::ID_IsReducedOrTopLevel(const ID* id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reducer::ID_IsReduced(const ID* id) const {
|
bool Reducer::ID_IsReduced(const ID* id) const {
|
||||||
return inline_block_level == 0 || tracked_ids.count(id) > 0 || id->IsGlobal() || IsTemporary(id);
|
return inline_block_level == 0 || tracked_ids.contains(id) || id->IsGlobal() || IsTemporary(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
StmtPtr Reducer::GenParam(const IDPtr& id, ExprPtr rhs, bool is_modified) {
|
StmtPtr Reducer::GenParam(const IDPtr& id, ExprPtr rhs, bool is_modified) {
|
||||||
|
@ -335,7 +335,7 @@ StmtPtr Reducer::GenParam(const IDPtr& id, ExprPtr rhs, bool is_modified) {
|
||||||
param->SetLocationInfo(rhs->GetLocationInfo());
|
param->SetLocationInfo(rhs->GetLocationInfo());
|
||||||
auto rhs_id = rhs->Tag() == EXPR_NAME ? rhs->AsNameExpr()->IdPtr() : nullptr;
|
auto rhs_id = rhs->Tag() == EXPR_NAME ? rhs->AsNameExpr()->IdPtr() : nullptr;
|
||||||
|
|
||||||
if ( rhs_id && pf->Locals().count(rhs_id.get()) == 0 && ! rhs_id->IsConst() )
|
if ( rhs_id && ! pf->Locals().contains(rhs_id.get()) && ! rhs_id->IsConst() )
|
||||||
// It's hard to guarantee the RHS won't change during
|
// It's hard to guarantee the RHS won't change during
|
||||||
// the inline block's execution.
|
// the inline block's execution.
|
||||||
is_modified = true;
|
is_modified = true;
|
||||||
|
@ -838,14 +838,14 @@ IDPtr Reducer::GenLocal(const IDPtr& orig) {
|
||||||
local_id->GetOptInfo()->SetTemp();
|
local_id->GetOptInfo()->SetTemp();
|
||||||
|
|
||||||
IDPtr prev;
|
IDPtr prev;
|
||||||
if ( orig_to_new_locals.count(orig.get()) )
|
if ( orig_to_new_locals.contains(orig.get()) )
|
||||||
prev = orig_to_new_locals[orig.get()];
|
prev = orig_to_new_locals[orig.get()];
|
||||||
|
|
||||||
AddNewLocal(local_id);
|
AddNewLocal(local_id);
|
||||||
om.AddObj(orig.get());
|
om.AddObj(orig.get());
|
||||||
orig_to_new_locals[orig.get()] = local_id;
|
orig_to_new_locals[orig.get()] = local_id;
|
||||||
|
|
||||||
if ( ! block_locals.empty() && ret_vars.count(orig.get()) == 0 )
|
if ( ! block_locals.empty() && ! ret_vars.contains(orig.get()) )
|
||||||
block_locals.back()[orig.get()] = prev;
|
block_locals.back()[orig.get()] = prev;
|
||||||
|
|
||||||
return local_id;
|
return local_id;
|
||||||
|
@ -853,7 +853,7 @@ IDPtr Reducer::GenLocal(const IDPtr& orig) {
|
||||||
|
|
||||||
bool Reducer::IsNewLocal(const ID* id) const {
|
bool Reducer::IsNewLocal(const ID* id) const {
|
||||||
ID* non_const_ID = (ID*)id; // I don't get why C++ requires this
|
ID* non_const_ID = (ID*)id; // I don't get why C++ requires this
|
||||||
return new_locals.count(non_const_ID) != 0;
|
return new_locals.contains(non_const_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TempVar> Reducer::FindTemporary(const ID* id) const {
|
std::shared_ptr<TempVar> Reducer::FindTemporary(const ID* id) const {
|
||||||
|
|
|
@ -83,9 +83,9 @@ public:
|
||||||
bool IsNewLocal(const ID* id) const;
|
bool IsNewLocal(const ID* id) const;
|
||||||
|
|
||||||
bool IsTemporary(const ID* id) const { return FindTemporary(id) != nullptr; }
|
bool IsTemporary(const ID* id) const { return FindTemporary(id) != nullptr; }
|
||||||
bool IsParamTemp(const ID* id) const { return param_temps.count(id) > 0; }
|
bool IsParamTemp(const ID* id) const { return param_temps.contains(id); }
|
||||||
|
|
||||||
bool IsConstantVar(const ID* id) const { return constant_vars.find(id) != constant_vars.end(); }
|
bool IsConstantVar(const ID* id) const { return constant_vars.contains(id); }
|
||||||
|
|
||||||
// True if the Reducer is being used in the context of a second
|
// True if the Reducer is being used in the context of a second
|
||||||
// pass over for AST optimization.
|
// pass over for AST optimization.
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
|
|
||||||
// A predicate that returns true if the given statement should
|
// A predicate that returns true if the given statement should
|
||||||
// be removed due to AST optimization.
|
// be removed due to AST optimization.
|
||||||
bool ShouldOmitStmt(const Stmt* s) const { return omitted_stmts.find(s) != omitted_stmts.end(); }
|
bool ShouldOmitStmt(const Stmt* s) const { return omitted_stmts.contains(s); }
|
||||||
|
|
||||||
// Provides a replacement for the given statement due to
|
// Provides a replacement for the given statement due to
|
||||||
// AST optimization, or nil if there's no replacement.
|
// AST optimization, or nil if there's no replacement.
|
||||||
|
|
|
@ -52,9 +52,9 @@ void analyze_lambda(LambdaExpr* l) {
|
||||||
|
|
||||||
void analyze_when_lambda(LambdaExpr* l) { when_lambdas.insert(l->PrimaryFunc().get()); }
|
void analyze_when_lambda(LambdaExpr* l) { when_lambdas.insert(l->PrimaryFunc().get()); }
|
||||||
|
|
||||||
bool is_lambda(const ScriptFunc* f) { return lambdas.count(f) > 0; }
|
bool is_lambda(const ScriptFunc* f) { return lambdas.contains(f); }
|
||||||
|
|
||||||
bool is_when_lambda(const ScriptFunc* f) { return when_lambdas.count(f) > 0; }
|
bool is_when_lambda(const ScriptFunc* f) { return when_lambdas.contains(f); }
|
||||||
|
|
||||||
void analyze_global_stmts(Stmt* stmts) {
|
void analyze_global_stmts(Stmt* stmts) {
|
||||||
if ( analysis_options.gen_standalone_CPP && obj_matches_opt_files(stmts) )
|
if ( analysis_options.gen_standalone_CPP && obj_matches_opt_files(stmts) )
|
||||||
|
@ -396,7 +396,7 @@ static void report_CPP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hash = f.Profile()->HashVal();
|
auto hash = f.Profile()->HashVal();
|
||||||
bool have = compiled_scripts.count(hash) > 0;
|
bool have = compiled_scripts.contains(hash);
|
||||||
|
|
||||||
printf("script function %s (hash %llu): %s\n", name.c_str(), hash, have ? "yes" : "no");
|
printf("script function %s (hash %llu): %s\n", name.c_str(), hash, have ? "yes" : "no");
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ static void report_CPP() {
|
||||||
|
|
||||||
int addl = 0;
|
int addl = 0;
|
||||||
for ( const auto& s : compiled_scripts )
|
for ( const auto& s : compiled_scripts )
|
||||||
if ( already_reported.count(s.first) == 0 ) {
|
if ( ! already_reported.contains(s.first) ) {
|
||||||
printf("%s body (hash %llu)\n", s.second.body->Name().c_str(), s.first);
|
printf("%s body (hash %llu)\n", s.second.body->Name().c_str(), s.first);
|
||||||
++addl;
|
++addl;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ static void use_CPP() {
|
||||||
// we're using code compiled for standalone.
|
// we're using code compiled for standalone.
|
||||||
if ( f.Body()->Tag() != STMT_CPP ) {
|
if ( f.Body()->Tag() != STMT_CPP ) {
|
||||||
auto func = f.Func();
|
auto func = f.Func();
|
||||||
if ( added_bodies[func->GetName()].count(hash) > 0 )
|
if ( added_bodies[func->GetName()].contains(hash) )
|
||||||
// We've already added the
|
// We've already added the
|
||||||
// replacement. Delete orig.
|
// replacement. Delete orig.
|
||||||
func->ReplaceBody(f.Body(), nullptr);
|
func->ReplaceBody(f.Body(), nullptr);
|
||||||
|
@ -535,7 +535,7 @@ static void analyze_scripts_for_ZAM(std::shared_ptr<ProfileFuncs> pfs) {
|
||||||
bool is_lambda = l != lambdas.end();
|
bool is_lambda = l != lambdas.end();
|
||||||
|
|
||||||
if ( ! analysis_options.compile_all && ! is_lambda && inl && inl->WasFullyInlined(func.get()) &&
|
if ( ! analysis_options.compile_all && ! is_lambda && inl && inl->WasFullyInlined(func.get()) &&
|
||||||
func_used_indirectly.count(func.get()) == 0 ) {
|
! func_used_indirectly.contains(func.get()) ) {
|
||||||
// No need to compile as it won't be called directly. We'd
|
// No need to compile as it won't be called directly. We'd
|
||||||
// like to zero out the body to recover the memory, but a *few*
|
// like to zero out the body to recover the memory, but a *few*
|
||||||
// such functions do get called, such as by the event engine
|
// such functions do get called, such as by the event engine
|
||||||
|
@ -732,7 +732,7 @@ bool has_AST_node_unknown_to_script_opt(const ProfileFunc* prof, bool /* is_ZAM
|
||||||
static_assert(NUM_STMTS == SCRIPT_OPT_NUM_STMTS);
|
static_assert(NUM_STMTS == SCRIPT_OPT_NUM_STMTS);
|
||||||
|
|
||||||
for ( auto& s : prof->Stmts() )
|
for ( auto& s : prof->Stmts() )
|
||||||
if ( known_stmts.count(s->Tag()) == 0 )
|
if ( ! known_stmts.contains(s->Tag()) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -821,7 +821,7 @@ bool has_AST_node_unknown_to_script_opt(const ProfileFunc* prof, bool /* is_ZAM
|
||||||
static_assert(NUM_EXPRS == SCRIPT_OPT_NUM_EXPRS);
|
static_assert(NUM_EXPRS == SCRIPT_OPT_NUM_EXPRS);
|
||||||
|
|
||||||
for ( auto& e : prof->Exprs() )
|
for ( auto& e : prof->Exprs() )
|
||||||
if ( known_exprs.count(e->Tag()) == 0 )
|
if ( ! known_exprs.contains(e->Tag()) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -771,7 +771,7 @@ static unsigned int find_rec_assignment_chain(const std::vector<StmtPtr>& stmts,
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
auto lhs_field = lhs->AsFieldExpr()->Field();
|
auto lhs_field = lhs->AsFieldExpr()->Field();
|
||||||
if ( fields_seen.count(lhs_field) > 0 )
|
if ( fields_seen.contains(lhs_field) )
|
||||||
// Earlier in this chain we've already seen "x$a", so end the
|
// Earlier in this chain we've already seen "x$a", so end the
|
||||||
// chain at this repeated use because it's no longer a simple
|
// chain at this repeated use because it's no longer a simple
|
||||||
// block of field assignments.
|
// block of field assignments.
|
||||||
|
@ -925,7 +925,7 @@ static bool simplify_chain(const std::vector<StmtPtr>& stmts, unsigned int start
|
||||||
|
|
||||||
// At this point, chain_stmts has only the remainders that weren't removed.
|
// At this point, chain_stmts has only the remainders that weren't removed.
|
||||||
for ( auto s : stmts )
|
for ( auto s : stmts )
|
||||||
if ( chain_stmts.count(s.get()) > 0 )
|
if ( chain_stmts.contains(s.get()) )
|
||||||
f_stmts.push_back(std::move(s));
|
f_stmts.push_back(std::move(s));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1106,7 +1106,7 @@ bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
|
||||||
for ( auto& cp : *cl ) {
|
for ( auto& cp : *cl ) {
|
||||||
const auto& cid = cp.Id();
|
const auto& cid = cp.Id();
|
||||||
|
|
||||||
if ( when_new_locals.count(cid.get()) == 0 && ! c->ID_IsReduced(cp.Id()) )
|
if ( ! when_new_locals.contains(cid.get()) && ! c->ID_IsReduced(cp.Id()) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,7 +1120,7 @@ bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
|
||||||
void WhenInfo::UpdateIDs(Reducer* c) {
|
void WhenInfo::UpdateIDs(Reducer* c) {
|
||||||
for ( auto& cp : *cl ) {
|
for ( auto& cp : *cl ) {
|
||||||
auto& cid = cp.Id();
|
auto& cid = cp.Id();
|
||||||
if ( when_new_locals.count(cid.get()) == 0 )
|
if ( ! when_new_locals.contains(cid.get()) )
|
||||||
cp.SetID(c->UpdateID(cid));
|
cp.SetID(c->UpdateID(cid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ UsageAnalyzer::UsageAnalyzer(std::vector<FuncInfo>& funcs) {
|
||||||
if ( t->AsFuncType()->Flavor() == FUNC_FLAVOR_FUNCTION )
|
if ( t->AsFuncType()->Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( reachables.count(id) > 0 )
|
if ( reachables.contains(id) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto flavor = t->AsFuncType()->FlavorString();
|
auto flavor = t->AsFuncType()->FlavorString();
|
||||||
|
@ -69,7 +69,7 @@ UsageAnalyzer::UsageAnalyzer(std::vector<FuncInfo>& funcs) {
|
||||||
for ( auto& gpair : globals ) {
|
for ( auto& gpair : globals ) {
|
||||||
auto& id = gpair.second;
|
auto& id = gpair.second;
|
||||||
|
|
||||||
if ( reachables.count(id.get()) > 0 )
|
if ( reachables.contains(id.get()) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto f = GetFuncIfAny(id);
|
auto f = GetFuncIfAny(id);
|
||||||
|
@ -109,7 +109,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode PreType(const Type* t) override {
|
TraversalCode PreType(const Type* t) override {
|
||||||
if ( analyzed_types.count(t) > 0 )
|
if ( analyzed_types.contains(t) )
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
|
|
||||||
analyzed_types.insert(t);
|
analyzed_types.insert(t);
|
||||||
|
@ -117,7 +117,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode PreID(const ID* id) override {
|
TraversalCode PreID(const ID* id) override {
|
||||||
if ( ids.count(id) > 0 )
|
if ( ids.contains(id) )
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
|
|
||||||
if ( attr_depth > 0 )
|
if ( attr_depth > 0 )
|
||||||
|
@ -149,7 +149,7 @@ void UsageAnalyzer::FindSeeds(IDSet& seeds) const {
|
||||||
auto f = GetFuncIfAny(id);
|
auto f = GetFuncIfAny(id);
|
||||||
|
|
||||||
if ( f && id->GetType<FuncType>()->Flavor() == FUNC_FLAVOR_EVENT ) {
|
if ( f && id->GetType<FuncType>()->Flavor() == FUNC_FLAVOR_EVENT ) {
|
||||||
if ( script_events.count(f->GetName()) == 0 )
|
if ( ! script_events.contains(f->GetName()) )
|
||||||
seeds.insert(id.get());
|
seeds.insert(id.get());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -225,7 +225,7 @@ void UsageAnalyzer::Expand(const ID* id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode UsageAnalyzer::PreID(const ID* id) {
|
TraversalCode UsageAnalyzer::PreID(const ID* id) {
|
||||||
if ( analyzed_IDs.count(id) > 0 )
|
if ( analyzed_IDs.contains(id) )
|
||||||
// No need to repeat the analysis.
|
// No need to repeat the analysis.
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ TraversalCode UsageAnalyzer::PreID(const ID* id) {
|
||||||
|
|
||||||
auto f = GetFuncIfAny(id);
|
auto f = GetFuncIfAny(id);
|
||||||
|
|
||||||
if ( f && reachables.count(id) == 0 )
|
if ( f && ! reachables.contains(id) )
|
||||||
// Haven't seen this function before.
|
// Haven't seen this function before.
|
||||||
new_reachables.insert(id);
|
new_reachables.insert(id);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ TraversalCode UsageAnalyzer::PreID(const ID* id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode UsageAnalyzer::PreType(const Type* t) {
|
TraversalCode UsageAnalyzer::PreType(const Type* t) {
|
||||||
if ( analyzed_types.count(t) > 0 )
|
if ( analyzed_types.contains(t) )
|
||||||
return TC_ABORTSTMT;
|
return TC_ABORTSTMT;
|
||||||
|
|
||||||
// Save processing by avoiding a re-traversal of this type.
|
// Save processing by avoiding a re-traversal of this type.
|
||||||
|
|
|
@ -49,7 +49,7 @@ void UseDefs::Dump() {
|
||||||
for ( int i = stmts.size(); --i >= 0; ) {
|
for ( int i = stmts.size(); --i >= 0; ) {
|
||||||
const auto& s = stmts[i];
|
const auto& s = stmts[i];
|
||||||
auto uds = FindUsage(s);
|
auto uds = FindUsage(s);
|
||||||
auto are_copies = (UDs_are_copies.find(s) != UDs_are_copies.end());
|
auto are_copies = (UDs_are_copies.contains(s));
|
||||||
|
|
||||||
printf("UDs (%s) for %s:\n", are_copies ? "copy" : "orig", obj_desc(s).c_str());
|
printf("UDs (%s) for %s:\n", are_copies ? "copy" : "orig", obj_desc(s).c_str());
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs, const Stmt* succ_stmt, bo
|
||||||
|
|
||||||
if ( i == int(stmts.size()) - 1 ) { // Very last statement.
|
if ( i == int(stmts.size()) - 1 ) { // Very last statement.
|
||||||
succ = succ_stmt;
|
succ = succ_stmt;
|
||||||
if ( successor2.find(s) != successor2.end() ) {
|
if ( successor2.contains(s) ) {
|
||||||
om.AddObj(s_i);
|
om.AddObj(s_i);
|
||||||
successor2[s_i] = successor2[s];
|
successor2[s_i] = successor2[s];
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ void UseDefs::FoldInUDs(UDs& main_UDs, const UDs& u1, const UDs& u2) {
|
||||||
void UseDefs::UpdateUDs(const Stmt* s, const UDs& uds) {
|
void UseDefs::UpdateUDs(const Stmt* s, const UDs& uds) {
|
||||||
auto curr_uds = FindUsage(s);
|
auto curr_uds = FindUsage(s);
|
||||||
|
|
||||||
if ( ! curr_uds || UDs_are_copies.find(s) != UDs_are_copies.end() ) {
|
if ( ! curr_uds || UDs_are_copies.contains(s) ) {
|
||||||
// Copy-on-write.
|
// Copy-on-write.
|
||||||
auto new_uds = std::make_shared<UseDefSet>();
|
auto new_uds = std::make_shared<UseDefSet>();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
void Replicate(const UDs& from) { use_defs = from->use_defs; }
|
void Replicate(const UDs& from) { use_defs = from->use_defs; }
|
||||||
|
|
||||||
bool HasID(const ID* id) { return use_defs.find(id) != use_defs.end(); }
|
bool HasID(const ID* id) { return use_defs.contains(id); }
|
||||||
|
|
||||||
void Add(const ID* id) { use_defs.insert(id); }
|
void Add(const ID* id) { use_defs.insert(id); }
|
||||||
void Remove(const ID* id) { use_defs.erase(id); }
|
void Remove(const ID* id) { use_defs.erase(id); }
|
||||||
|
@ -56,8 +56,8 @@ public:
|
||||||
void Analyze();
|
void Analyze();
|
||||||
|
|
||||||
// True if we've computed use-defs for the given statement.
|
// True if we've computed use-defs for the given statement.
|
||||||
bool HasUsage(const Stmt* s) const { return use_defs_map.find(s) != use_defs_map.end(); }
|
|
||||||
bool HasUsage(const StmtPtr& s) const { return HasUsage(s.get()); }
|
bool HasUsage(const StmtPtr& s) const { return HasUsage(s.get()); }
|
||||||
|
bool HasUsage(const Stmt* s) const { return use_defs_map.contains(s); }
|
||||||
|
|
||||||
// Returns the use-defs for the given statement.
|
// Returns the use-defs for the given statement.
|
||||||
UDs GetUsage(const Stmt* s) const { return FindUsage(s); }
|
UDs GetUsage(const Stmt* s) const { return FindUsage(s); }
|
||||||
|
|
|
@ -43,10 +43,10 @@ void finalize_functions(const std::vector<FuncInfo>& funcs) {
|
||||||
for ( auto& f : funcs ) {
|
for ( auto& f : funcs ) {
|
||||||
auto func = f.Func();
|
auto func = f.Func();
|
||||||
|
|
||||||
if ( leave_alone.count(func) > 0 )
|
if ( leave_alone.contains(func) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( remapped_intrp_frame_sizes.count(func) == 0 )
|
if ( ! remapped_intrp_frame_sizes.contains(func) )
|
||||||
// No entry for this function, keep current frame size.
|
// No entry for this function, keep current frame size.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ bool ZAMCompiler::PruneUnused() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int slot = inst->v1;
|
int slot = inst->v1;
|
||||||
if ( denizen_ending.count(slot) > 0 )
|
if ( denizen_ending.contains(slot) )
|
||||||
// Variable is used, keep assignment.
|
// Variable is used, keep assignment.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ bool ZAMCompiler::PruneUnused() {
|
||||||
// can't remove the instruction entirely because it has
|
// can't remove the instruction entirely because it has
|
||||||
// side effects. Transform the instruction into its flavor
|
// side effects. Transform the instruction into its flavor
|
||||||
// that doesn't make an assignment.
|
// that doesn't make an assignment.
|
||||||
if ( assignmentless_op.count(inst->op) == 0 )
|
if ( ! assignmentless_op.contains(inst->op) )
|
||||||
reporter->InternalError("inconsistency in re-flavoring instruction with side effects");
|
reporter->InternalError("inconsistency in re-flavoring instruction with side effects");
|
||||||
|
|
||||||
inst->op_type = assignmentless_op_class[inst->op];
|
inst->op_type = assignmentless_op_class[inst->op];
|
||||||
|
@ -506,14 +506,14 @@ void ZAMCompiler::ReMapFrame() {
|
||||||
for ( zeek_uint_t i = 0; i < insts1.size(); ++i ) {
|
for ( zeek_uint_t i = 0; i < insts1.size(); ++i ) {
|
||||||
auto inst = insts1[i];
|
auto inst = insts1[i];
|
||||||
|
|
||||||
if ( inst_beginnings.count(inst) == 0 )
|
if ( ! inst_beginnings.contains(inst) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto vars = inst_beginnings[inst];
|
auto vars = inst_beginnings[inst];
|
||||||
for ( auto v : vars ) {
|
for ( auto v : vars ) {
|
||||||
// Don't remap variables whose values aren't actually used.
|
// Don't remap variables whose values aren't actually used.
|
||||||
int slot = frame_layout1[v];
|
int slot = frame_layout1[v];
|
||||||
if ( denizen_ending.count(slot) > 0 )
|
if ( denizen_ending.contains(slot) )
|
||||||
ReMapVar(v, slot, i);
|
ReMapVar(v, slot, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ void ZAMCompiler::ReMapInterpreterFrame() {
|
||||||
// Update frame sizes for functions that might have more than
|
// Update frame sizes for functions that might have more than
|
||||||
// one body.
|
// one body.
|
||||||
auto f = func.get();
|
auto f = func.get();
|
||||||
if ( remapped_intrp_frame_sizes.count(f) == 0 || remapped_intrp_frame_sizes[f] < next_interp_slot )
|
if ( ! remapped_intrp_frame_sizes.contains(f) || remapped_intrp_frame_sizes[f] < next_interp_slot )
|
||||||
remapped_intrp_frame_sizes[f] = next_interp_slot;
|
remapped_intrp_frame_sizes[f] = next_interp_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +753,7 @@ void ZAMCompiler::CheckSlotAssignment(int slot, const ZInstI* inst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::SetLifetimeStart(int slot, const ZInstI* inst) {
|
void ZAMCompiler::SetLifetimeStart(int slot, const ZInstI* inst) {
|
||||||
if ( denizen_beginning.count(slot) > 0 ) {
|
if ( denizen_beginning.contains(slot) ) {
|
||||||
// Beginning of denizen's lifetime already seen, nothing
|
// Beginning of denizen's lifetime already seen, nothing
|
||||||
// more to do other than check for consistency.
|
// more to do other than check for consistency.
|
||||||
ASSERT(denizen_beginning[slot]->inst_num <= inst->inst_num);
|
ASSERT(denizen_beginning[slot]->inst_num <= inst->inst_num);
|
||||||
|
@ -762,7 +762,7 @@ void ZAMCompiler::SetLifetimeStart(int slot, const ZInstI* inst) {
|
||||||
else { // denizen begins here
|
else { // denizen begins here
|
||||||
denizen_beginning[slot] = inst;
|
denizen_beginning[slot] = inst;
|
||||||
|
|
||||||
if ( inst_beginnings.count(inst) == 0 )
|
if ( ! inst_beginnings.contains(inst) )
|
||||||
// Need to create a set to track the denizens
|
// Need to create a set to track the denizens
|
||||||
// beginning at the instruction.
|
// beginning at the instruction.
|
||||||
inst_beginnings[inst] = {};
|
inst_beginnings[inst] = {};
|
||||||
|
@ -777,7 +777,7 @@ void ZAMCompiler::CheckSlotUse(int slot, const ZInstI* inst) {
|
||||||
|
|
||||||
ASSERT(static_cast<zeek_uint_t>(slot) < frame_denizens.size());
|
ASSERT(static_cast<zeek_uint_t>(slot) < frame_denizens.size());
|
||||||
|
|
||||||
if ( denizen_beginning.count(slot) == 0 ) {
|
if ( ! denizen_beginning.contains(slot) ) {
|
||||||
ODesc d;
|
ODesc d;
|
||||||
inst->loc->Loc()->Describe(&d);
|
inst->loc->Loc()->Describe(&d);
|
||||||
reporter->Error("%s: value used but not set: %s", d.Description(), frame_denizens[slot]->Name());
|
reporter->Error("%s: value used but not set: %s", d.Description(), frame_denizens[slot]->Name());
|
||||||
|
@ -788,7 +788,7 @@ void ZAMCompiler::CheckSlotUse(int slot, const ZInstI* inst) {
|
||||||
// at a lower loop depth than that for this instruction, then we
|
// at a lower loop depth than that for this instruction, then we
|
||||||
// extend its lifetime to the end of this instruction's loop.
|
// extend its lifetime to the end of this instruction's loop.
|
||||||
if ( reducer->IsTemporary(frame_denizens[slot]) ) {
|
if ( reducer->IsTemporary(frame_denizens[slot]) ) {
|
||||||
ASSERT(denizen_beginning.count(slot) > 0);
|
ASSERT(denizen_beginning.contains(slot));
|
||||||
int definition_depth = denizen_beginning[slot]->loop_depth;
|
int definition_depth = denizen_beginning[slot]->loop_depth;
|
||||||
|
|
||||||
if ( inst->loop_depth > definition_depth )
|
if ( inst->loop_depth > definition_depth )
|
||||||
|
@ -805,7 +805,7 @@ void ZAMCompiler::ExtendLifetime(int slot, const ZInstI* inst) {
|
||||||
auto id = frame_denizens[slot];
|
auto id = frame_denizens[slot];
|
||||||
auto& t = id->GetType();
|
auto& t = id->GetType();
|
||||||
|
|
||||||
if ( denizen_ending.count(slot) > 0 ) {
|
if ( denizen_ending.contains(slot) ) {
|
||||||
// End of denizen's lifetime already seen. Check for
|
// End of denizen's lifetime already seen. Check for
|
||||||
// consistency and then extend as needed.
|
// consistency and then extend as needed.
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@ void ZAMCompiler::ExtendLifetime(int slot, const ZInstI* inst) {
|
||||||
if ( old_inst->inst_num < inst->inst_num ) { // Extend.
|
if ( old_inst->inst_num < inst->inst_num ) { // Extend.
|
||||||
inst_endings[old_inst].erase(frame_denizens[slot]);
|
inst_endings[old_inst].erase(frame_denizens[slot]);
|
||||||
|
|
||||||
if ( inst_endings.count(inst) == 0 )
|
if ( ! inst_endings.contains(inst) )
|
||||||
inst_endings[inst] = {};
|
inst_endings[inst] = {};
|
||||||
|
|
||||||
inst_endings[inst].insert(frame_denizens[slot]);
|
inst_endings[inst].insert(frame_denizens[slot]);
|
||||||
|
@ -839,7 +839,7 @@ void ZAMCompiler::ExtendLifetime(int slot, const ZInstI* inst) {
|
||||||
else { // first time seeing a use of this denizen
|
else { // first time seeing a use of this denizen
|
||||||
denizen_ending[slot] = inst;
|
denizen_ending[slot] = inst;
|
||||||
|
|
||||||
if ( inst_endings.count(inst) == 0 ) {
|
if ( ! inst_endings.contains(inst) ) {
|
||||||
IDSet denizens;
|
IDSet denizens;
|
||||||
inst_endings[inst] = denizens;
|
inst_endings[inst] = denizens;
|
||||||
}
|
}
|
||||||
|
@ -988,9 +988,9 @@ void ZAMCompiler::KillInst(zeek_uint_t i) {
|
||||||
if ( inst->aux && ! inst->aux->cft.empty() ) {
|
if ( inst->aux && ! inst->aux->cft.empty() ) {
|
||||||
auto& cft = inst->aux->cft;
|
auto& cft = inst->aux->cft;
|
||||||
|
|
||||||
if ( cft.count(CFT_ELSE) > 0 ) {
|
if ( cft.contains(CFT_ELSE) ) {
|
||||||
// Push forward unless this was the end of the block.
|
// Push forward unless this was the end of the block.
|
||||||
if ( cft.count(CFT_BLOCK_END) == 0 ) {
|
if ( ! cft.contains(CFT_BLOCK_END) ) {
|
||||||
ASSERT(succ);
|
ASSERT(succ);
|
||||||
AddCFT(succ, CFT_ELSE);
|
AddCFT(succ, CFT_ELSE);
|
||||||
}
|
}
|
||||||
|
@ -1007,15 +1007,15 @@ void ZAMCompiler::KillInst(zeek_uint_t i) {
|
||||||
// because they just lead to their following instruction, and next's
|
// because they just lead to their following instruction, and next's
|
||||||
// if they become dead code. However, loops and loop conditionals
|
// if they become dead code. However, loops and loop conditionals
|
||||||
// should not be killed.
|
// should not be killed.
|
||||||
ASSERT(cft.count(CFT_LOOP) == 0);
|
ASSERT(! cft.contains(CFT_LOOP));
|
||||||
ASSERT(cft.count(CFT_LOOP_COND) == 0);
|
ASSERT(! cft.contains(CFT_LOOP_COND));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::BackPropagateCFT(int inst_num, ControlFlowType cf_type) {
|
void ZAMCompiler::BackPropagateCFT(int inst_num, ControlFlowType cf_type) {
|
||||||
auto inst = insts1[inst_num];
|
auto inst = insts1[inst_num];
|
||||||
auto& cft = inst->aux->cft;
|
auto& cft = inst->aux->cft;
|
||||||
if ( cft.count(cf_type) == 0 )
|
if ( ! cft.contains(cf_type) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int j = inst_num;
|
int j = inst_num;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void ZAMCompiler::Init() {
|
||||||
|
|
||||||
TrackMemoryManagement();
|
TrackMemoryManagement();
|
||||||
|
|
||||||
non_recursive = non_recursive_funcs.count(func.get()) > 0;
|
non_recursive = non_recursive_funcs.contains(func.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAMCompiler::InitGlobals() {
|
void ZAMCompiler::InitGlobals() {
|
||||||
|
@ -92,7 +92,7 @@ void ZAMCompiler::InitLocals() {
|
||||||
if ( IsCapture(l) )
|
if ( IsCapture(l) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( pf->WhenLocals().count(l) > 0 )
|
if ( pf->WhenLocals().contains(l) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto non_const_l = const_cast<ID*>(l);
|
auto non_const_l = const_cast<ID*>(l);
|
||||||
|
|
|
@ -322,7 +322,7 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdatesExpr*
|
||||||
bool homogeneous = field_tags.size() == 1;
|
bool homogeneous = field_tags.size() == 1;
|
||||||
// Here we leverage the fact that C++ "+=" works identically for
|
// Here we leverage the fact that C++ "+=" works identically for
|
||||||
// signed and unsigned int's.
|
// signed and unsigned int's.
|
||||||
if ( ! homogeneous && field_tags.size() == 2 && field_tags.count(TYPE_INT) > 0 && field_tags.count(TYPE_COUNT) > 0 )
|
if ( ! homogeneous && field_tags.size() == 2 && field_tags.contains(TYPE_INT) && field_tags.contains(TYPE_COUNT) )
|
||||||
homogeneous = true;
|
homogeneous = true;
|
||||||
|
|
||||||
ZOp op;
|
ZOp op;
|
||||||
|
@ -338,7 +338,7 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdatesExpr*
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( homogeneous ) {
|
else if ( homogeneous ) {
|
||||||
if ( field_tags.count(TYPE_DOUBLE) > 0 )
|
if ( field_tags.contains(TYPE_DOUBLE) )
|
||||||
op = OP_REC_ADD_DOUBLE_FIELDS_VV;
|
op = OP_REC_ADD_DOUBLE_FIELDS_VV;
|
||||||
else
|
else
|
||||||
// Here we leverage that += will work for both signed/unsigned.
|
// Here we leverage that += will work for both signed/unsigned.
|
||||||
|
@ -951,7 +951,7 @@ const ZAMStmt ZAMCompiler::BuildLambda(int n_slot, ExprPtr e) {
|
||||||
for ( int i = 0; i < ncaptures; ++i ) {
|
for ( int i = 0; i < ncaptures; ++i ) {
|
||||||
auto& id_i = (*captures)[i].Id();
|
auto& id_i = (*captures)[i].Id();
|
||||||
|
|
||||||
if ( pf->WhenLocals().count(id_i.get()) > 0 )
|
if ( pf->WhenLocals().contains(id_i.get()) )
|
||||||
aux->Add(i, nullptr);
|
aux->Add(i, nullptr);
|
||||||
else
|
else
|
||||||
aux->Add(i, FrameSlot(id_i), id_i->GetType());
|
aux->Add(i, FrameSlot(id_i), id_i->GetType());
|
||||||
|
|
|
@ -118,7 +118,7 @@ eval static auto any_val = ZVal();
|
||||||
macro EvalSwitchBody(index, branch, cases, postscript)
|
macro EvalSwitchBody(index, branch, cases, postscript)
|
||||||
{
|
{
|
||||||
auto t = cases[index];
|
auto t = cases[index];
|
||||||
if ( t.find(v) == t.end() )
|
if ( ! t.contains(v) )
|
||||||
pc = branch;
|
pc = branch;
|
||||||
else
|
else
|
||||||
pc = t[v];
|
pc = t[v];
|
||||||
|
|
|
@ -102,7 +102,7 @@ void validate_ZAM_insts() {
|
||||||
|
|
||||||
for ( int i = 0; i < int(OP_NOP); ++i ) {
|
for ( int i = 0; i < int(OP_NOP); ++i ) {
|
||||||
auto zop = ZOp(i);
|
auto zop = ZOp(i);
|
||||||
if ( zam_inst_desc.find(zop) == zam_inst_desc.end() && assignment_flavor.find(zop) == assignment_flavor.end() )
|
if ( ! zam_inst_desc.contains(zop) && ! assignment_flavor.contains(zop) )
|
||||||
reporter->InternalError("op %s missing from description", ZOP_name(zop));
|
reporter->InternalError("op %s missing from description", ZOP_name(zop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ bool ZAMCompiler::IsUnused(const IDPtr& id, const Stmt* where) const {
|
||||||
|
|
||||||
bool ZAMCompiler::IsCapture(const ID* id) const {
|
bool ZAMCompiler::IsCapture(const ID* id) const {
|
||||||
const auto& c = pf->CapturesOffsets();
|
const auto& c = pf->CapturesOffsets();
|
||||||
return c.find(id) != c.end();
|
return c.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZAMCompiler::CaptureOffset(const ID* id) const {
|
int ZAMCompiler::CaptureOffset(const ID* id) const {
|
||||||
|
@ -143,7 +143,7 @@ int ZAMCompiler::RawSlot(const ID* id) {
|
||||||
return id_slot->second;
|
return id_slot->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZAMCompiler::HasFrameSlot(const ID* id) const { return frame_layout1.find(id) != frame_layout1.end(); }
|
bool ZAMCompiler::HasFrameSlot(const ID* id) const { return frame_layout1.contains(id); }
|
||||||
|
|
||||||
int ZAMCompiler::NewSlot(bool is_managed) {
|
int ZAMCompiler::NewSlot(bool is_managed) {
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
|
|
|
@ -653,7 +653,7 @@ bool ZInstI::IsGlobalLoad() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return global_ops.count(op) > 0;
|
return global_ops.contains(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZInstI::IsCaptureLoad() const { return op == OP_LOAD_CAPTURE_Vi || op == OP_LOAD_MANAGED_CAPTURE_Vi; }
|
bool ZInstI::IsCaptureLoad() const { return op == OP_LOAD_CAPTURE_Vi || op == OP_LOAD_MANAGED_CAPTURE_Vi; }
|
||||||
|
|
|
@ -83,7 +83,7 @@ ZOp AssignmentFlavor(ZOp orig, TypeTag tag, bool strict) {
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( assignment_flavor.count(orig) == 0 ) {
|
if ( ! assignment_flavor.contains(orig) ) {
|
||||||
if ( strict )
|
if ( strict )
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
else
|
else
|
||||||
|
@ -92,7 +92,7 @@ ZOp AssignmentFlavor(ZOp orig, TypeTag tag, bool strict) {
|
||||||
|
|
||||||
auto orig_map = assignment_flavor[orig];
|
auto orig_map = assignment_flavor[orig];
|
||||||
|
|
||||||
if ( orig_map.count(tag) == 0 ) {
|
if ( ! orig_map.contains(tag) ) {
|
||||||
if ( strict )
|
if ( strict )
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
else
|
else
|
||||||
|
|
|
@ -1251,7 +1251,7 @@ function hexdump%(data_str: string%) : string
|
||||||
function reverse%(str: string%) : string
|
function reverse%(str: string%) : string
|
||||||
%{
|
%{
|
||||||
string s = str->ToStdString();
|
string s = str->ToStdString();
|
||||||
reverse(s.begin(), s.end());
|
std::ranges::reverse(s);
|
||||||
return zeek::make_intrusive<zeek::StringVal>(s.length(), (const char*)s.c_str());
|
return zeek::make_intrusive<zeek::StringVal>(s.length(), (const char*)s.c_str());
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -1308,8 +1308,8 @@ static int64_t do_find_str(zeek::StringVal* str, zeek::StringVal* sub, int64_t s
|
||||||
|
|
||||||
if ( ! case_sensitive )
|
if ( ! case_sensitive )
|
||||||
{
|
{
|
||||||
transform(s.begin(), s.end(), s.begin(), ::tolower);
|
std::ranges::transform(s, s.begin(), ::tolower);
|
||||||
transform(sb.begin(), sb.end(), sb.begin(), ::tolower);
|
std::ranges::transform(sb, sb.begin(), ::tolower);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rfind )
|
if ( rfind )
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ std::optional<SupervisedNode> Stem::Poll() {
|
||||||
|
|
||||||
if ( cmd == "create" ) {
|
if ( cmd == "create" ) {
|
||||||
const auto& node_json = msg_tokens[2];
|
const auto& node_json = msg_tokens[2];
|
||||||
assert(nodes.find(node_name) == nodes.end());
|
assert(! nodes.contains(node_name));
|
||||||
auto node_config = Supervisor::NodeConfig::FromJSON(node_json);
|
auto node_config = Supervisor::NodeConfig::FromJSON(node_json);
|
||||||
auto it = nodes.emplace(node_name, std::move(node_config)).first;
|
auto it = nodes.emplace(node_name, std::move(node_config)).first;
|
||||||
auto& node = it->second;
|
auto& node = it->second;
|
||||||
|
@ -1514,7 +1514,7 @@ std::string Supervisor::Create(const Supervisor::NodeConfig& node) {
|
||||||
if ( node.name.find(' ') != std::string::npos )
|
if ( node.name.find(' ') != std::string::npos )
|
||||||
return util::fmt("node names must not contain spaces: '%s'", node.name.data());
|
return util::fmt("node names must not contain spaces: '%s'", node.name.data());
|
||||||
|
|
||||||
if ( nodes.find(node.name) != nodes.end() )
|
if ( nodes.contains(node.name) )
|
||||||
return util::fmt("node with name '%s' already exists", node.name.data());
|
return util::fmt("node with name '%s' already exists", node.name.data());
|
||||||
|
|
||||||
if ( node.interface.has_value() && node.pcap_file.has_value() )
|
if ( node.interface.has_value() && node.pcap_file.has_value() )
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool labels_valid(std::span<const zeek::telemetry::LabelView> labels,
|
||||||
return std::find(keys.begin(), keys.end(), x.first) != keys.end();
|
return std::find(keys.begin(), keys.end(), x.first) != keys.end();
|
||||||
};
|
};
|
||||||
return labels.size() == label_names.size()
|
return labels.size() == label_names.size()
|
||||||
&& std::all_of(labels.begin(), labels.end(), key_in_label_names);
|
&& std::ranges::all_of(labels, key_in_label_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IntOrDbl>
|
template <class IntOrDbl>
|
||||||
|
|
|
@ -275,11 +275,11 @@ static bool show_plugins(int level) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for ( plugin::Manager::plugin_list::const_iterator i = plugins.begin(); i != plugins.end(); i++ ) {
|
for ( const auto& plugin : plugins ) {
|
||||||
if ( requested_plugins.size() && requested_plugins.find((*i)->Name()) == requested_plugins.end() )
|
if ( ! requested_plugins.empty() && ! requested_plugins.contains(plugin->Name()) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*i)->Describe(&d);
|
plugin->Describe(&d);
|
||||||
|
|
||||||
if ( ! d.IsShort() )
|
if ( ! d.IsShort() )
|
||||||
d.Add("\n");
|
d.Add("\n");
|
||||||
|
|
|
@ -9,13 +9,14 @@
|
||||||
|
|
||||||
%%{ // C++ segment
|
%%{ // C++ segment
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <numbers>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "zeek/digest.h"
|
#include "zeek/digest.h"
|
||||||
|
@ -4222,7 +4223,7 @@ function blocking_lookup_hostname%(host: string%) : addr_set
|
||||||
## .. zeek:see:: haversine_distance_ip
|
## .. zeek:see:: haversine_distance_ip
|
||||||
function haversine_distance%(lat1: double, long1: double, lat2: double, long2: double%): double
|
function haversine_distance%(lat1: double, long1: double, lat2: double, long2: double%): double
|
||||||
%{
|
%{
|
||||||
const double PI = 3.14159;
|
const double PI = std::numbers::pi;
|
||||||
const double RADIUS = 3958.8; // Earth's radius in miles.
|
const double RADIUS = 3958.8; // Earth's radius in miles.
|
||||||
|
|
||||||
double s1 = sin((lat2 - lat1) * PI/360);
|
double s1 = sin((lat2 - lat1) * PI/360);
|
||||||
|
|
|
@ -494,7 +494,7 @@ void ScriptTarget::DoGenerate() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const auto& f : dir_contents ) {
|
for ( const auto& f : dir_contents ) {
|
||||||
if ( targets.find(f) != targets.end() )
|
if ( targets.contains(f) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( unlink(f.c_str()) < 0 )
|
if ( unlink(f.c_str()) < 0 )
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
5.8481e+03
|
5.8481e+03
|
||||||
1.9193e-02
|
1.9193e-02
|
||||||
1.5136e-02
|
1.5136e-02
|
||||||
9.2419e-01
|
9.0763e-01
|
||||||
1.2437e+04
|
1.2437e+04
|
||||||
1.2437e+04
|
1.2437e+04
|
||||||
|
|
|
@ -912,7 +912,7 @@ Type* Type::LookUpByID(ID* id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Type::AddPredefinedType(const string& type_name, Type* type) {
|
void Type::AddPredefinedType(const string& type_name, Type* type) {
|
||||||
ASSERT(type_map_.find(type_name) == type_map_.end());
|
ASSERT(! type_map_.contains(type_name));
|
||||||
type_map_[type_name] = type;
|
type_map_[type_name] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue