diff --git a/src/script_opt/CPP/Types.cc b/src/script_opt/CPP/Types.cc index b6eaeb2564..64e1e4ed24 100644 --- a/src/script_opt/CPP/Types.cc +++ b/src/script_opt/CPP/Types.cc @@ -133,7 +133,7 @@ void CPPCompile::ExpandTypeVar(const TypePtr& t) } auto& script_type_name = t->GetName(); - if ( script_type_name.size() > 0 ) + if ( ! script_type_name.empty() ) AddInit(t, "register_type__CPP(" + tn + ", \"" + script_type_name + "\");"); @@ -181,7 +181,7 @@ void CPPCompile::ExpandEnumTypeVar(const TypePtr& t, string& tn) auto names = et->Names(); 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() ) AddInit(t, string("\tet->AddNameInternal(\"") + diff --git a/src/script_opt/CPP/Vars.cc b/src/script_opt/CPP/Vars.cc index 6e1795123b..76a93ed064 100644 --- a/src/script_opt/CPP/Vars.cc +++ b/src/script_opt/CPP/Vars.cc @@ -54,7 +54,7 @@ bool CPPCompile::CheckForCollisions() // the name either (1) wasn't previously used, or (2) if it // was, it was likewise for an enum or a record. 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 // wasn't previously compiled. continue; diff --git a/src/script_opt/GenIDDefs.cc b/src/script_opt/GenIDDefs.cc index 842a65dd36..36137ffdcc 100644 --- a/src/script_opt/GenIDDefs.cc +++ b/src/script_opt/GenIDDefs.cc @@ -518,7 +518,7 @@ void GenIDDefs::TrackID(const ID* id, const ExprPtr& e) { auto oi = id->GetOptInfo(); - ASSERT(barrier_blocks.size() > 0); + ASSERT(! barrier_blocks.empty()); oi->DefinedAfter(curr_stmt, e, confluence_blocks, barrier_blocks.back()); @@ -529,7 +529,7 @@ void GenIDDefs::TrackID(const ID* id, const ExprPtr& e) // block. modified_IDs[i+1].insert(id); - if ( confluence_blocks.size() == 0 ) + if ( confluence_blocks.empty() ) // This is a definition at the outermost level. modified_IDs[0].insert(id); } diff --git a/src/script_opt/GenRDs.cc b/src/script_opt/GenRDs.cc index 8c59ce4a4d..198fbdc447 100644 --- a/src/script_opt/GenRDs.cc +++ b/src/script_opt/GenRDs.cc @@ -357,7 +357,7 @@ void RD_Decorate::TraverseSwitch(const SwitchStmt* sw) bd->Clear(); body->Traverse(this); - if ( bd->PreRDs().size() > 0 ) + if ( ! bd->PreRDs().empty() ) reporter->InternalError("mispropagation of switch body defs"); if ( body->NoFlowAfter(true) ) @@ -544,7 +544,7 @@ TraversalCode RD_Decorate::PostStmt(const Stmt* s) break; case STMT_BREAK: - if ( block_defs.size() == 0 ) + if ( block_defs.empty() ) { if ( func_flavor == FUNC_FLAVOR_HOOK ) // Treat as a return. diff --git a/src/script_opt/IDOptInfo.cc b/src/script_opt/IDOptInfo.cc index a9c1e5d0fd..7670de5aa2 100644 --- a/src/script_opt/IDOptInfo.cc +++ b/src/script_opt/IDOptInfo.cc @@ -78,7 +78,7 @@ void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e, if ( ! s ) { // This is a definition-upon-entry - ASSERT(usage_regions.size() == 0); + ASSERT(usage_regions.empty()); usage_regions.emplace_back(0, 0, true, 0); if ( tracing ) DumpBlocks(); @@ -88,12 +88,12 @@ void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e, auto s_oi = s->GetOptInfo(); 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, // so we don't have any context or confluence // 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); } @@ -300,7 +300,7 @@ void IDOptInfo::ConfluenceBlockEndsAfter(const Stmt* s, bool no_orig_flow) { auto stmt_num = s->GetOptInfo()->stmt_num; - ASSERT(confluence_stmts.size() > 0); + ASSERT(! confluence_stmts.empty()); auto cs = confluence_stmts.back(); auto& pc = pending_confluences[cs]; @@ -434,7 +434,7 @@ ExprPtr IDOptInfo::DefExprBefore(const Stmt* s) bool IDOptInfo::IsPossiblyDefinedBefore(int stmt_num) { - if ( usage_regions.size() == 0 ) + if ( usage_regions.empty() ) return false; return FindRegionBefore(stmt_num).MaybeDefined(); @@ -442,7 +442,7 @@ bool IDOptInfo::IsPossiblyDefinedBefore(int stmt_num) bool IDOptInfo::IsDefinedBefore(int stmt_num) { - if ( usage_regions.size() == 0 ) + if ( usage_regions.empty() ) return false; return FindRegionBefore(stmt_num).DefinedAfter() != NO_DEF; @@ -450,7 +450,7 @@ bool IDOptInfo::IsDefinedBefore(int stmt_num) int IDOptInfo::DefinitionBefore(int stmt_num) { - if ( usage_regions.size() == 0 ) + if ( usage_regions.empty() ) return NO_DEF; return FindRegionBefore(stmt_num).DefinedAfter(); @@ -458,7 +458,7 @@ int IDOptInfo::DefinitionBefore(int stmt_num) ExprPtr IDOptInfo::DefExprBefore(int stmt_num) { - if ( usage_regions.size() == 0 ) + if ( usage_regions.empty() ) return nullptr; return FindRegionBefore(stmt_num).DefExprAfter(); diff --git a/src/script_opt/UseDefs.cc b/src/script_opt/UseDefs.cc index a30b8cca3b..9b4093af26 100644 --- a/src/script_opt/UseDefs.cc +++ b/src/script_opt/UseDefs.cc @@ -94,7 +94,7 @@ bool UseDefs::RemoveUnused(int iter) ! CheckIfUnused(s, id.get(), false) ) used_ids.emplace_back(id); - if ( used_ids.size() == 0 ) + if ( used_ids.empty() ) { // There aren't any ID's to keep. rc->AddStmtToOmit(s); continue; diff --git a/src/script_opt/ZAM/AM-Opt.cc b/src/script_opt/ZAM/AM-Opt.cc index 6d165a0d2e..a2bd07ead7 100644 --- a/src/script_opt/ZAM/AM-Opt.cc +++ b/src/script_opt/ZAM/AM-Opt.cc @@ -150,7 +150,7 @@ void ZAMCompiler::TallySwitchTargets(const CaseMapsI& switches) bool ZAMCompiler::RemoveDeadCode() { - if ( insts1.size() == 0 ) + if ( insts1.empty() ) return false; bool did_removal = false; diff --git a/src/script_opt/ZAM/Branches.cc b/src/script_opt/ZAM/Branches.cc index 090ab4ade8..36e44e44b3 100644 --- a/src/script_opt/ZAM/Branches.cc +++ b/src/script_opt/ZAM/Branches.cc @@ -99,7 +99,7 @@ void ZAMCompiler::ConcretizeBranch(ZInstI* inst, ZInstI* target, if ( target == pending_inst ) { - if ( insts2.size() == 0 ) + if ( insts2.empty() ) // We're doing this in the context of concretizing // intermediary instructions for dumping them out. t = insts1.size(); diff --git a/src/script_opt/ZAM/Gen-ZAM.cc b/src/script_opt/ZAM/Gen-ZAM.cc index 2f50cb71b1..08823a22d6 100644 --- a/src/script_opt/ZAM/Gen-ZAM.cc +++ b/src/script_opt/ZAM/Gen-ZAM.cc @@ -188,12 +188,12 @@ void ArgsManager::Differentiate() for ( auto& arg : args ) { - if ( full_decl.size() > 0 ) + if ( ! full_decl.empty() ) full_decl += ", "; full_decl += arg.decl_type + " " + arg.decl_name; - if ( full_params.size() > 0 ) + if ( ! full_params.empty() ) full_params += ", "; full_params += arg.param_name; @@ -238,7 +238,7 @@ void ZAM_OpTemplate::Build() break; auto words = g->SplitIntoWords(line); - if ( words.size() == 0 ) + if ( words.empty() ) break; Parse(words[0], line, words); @@ -384,7 +384,7 @@ void ZAM_OpTemplate::Parse(const string& attr, const string& line, AddEval(g->SkipWords(line, 1)); auto addl = GatherEval(); - if ( addl.size() > 0 ) + if ( ! addl.empty() ) AddEval(addl); } @@ -543,7 +543,7 @@ void ZAM_OpTemplate::InstantiateMethodCore(const vector& ot, return; } - assert(ot.size() > 0); + assert(! ot.empty()); string full_suffix = "_" + OpSuffix(ot) + suffix; @@ -673,7 +673,7 @@ void ZAM_OpTemplate::GenAssignOpCore(const vector& ot, return; } - if ( eval.size() != 0) + if ( ! eval.empty() ) g->Gripe("assign-op should not have an \"eval\"", eval); auto lhs_field = (ot[0] == ZAM_OT_ASSIGN_FIELD); @@ -1284,7 +1284,7 @@ string EvalInstance::OpMarker() const void ZAM_ExprOpTemplate::InstantiateEval(const vector& ot_orig, const string& suffix, ZAM_InstClass zc) { - if ( expr_types.size() == 0 ) + if ( expr_types.empty() ) { // No operand types to expand over. ZAM_OpTemplate::InstantiateEval(ot_orig, suffix, zc); return; @@ -1775,7 +1775,7 @@ void ZAM_InternalBinaryOpTemplate::InstantiateEval(const vector auto eval = prelude + GetEval(); auto& ets = ExprTypes(); - if ( ets.size() > 0 ) + if ( ! ets.empty() ) { if ( ets.size() != 1 ) 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) { - if ( put_back.size() > 0 ) + if ( ! put_back.empty() ) { line = put_back; put_back.clear(); diff --git a/src/script_opt/ZAM/Low-Level.cc b/src/script_opt/ZAM/Low-Level.cc index 3b8e177809..51265a4656 100644 --- a/src/script_opt/ZAM/Low-Level.cc +++ b/src/script_opt/ZAM/Low-Level.cc @@ -23,7 +23,7 @@ const ZAMStmt ZAMCompiler::FinishBlock(const ZAMStmt /* start */) bool ZAMCompiler::NullStmtOK() const { // They're okay iff they're the entire statement body. - return insts1.size() == 0; + return insts1.empty(); } const ZAMStmt ZAMCompiler::EmptyStmt() diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index f49b84cdeb..21f670d2e6 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -959,7 +959,7 @@ const ZAMStmt ZAMCompiler::CompileReturn(const ReturnStmt* r) { auto e = r->StmtExpr(); - if ( retvars.size() == 0 ) + if ( retvars.empty() ) { // a "true" return if ( e ) { diff --git a/src/script_opt/ZAM/ZBody.cc b/src/script_opt/ZAM/ZBody.cc index af1e16ba00..dc24aefb8e 100644 --- a/src/script_opt/ZAM/ZBody.cc +++ b/src/script_opt/ZAM/ZBody.cc @@ -273,7 +273,7 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow) for ( auto s : managed_slots ) frame[s].ClearManagedVal(); - if ( table_iters.size() > 0 ) + if ( ! table_iters.empty() ) { local_table_iters = std::make_unique(table_iters.size()); @@ -363,7 +363,7 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow) void ZBody::ProfileExecution() const { - if ( inst_count->size() == 0 ) + if ( inst_count->empty() ) { printf("%s has an empty body\n", func_name); return; @@ -426,12 +426,12 @@ void ZBody::Dump() const printf("frame[%d] =", i); - if ( d.names.size() > 0 ) - for ( auto& n : d.names ) - printf(" %s", n); - else + if ( d.names.empty() ) for ( auto& id : d.ids ) printf(" %s", id->Name()); + else + for ( auto& n : d.names ) + printf(" %s", n); printf("\n"); } diff --git a/src/script_opt/ZAM/ZInst.cc b/src/script_opt/ZAM/ZInst.cc index 77ef429c22..7040510d5c 100644 --- a/src/script_opt/ZAM/ZInst.cc +++ b/src/script_opt/ZAM/ZInst.cc @@ -231,7 +231,7 @@ string ZInst::VName(int n, int inst_num, const FrameReMap* mappings) const 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); } @@ -586,7 +586,7 @@ bool ZInstI::IsGlobalLoad() const static std::unordered_set global_ops; - if ( global_ops.size() == 0 ) + if ( global_ops.empty() ) { // Initialize the set. for ( int t = 0; t < NUM_TYPES; ++t ) {