mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix clang-tidy modernize-use-emplace findings
This commit is contained in:
parent
3943e64372
commit
a3078f3132
9 changed files with 19 additions and 20 deletions
|
@ -10,6 +10,7 @@ Checks: [-*,
|
||||||
modernize-return-braced-init-list,
|
modernize-return-braced-init-list,
|
||||||
modernize-use-bool-literals,
|
modernize-use-bool-literals,
|
||||||
modernize-use-default-member-init,
|
modernize-use-default-member-init,
|
||||||
|
modernize-use-emplace,
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
|
@ -696,8 +696,8 @@ StmtPtr ScriptFunc::AddInits(StmtPtr body, const std::vector<IDPtr>& inits) {
|
||||||
auto stmt_series = with_location_of(make_intrusive<StmtList>(), body);
|
auto stmt_series = with_location_of(make_intrusive<StmtList>(), body);
|
||||||
auto init = with_location_of(make_intrusive<InitStmt>(inits), body);
|
auto init = with_location_of(make_intrusive<InitStmt>(inits), body);
|
||||||
|
|
||||||
stmt_series->Stmts().push_back(std::move(init));
|
stmt_series->Stmts().emplace_back(std::move(init));
|
||||||
stmt_series->Stmts().push_back(std::move(body));
|
stmt_series->Stmts().emplace_back(std::move(body));
|
||||||
|
|
||||||
return stmt_series;
|
return stmt_series;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,15 +92,15 @@ void RuleActionEvent::DoAction(const Rule* parent, RuleEndpointState* state, con
|
||||||
if ( handler ) {
|
if ( handler ) {
|
||||||
zeek::Args args;
|
zeek::Args args;
|
||||||
args.reserve(msg ? 3 : 2);
|
args.reserve(msg ? 3 : 2);
|
||||||
args.push_back({AdoptRef{}, rule_matcher->BuildRuleStateValue(parent, state)});
|
args.emplace_back(AdoptRef{}, rule_matcher->BuildRuleStateValue(parent, state));
|
||||||
|
|
||||||
if ( msg )
|
if ( msg )
|
||||||
args.push_back(msg);
|
args.emplace_back(msg);
|
||||||
|
|
||||||
if ( data )
|
if ( data )
|
||||||
args.push_back(make_intrusive<StringVal>(len, reinterpret_cast<const char*>(data)));
|
args.emplace_back(make_intrusive<StringVal>(len, reinterpret_cast<const char*>(data)));
|
||||||
else
|
else
|
||||||
args.push_back(zeek::val_mgr->EmptyString());
|
args.emplace_back(zeek::val_mgr->EmptyString());
|
||||||
|
|
||||||
if ( want_end_of_match ) {
|
if ( want_end_of_match ) {
|
||||||
auto* match = state->FindRulePatternMatch(parent);
|
auto* match = state->FindRulePatternMatch(parent);
|
||||||
|
|
|
@ -1638,7 +1638,7 @@ bool detail::TablePatternMatcher::MatchAll(const StringValPtr& s) {
|
||||||
|
|
||||||
void detail::TablePatternMatcher::Build() {
|
void detail::TablePatternMatcher::Build() {
|
||||||
matcher_yields.clear();
|
matcher_yields.clear();
|
||||||
matcher_yields.push_back(nullptr);
|
matcher_yields.emplace_back(nullptr);
|
||||||
|
|
||||||
auto& tbl_dict = *tbl->Get();
|
auto& tbl_dict = *tbl->Get();
|
||||||
auto& tbl_hash = *tbl->GetTableHash();
|
auto& tbl_hash = *tbl->GetTableHash();
|
||||||
|
|
|
@ -775,7 +775,7 @@ void Manager::Peer(const string& addr, uint16_t port, double retry) {
|
||||||
|
|
||||||
auto secs = broker::timeout::seconds(static_cast<uint64_t>(retry));
|
auto secs = broker::timeout::seconds(static_cast<uint64_t>(retry));
|
||||||
bstate->endpoint.peer_nosync(addr, port, secs);
|
bstate->endpoint.peer_nosync(addr, port, secs);
|
||||||
bstate->outbound_peerings.emplace(broker::network_info(addr, port));
|
bstate->outbound_peerings.emplace(addr, port);
|
||||||
|
|
||||||
auto counts_as_iosource = get_option("Broker::peer_counts_as_iosource")->AsBool();
|
auto counts_as_iosource = get_option("Broker::peer_counts_as_iosource")->AsBool();
|
||||||
|
|
||||||
|
@ -1160,7 +1160,7 @@ RecordVal* Manager::MakeEvent(ValPList* args, zeek::detail::Frame* frame) {
|
||||||
zeek::Args cargs;
|
zeek::Args cargs;
|
||||||
cargs.reserve(args->size());
|
cargs.reserve(args->size());
|
||||||
for ( auto* a : *args )
|
for ( auto* a : *args )
|
||||||
cargs.push_back({zeek::NewRef{}, a});
|
cargs.emplace_back(zeek::NewRef{}, a);
|
||||||
|
|
||||||
return MakeEvent(ArgsSpan{cargs}, frame)->Ref()->AsRecordVal();
|
return MakeEvent(ArgsSpan{cargs}, frame)->Ref()->AsRecordVal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,8 @@ std::optional<broker::zeek::Event> detail::to_broker_event(const detail::Event&
|
||||||
|
|
||||||
for ( const auto& m : *meta ) {
|
for ( const auto& m : *meta ) {
|
||||||
if ( auto res = zeek::Broker::detail::val_to_data(m.Val().get()); res.has_value() ) {
|
if ( auto res = zeek::Broker::detail::val_to_data(m.Val().get()); res.has_value() ) {
|
||||||
broker::vector entry(2);
|
broker::vector entry{static_cast<broker::count>(m.Id()), res.value()};
|
||||||
entry[0] = static_cast<broker::count>(m.Id());
|
broker_meta.emplace_back(std::move(entry));
|
||||||
entry[1] = res.value();
|
|
||||||
broker_meta.push_back(std::move(entry));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Just for sanity - we should never get here.
|
// Just for sanity - we should never get here.
|
||||||
|
|
|
@ -281,7 +281,7 @@ void Inliner::CoalesceEventHandlers(ScriptFuncPtr func, const std::vector<Func::
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto ie_s = with_location_of(make_intrusive<ExprStmt>(ie), bp);
|
auto ie_s = with_location_of(make_intrusive<ExprStmt>(ie), bp);
|
||||||
merged_body->Stmts().push_back(std::move(ie_s));
|
merged_body->Stmts().emplace_back(std::move(ie_s));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto inlined_func = make_intrusive<CoalescedScriptFunc>(merged_body, new_scope, func);
|
auto inlined_func = make_intrusive<CoalescedScriptFunc>(merged_body, new_scope, func);
|
||||||
|
|
|
@ -101,7 +101,7 @@ ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode ProfileFunc::PreStmt(const Stmt* s) {
|
TraversalCode ProfileFunc::PreStmt(const Stmt* s) {
|
||||||
stmts.push_back({NewRef{}, const_cast<Stmt*>(s)});
|
stmts.emplace_back(NewRef{}, const_cast<Stmt*>(s));
|
||||||
|
|
||||||
switch ( s->Tag() ) {
|
switch ( s->Tag() ) {
|
||||||
case STMT_INIT:
|
case STMT_INIT:
|
||||||
|
@ -185,7 +185,7 @@ TraversalCode ProfileFunc::PreStmt(const Stmt* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TraversalCode ProfileFunc::PreExpr(const Expr* e) {
|
TraversalCode ProfileFunc::PreExpr(const Expr* e) {
|
||||||
exprs.push_back({NewRef{}, const_cast<Expr*>(e)});
|
exprs.emplace_back(NewRef{}, const_cast<Expr*>(e));
|
||||||
|
|
||||||
TrackType(e->GetType());
|
TrackType(e->GetType());
|
||||||
|
|
||||||
|
@ -1476,7 +1476,7 @@ std::string func_name_at_loc(std::string fname, const Location* loc) {
|
||||||
TraversalCode SetBlockLineNumbers::PreStmt(const Stmt* s) {
|
TraversalCode SetBlockLineNumbers::PreStmt(const Stmt* s) {
|
||||||
auto loc = const_cast<Location*>(s->GetLocationInfo());
|
auto loc = const_cast<Location*>(s->GetLocationInfo());
|
||||||
UpdateLocInfo(loc);
|
UpdateLocInfo(loc);
|
||||||
block_line_range.emplace_back(std::pair<int, int>{loc->first_line, loc->last_line});
|
block_line_range.emplace_back(loc->first_line, loc->last_line);
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1535,7 +1535,7 @@ ASTBlockAnalyzer::ASTBlockAnalyzer(std::vector<FuncInfo>& funcs) {
|
||||||
auto body_loc = body->GetLocationInfo();
|
auto body_loc = body->GetLocationInfo();
|
||||||
fn = func_name_at_loc(fn, body_loc);
|
fn = func_name_at_loc(fn, body_loc);
|
||||||
|
|
||||||
parents.emplace_back(std::pair<std::string, std::string>{fn, fn});
|
parents.emplace_back(fn, fn);
|
||||||
func_name_prefix = fn + ":";
|
func_name_prefix = fn + ":";
|
||||||
body->Traverse(this);
|
body->Traverse(this);
|
||||||
parents.pop_back();
|
parents.pop_back();
|
||||||
|
@ -1555,7 +1555,7 @@ TraversalCode ASTBlockAnalyzer::PreStmt(const Stmt* s) {
|
||||||
auto ls = BuildExpandedDescription(loc);
|
auto ls = BuildExpandedDescription(loc);
|
||||||
|
|
||||||
if ( is_compound_stmt(s) )
|
if ( is_compound_stmt(s) )
|
||||||
parents.push_back(std::pair<std::string, std::string>{LocWithFunc(loc), std::move(ls)});
|
parents.emplace_back(LocWithFunc(loc), std::move(ls));
|
||||||
|
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,7 @@ NameExprPtr Reducer::GenInlineBlockName(const IDPtr& id) {
|
||||||
|
|
||||||
void Reducer::PushInlineBlock() {
|
void Reducer::PushInlineBlock() {
|
||||||
++inline_block_level;
|
++inline_block_level;
|
||||||
block_locals.emplace_back(std::unordered_map<const ID*, IDPtr>());
|
block_locals.emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reducer::PopInlineBlock() {
|
void Reducer::PopInlineBlock() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue