diff --git a/src/ScriptCoverageManager.cc b/src/ScriptCoverageManager.cc index 552f3970c0..ab56f3b793 100644 --- a/src/ScriptCoverageManager.cc +++ b/src/ScriptCoverageManager.cc @@ -127,27 +127,27 @@ bool ScriptCoverageManager::WriteStats() return false; } - for ( list::const_iterator it = stmts.begin(); it != stmts.end(); ++it ) + for ( auto s : stmts ) { ODesc location_info; - (*it)->GetLocationInfo()->Describe(&location_info); + s->GetLocationInfo()->Describe(&location_info); ODesc desc_info; - (*it)->Describe(&desc_info); + s->Describe(&desc_info); string desc(desc_info.Description()); canonicalize_desc cd{delim}; for_each(desc.begin(), desc.end(), cd); pair location_desc(location_info.Description(), desc); if ( usage_map.find(location_desc) != usage_map.end() ) - usage_map[location_desc] += (*it)->GetAccessCount(); + usage_map[location_desc] += s->GetAccessCount(); else - usage_map[location_desc] = (*it)->GetAccessCount(); + usage_map[location_desc] = s->GetAccessCount(); } map, uint64_t>::const_iterator it; - for ( it = usage_map.begin(); it != usage_map.end(); ++it ) + for ( auto& um : usage_map ) { - fprintf(f, "%" PRIu64 "%c%s%c%s\n", it->second, delim, it->first.first.c_str(), delim, - it->first.second.c_str()); + fprintf(f, "%" PRIu64 "%c%s%c%s\n", um.second, delim, um.first.first.c_str(), delim, + um.first.second.c_str()); } fclose(f); diff --git a/src/Stmt.cc b/src/Stmt.cc index 23b3faea4c..c3309f9230 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -258,7 +258,7 @@ ExprListStmt::~ExprListStmt() = default; ValPtr ExprListStmt::Exec(Frame* f, StmtFlowType& flow) { - last_access = run_state::network_time; + RegisterAccess(); flow = FLOW_NEXT; auto vals = eval_list(f, l.get()); @@ -325,7 +325,6 @@ static void print_log(const std::vector& vals) ValPtr PrintStmt::DoExec(std::vector vals, StmtFlowType& /* flow */) { - RegisterAccess(); do_print_stmt(vals); return nullptr; } diff --git a/src/parse.y b/src/parse.y index 240d6017dd..ced76e6269 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1665,28 +1665,33 @@ stmt: { set_location(@1, @4); $$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, make_intrusive()); + script_coverage_mgr.AddStmt($$); } | TOK_IF '(' expr ')' stmt TOK_ELSE stmt { set_location(@1, @4); $$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, {AdoptRef{}, $7}); + script_coverage_mgr.AddStmt($$); } | TOK_SWITCH expr '{' case_list '}' { set_location(@1, @2); $$ = new SwitchStmt({AdoptRef{}, $2}, $4); + script_coverage_mgr.AddStmt($$); } | for_head stmt { $1->AsForStmt()->AddBody({AdoptRef{}, $2}); + script_coverage_mgr.AddStmt($1); } | TOK_WHILE '(' expr ')' stmt { $$ = new WhileStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}); + script_coverage_mgr.AddStmt($$); } | TOK_NEXT ';' opt_no_test @@ -1762,6 +1767,7 @@ stmt: | when_clause { $$ = new WhenStmt($1); + script_coverage_mgr.AddStmt($$); } | index_slice '=' expr ';' opt_no_test @@ -1786,6 +1792,7 @@ stmt: { set_location(@1, @1); $$ = new NullStmt; + script_coverage_mgr.AddStmt($$); } | conditional