mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
use container empty() rather than size() where appropriate
This commit is contained in:
parent
9b2eb2c373
commit
ffd1905f90
13 changed files with 37 additions and 37 deletions
|
@ -133,7 +133,7 @@ void CPPCompile::ExpandTypeVar(const TypePtr& t)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& script_type_name = t->GetName();
|
auto& script_type_name = t->GetName();
|
||||||
if ( script_type_name.size() > 0 )
|
if ( ! script_type_name.empty() )
|
||||||
AddInit(t, "register_type__CPP(" + tn + ", \"" +
|
AddInit(t, "register_type__CPP(" + tn + ", \"" +
|
||||||
script_type_name + "\");");
|
script_type_name + "\");");
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ void CPPCompile::ExpandEnumTypeVar(const TypePtr& t, string& tn)
|
||||||
auto names = et->Names();
|
auto names = et->Names();
|
||||||
|
|
||||||
AddInit(t, "{ auto et = " + e_name + ";");
|
AddInit(t, "{ auto et = " + e_name + ";");
|
||||||
AddInit(t, "if ( et->Names().size() == 0 ) {");
|
AddInit(t, "if ( et->Names().empty() ) {");
|
||||||
|
|
||||||
for ( const auto& name_pair : et->Names() )
|
for ( const auto& name_pair : et->Names() )
|
||||||
AddInit(t, string("\tet->AddNameInternal(\"") +
|
AddInit(t, string("\tet->AddNameInternal(\"") +
|
||||||
|
|
|
@ -54,7 +54,7 @@ bool CPPCompile::CheckForCollisions()
|
||||||
// the name either (1) wasn't previously used, or (2) if it
|
// the name either (1) wasn't previously used, or (2) if it
|
||||||
// was, it was likewise for an enum or a record.
|
// was, it was likewise for an enum or a record.
|
||||||
const auto& tn = t->GetName();
|
const auto& tn = t->GetName();
|
||||||
if ( tn.size() == 0 || ! hm.HasGlobal(tn) )
|
if ( tn.empty() || ! hm.HasGlobal(tn) )
|
||||||
// No concern of collision since the type name
|
// No concern of collision since the type name
|
||||||
// wasn't previously compiled.
|
// wasn't previously compiled.
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -518,7 +518,7 @@ void GenIDDefs::TrackID(const ID* id, const ExprPtr& e)
|
||||||
{
|
{
|
||||||
auto oi = id->GetOptInfo();
|
auto oi = id->GetOptInfo();
|
||||||
|
|
||||||
ASSERT(barrier_blocks.size() > 0);
|
ASSERT(! barrier_blocks.empty());
|
||||||
oi->DefinedAfter(curr_stmt, e,
|
oi->DefinedAfter(curr_stmt, e,
|
||||||
confluence_blocks, barrier_blocks.back());
|
confluence_blocks, barrier_blocks.back());
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ void GenIDDefs::TrackID(const ID* id, const ExprPtr& e)
|
||||||
// block.
|
// block.
|
||||||
modified_IDs[i+1].insert(id);
|
modified_IDs[i+1].insert(id);
|
||||||
|
|
||||||
if ( confluence_blocks.size() == 0 )
|
if ( confluence_blocks.empty() )
|
||||||
// This is a definition at the outermost level.
|
// This is a definition at the outermost level.
|
||||||
modified_IDs[0].insert(id);
|
modified_IDs[0].insert(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,7 +357,7 @@ void RD_Decorate::TraverseSwitch(const SwitchStmt* sw)
|
||||||
bd->Clear();
|
bd->Clear();
|
||||||
body->Traverse(this);
|
body->Traverse(this);
|
||||||
|
|
||||||
if ( bd->PreRDs().size() > 0 )
|
if ( ! bd->PreRDs().empty() )
|
||||||
reporter->InternalError("mispropagation of switch body defs");
|
reporter->InternalError("mispropagation of switch body defs");
|
||||||
|
|
||||||
if ( body->NoFlowAfter(true) )
|
if ( body->NoFlowAfter(true) )
|
||||||
|
@ -544,7 +544,7 @@ TraversalCode RD_Decorate::PostStmt(const Stmt* s)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STMT_BREAK:
|
case STMT_BREAK:
|
||||||
if ( block_defs.size() == 0 )
|
if ( block_defs.empty() )
|
||||||
{
|
{
|
||||||
if ( func_flavor == FUNC_FLAVOR_HOOK )
|
if ( func_flavor == FUNC_FLAVOR_HOOK )
|
||||||
// Treat as a return.
|
// Treat as a return.
|
||||||
|
|
|
@ -78,7 +78,7 @@ void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e,
|
||||||
|
|
||||||
if ( ! s )
|
if ( ! s )
|
||||||
{ // This is a definition-upon-entry
|
{ // This is a definition-upon-entry
|
||||||
ASSERT(usage_regions.size() == 0);
|
ASSERT(usage_regions.empty());
|
||||||
usage_regions.emplace_back(0, 0, true, 0);
|
usage_regions.emplace_back(0, 0, true, 0);
|
||||||
if ( tracing )
|
if ( tracing )
|
||||||
DumpBlocks();
|
DumpBlocks();
|
||||||
|
@ -88,12 +88,12 @@ void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e,
|
||||||
auto s_oi = s->GetOptInfo();
|
auto s_oi = s->GetOptInfo();
|
||||||
auto stmt_num = s_oi->stmt_num;
|
auto stmt_num = s_oi->stmt_num;
|
||||||
|
|
||||||
if ( usage_regions.size() == 0 )
|
if ( usage_regions.empty() )
|
||||||
{
|
{
|
||||||
// We're seeing this identifier for the first time,
|
// We're seeing this identifier for the first time,
|
||||||
// so we don't have any context or confluence
|
// so we don't have any context or confluence
|
||||||
// information for it. Create its "backstory" region.
|
// information for it. Create its "backstory" region.
|
||||||
ASSERT(confluence_stmts.size() == 0);
|
ASSERT(confluence_stmts.empty());
|
||||||
usage_regions.emplace_back(0, 0, false, NO_DEF);
|
usage_regions.emplace_back(0, 0, false, NO_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ void IDOptInfo::ConfluenceBlockEndsAfter(const Stmt* s, bool no_orig_flow)
|
||||||
{
|
{
|
||||||
auto stmt_num = s->GetOptInfo()->stmt_num;
|
auto stmt_num = s->GetOptInfo()->stmt_num;
|
||||||
|
|
||||||
ASSERT(confluence_stmts.size() > 0);
|
ASSERT(! confluence_stmts.empty());
|
||||||
auto cs = confluence_stmts.back();
|
auto cs = confluence_stmts.back();
|
||||||
auto& pc = pending_confluences[cs];
|
auto& pc = pending_confluences[cs];
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ ExprPtr IDOptInfo::DefExprBefore(const Stmt* s)
|
||||||
|
|
||||||
bool IDOptInfo::IsPossiblyDefinedBefore(int stmt_num)
|
bool IDOptInfo::IsPossiblyDefinedBefore(int stmt_num)
|
||||||
{
|
{
|
||||||
if ( usage_regions.size() == 0 )
|
if ( usage_regions.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return FindRegionBefore(stmt_num).MaybeDefined();
|
return FindRegionBefore(stmt_num).MaybeDefined();
|
||||||
|
@ -442,7 +442,7 @@ bool IDOptInfo::IsPossiblyDefinedBefore(int stmt_num)
|
||||||
|
|
||||||
bool IDOptInfo::IsDefinedBefore(int stmt_num)
|
bool IDOptInfo::IsDefinedBefore(int stmt_num)
|
||||||
{
|
{
|
||||||
if ( usage_regions.size() == 0 )
|
if ( usage_regions.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return FindRegionBefore(stmt_num).DefinedAfter() != NO_DEF;
|
return FindRegionBefore(stmt_num).DefinedAfter() != NO_DEF;
|
||||||
|
@ -450,7 +450,7 @@ bool IDOptInfo::IsDefinedBefore(int stmt_num)
|
||||||
|
|
||||||
int IDOptInfo::DefinitionBefore(int stmt_num)
|
int IDOptInfo::DefinitionBefore(int stmt_num)
|
||||||
{
|
{
|
||||||
if ( usage_regions.size() == 0 )
|
if ( usage_regions.empty() )
|
||||||
return NO_DEF;
|
return NO_DEF;
|
||||||
|
|
||||||
return FindRegionBefore(stmt_num).DefinedAfter();
|
return FindRegionBefore(stmt_num).DefinedAfter();
|
||||||
|
@ -458,7 +458,7 @@ int IDOptInfo::DefinitionBefore(int stmt_num)
|
||||||
|
|
||||||
ExprPtr IDOptInfo::DefExprBefore(int stmt_num)
|
ExprPtr IDOptInfo::DefExprBefore(int stmt_num)
|
||||||
{
|
{
|
||||||
if ( usage_regions.size() == 0 )
|
if ( usage_regions.empty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return FindRegionBefore(stmt_num).DefExprAfter();
|
return FindRegionBefore(stmt_num).DefExprAfter();
|
||||||
|
|
|
@ -94,7 +94,7 @@ bool UseDefs::RemoveUnused(int iter)
|
||||||
! CheckIfUnused(s, id.get(), false) )
|
! CheckIfUnused(s, id.get(), false) )
|
||||||
used_ids.emplace_back(id);
|
used_ids.emplace_back(id);
|
||||||
|
|
||||||
if ( used_ids.size() == 0 )
|
if ( used_ids.empty() )
|
||||||
{ // There aren't any ID's to keep.
|
{ // There aren't any ID's to keep.
|
||||||
rc->AddStmtToOmit(s);
|
rc->AddStmtToOmit(s);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -150,7 +150,7 @@ void ZAMCompiler::TallySwitchTargets(const CaseMapsI<T>& switches)
|
||||||
|
|
||||||
bool ZAMCompiler::RemoveDeadCode()
|
bool ZAMCompiler::RemoveDeadCode()
|
||||||
{
|
{
|
||||||
if ( insts1.size() == 0 )
|
if ( insts1.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool did_removal = false;
|
bool did_removal = false;
|
||||||
|
|
|
@ -99,7 +99,7 @@ void ZAMCompiler::ConcretizeBranch(ZInstI* inst, ZInstI* target,
|
||||||
|
|
||||||
if ( target == pending_inst )
|
if ( target == pending_inst )
|
||||||
{
|
{
|
||||||
if ( insts2.size() == 0 )
|
if ( insts2.empty() )
|
||||||
// We're doing this in the context of concretizing
|
// We're doing this in the context of concretizing
|
||||||
// intermediary instructions for dumping them out.
|
// intermediary instructions for dumping them out.
|
||||||
t = insts1.size();
|
t = insts1.size();
|
||||||
|
|
|
@ -188,12 +188,12 @@ void ArgsManager::Differentiate()
|
||||||
|
|
||||||
for ( auto& arg : args )
|
for ( auto& arg : args )
|
||||||
{
|
{
|
||||||
if ( full_decl.size() > 0 )
|
if ( ! full_decl.empty() )
|
||||||
full_decl += ", ";
|
full_decl += ", ";
|
||||||
|
|
||||||
full_decl += arg.decl_type + " " + arg.decl_name;
|
full_decl += arg.decl_type + " " + arg.decl_name;
|
||||||
|
|
||||||
if ( full_params.size() > 0 )
|
if ( ! full_params.empty() )
|
||||||
full_params += ", ";
|
full_params += ", ";
|
||||||
|
|
||||||
full_params += arg.param_name;
|
full_params += arg.param_name;
|
||||||
|
@ -238,7 +238,7 @@ void ZAM_OpTemplate::Build()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auto words = g->SplitIntoWords(line);
|
auto words = g->SplitIntoWords(line);
|
||||||
if ( words.size() == 0 )
|
if ( words.empty() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Parse(words[0], line, words);
|
Parse(words[0], line, words);
|
||||||
|
@ -384,7 +384,7 @@ void ZAM_OpTemplate::Parse(const string& attr, const string& line,
|
||||||
AddEval(g->SkipWords(line, 1));
|
AddEval(g->SkipWords(line, 1));
|
||||||
|
|
||||||
auto addl = GatherEval();
|
auto addl = GatherEval();
|
||||||
if ( addl.size() > 0 )
|
if ( ! addl.empty() )
|
||||||
AddEval(addl);
|
AddEval(addl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ void ZAM_OpTemplate::InstantiateMethodCore(const vector<ZAM_OperandType>& ot,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ot.size() > 0);
|
assert(! ot.empty());
|
||||||
|
|
||||||
string full_suffix = "_" + OpSuffix(ot) + suffix;
|
string full_suffix = "_" + OpSuffix(ot) + suffix;
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ void ZAM_OpTemplate::GenAssignOpCore(const vector<ZAM_OperandType>& ot,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( eval.size() != 0)
|
if ( ! eval.empty() )
|
||||||
g->Gripe("assign-op should not have an \"eval\"", eval);
|
g->Gripe("assign-op should not have an \"eval\"", eval);
|
||||||
|
|
||||||
auto lhs_field = (ot[0] == ZAM_OT_ASSIGN_FIELD);
|
auto lhs_field = (ot[0] == ZAM_OT_ASSIGN_FIELD);
|
||||||
|
@ -1284,7 +1284,7 @@ string EvalInstance::OpMarker() const
|
||||||
void ZAM_ExprOpTemplate::InstantiateEval(const vector<ZAM_OperandType>& ot_orig,
|
void ZAM_ExprOpTemplate::InstantiateEval(const vector<ZAM_OperandType>& ot_orig,
|
||||||
const string& suffix, ZAM_InstClass zc)
|
const string& suffix, ZAM_InstClass zc)
|
||||||
{
|
{
|
||||||
if ( expr_types.size() == 0 )
|
if ( expr_types.empty() )
|
||||||
{ // No operand types to expand over.
|
{ // No operand types to expand over.
|
||||||
ZAM_OpTemplate::InstantiateEval(ot_orig, suffix, zc);
|
ZAM_OpTemplate::InstantiateEval(ot_orig, suffix, zc);
|
||||||
return;
|
return;
|
||||||
|
@ -1775,7 +1775,7 @@ void ZAM_InternalBinaryOpTemplate::InstantiateEval(const vector<ZAM_OperandType>
|
||||||
auto eval = prelude + GetEval();
|
auto eval = prelude + GetEval();
|
||||||
|
|
||||||
auto& ets = ExprTypes();
|
auto& ets = ExprTypes();
|
||||||
if ( ets.size() > 0 )
|
if ( ! ets.empty() )
|
||||||
{
|
{
|
||||||
if ( ets.size() != 1 )
|
if ( ets.size() != 1 )
|
||||||
g->Gripe("internal-binary-op's can have at most one op-type", op_loc);
|
g->Gripe("internal-binary-op's can have at most one op-type", op_loc);
|
||||||
|
@ -1882,7 +1882,7 @@ void ZAM_InternalOpTemplate::Parse(const string& attr, const string& line,
|
||||||
|
|
||||||
bool TemplateInput::ScanLine(string& line)
|
bool TemplateInput::ScanLine(string& line)
|
||||||
{
|
{
|
||||||
if ( put_back.size() > 0 )
|
if ( ! put_back.empty() )
|
||||||
{
|
{
|
||||||
line = put_back;
|
line = put_back;
|
||||||
put_back.clear();
|
put_back.clear();
|
||||||
|
|
|
@ -23,7 +23,7 @@ const ZAMStmt ZAMCompiler::FinishBlock(const ZAMStmt /* start */)
|
||||||
bool ZAMCompiler::NullStmtOK() const
|
bool ZAMCompiler::NullStmtOK() const
|
||||||
{
|
{
|
||||||
// They're okay iff they're the entire statement body.
|
// They're okay iff they're the entire statement body.
|
||||||
return insts1.size() == 0;
|
return insts1.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ZAMStmt ZAMCompiler::EmptyStmt()
|
const ZAMStmt ZAMCompiler::EmptyStmt()
|
||||||
|
|
|
@ -959,7 +959,7 @@ const ZAMStmt ZAMCompiler::CompileReturn(const ReturnStmt* r)
|
||||||
{
|
{
|
||||||
auto e = r->StmtExpr();
|
auto e = r->StmtExpr();
|
||||||
|
|
||||||
if ( retvars.size() == 0 )
|
if ( retvars.empty() )
|
||||||
{ // a "true" return
|
{ // a "true" return
|
||||||
if ( e )
|
if ( e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -273,7 +273,7 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
|
||||||
for ( auto s : managed_slots )
|
for ( auto s : managed_slots )
|
||||||
frame[s].ClearManagedVal();
|
frame[s].ClearManagedVal();
|
||||||
|
|
||||||
if ( table_iters.size() > 0 )
|
if ( ! table_iters.empty() )
|
||||||
{
|
{
|
||||||
local_table_iters =
|
local_table_iters =
|
||||||
std::make_unique<TableIterVec>(table_iters.size());
|
std::make_unique<TableIterVec>(table_iters.size());
|
||||||
|
@ -363,7 +363,7 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
|
||||||
|
|
||||||
void ZBody::ProfileExecution() const
|
void ZBody::ProfileExecution() const
|
||||||
{
|
{
|
||||||
if ( inst_count->size() == 0 )
|
if ( inst_count->empty() )
|
||||||
{
|
{
|
||||||
printf("%s has an empty body\n", func_name);
|
printf("%s has an empty body\n", func_name);
|
||||||
return;
|
return;
|
||||||
|
@ -426,12 +426,12 @@ void ZBody::Dump() const
|
||||||
|
|
||||||
printf("frame[%d] =", i);
|
printf("frame[%d] =", i);
|
||||||
|
|
||||||
if ( d.names.size() > 0 )
|
if ( d.names.empty() )
|
||||||
for ( auto& n : d.names )
|
|
||||||
printf(" %s", n);
|
|
||||||
else
|
|
||||||
for ( auto& id : d.ids )
|
for ( auto& id : d.ids )
|
||||||
printf(" %s", id->Name());
|
printf(" %s", id->Name());
|
||||||
|
else
|
||||||
|
for ( auto& n : d.names )
|
||||||
|
printf(" %s", n);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ string ZInst::VName(int n, int inst_num, const FrameReMap* mappings) const
|
||||||
ASSERT(i > 0);
|
ASSERT(i > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto id = map.names.size() > 0 ? map.names[i-1] : map.ids[i-1]->Name();
|
auto id = map.names.empty() ? map.ids[i-1]->Name() : map.names[i-1];
|
||||||
|
|
||||||
return util::fmt("%d (%s)", slot, id);
|
return util::fmt("%d (%s)", slot, id);
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ bool ZInstI::IsGlobalLoad() const
|
||||||
|
|
||||||
static std::unordered_set<ZOp> global_ops;
|
static std::unordered_set<ZOp> global_ops;
|
||||||
|
|
||||||
if ( global_ops.size() == 0 )
|
if ( global_ops.empty() )
|
||||||
{ // Initialize the set.
|
{ // Initialize the set.
|
||||||
for ( int t = 0; t < NUM_TYPES; ++t )
|
for ( int t = 0; t < NUM_TYPES; ++t )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue