bool ansi_c_typecheck( exprt &expr, message_handlert &message_handler, const namespacet &ns) { symbol_tablet symbol_table; ansi_c_parse_treet ansi_c_parse_tree; ansi_c_typecheckt ansi_c_typecheck( ansi_c_parse_tree, symbol_table, ns.get_symbol_table(), "", message_handler); try { ansi_c_typecheck.typecheck_expr(expr); } catch(int) { ansi_c_typecheck.error(); } catch(const char *e) { ansi_c_typecheck.error() << e << messaget::eom; } catch(const std::string &e) { ansi_c_typecheck.error() << e << messaget::eom; } return ansi_c_typecheck.get_error_found(); }
void compute_address_taken_in_symbols( std::set<irep_idt> &address_taken) { const symbol_tablet &symbol_table=ns.get_symbol_table(); for(const auto &s : symbol_table.symbols) compute_address_taken_functions(s.second.value, address_taken); }
void compute_address_taken_in_symbols( std::set<irep_idt> &address_taken) { const symbol_tablet &symbol_table=ns.get_symbol_table(); const symbol_tablet::symbolst &s=symbol_table.symbols; for(symbol_tablet::symbolst::const_iterator it=s.begin(); it!=s.end(); ++it) compute_address_taken_functions(it->second.value, address_taken); }
bool xml_typecheck(exprt &expr, std::ostream &err, const namespacet &ns) { symbol_tablet symbol_table; xml_parse_treet xml_parse_tree; #if 0 bool result=false; xml_typecheckt xml_typecheck(xml_parse, symbol_table, ns.get_symbol_table(), "", err); try { xml_typecheck.typecheck_expr(expr); } catch(int e) { result=true; } catch(const char *e) { str << e << std::endl; result=true; } catch(const std::string &e) { str << e << std::endl; result=true; } return result; #endif return true; }
goto_program_coverage_recordt::goto_program_coverage_recordt( const namespacet &ns, goto_functionst::function_mapt::const_iterator gf_it, const symex_coveraget::coveraget &coverage): coverage_recordt("method") { assert(gf_it->second.body_available()); // identify the file name, inlined functions aren't properly // accounted for goto_programt::const_targett end_function= --gf_it->second.body.instructions.end(); assert(end_function->is_end_function()); file_name=end_function->source_location.get_file(); assert(!file_name.empty()); // compute the maximum coverage of individual source-code lines coverage_lines_mapt coverage_lines_map; compute_coverage_lines( gf_it->second.body, file_name, coverage, coverage_lines_map); // <method name="foo" signature="int(int)" line-rate="1.0" branch-rate="1.0"> // <lines> // <line number="23" hits="1" branch="false"/> // <line number="24" hits="1" branch="false"/> // <line number="25" hits="1" branch="false"/> // <line number="26" hits="1" branch="false"/> // <line number="27" hits="1" branch="false"/> // <line number="28" hits="1" branch="false"/> // <line number="29" hits="1" branch="false"/> // <line number="30" hits="1" branch="false"/> // </lines> // </method> xml.set_attribute("name", id2string(gf_it->first)); code_typet sig_type= original_return_type(ns.get_symbol_table(), gf_it->first); if(sig_type.is_nil()) sig_type=gf_it->second.type; xml.set_attribute("signature", from_type(ns, gf_it->first, sig_type)); xml.set_attribute("line-rate", rate_detailed(lines_covered, lines_total)); xml.set_attribute("branch-rate", rate(branches_covered, branches_total)); xmlt &lines=xml.new_element("lines"); for(const auto &cov_line : coverage_lines_map) { xmlt &line=lines.new_element("line"); line.set_attribute("number", std::to_string(cov_line.first)); line.set_attribute("hits", std::to_string(cov_line.second.hits)); if(cov_line.second.conditions.empty()) line.set_attribute("branch", "false"); else { line.set_attribute("branch", "true"); xmlt &conditions=line.new_element("conditions"); std::size_t number=0, total_taken=0; for(const auto &c : cov_line.second.conditions) { // <condition number="0" type="jump" coverage="50%"/> xmlt &condition=conditions.new_element("condition"); condition.set_attribute("number", std::to_string(number++)); condition.set_attribute("type", "jump"); unsigned taken=c.second.false_taken+c.second.true_taken; total_taken+=taken; condition.set_attribute("coverage", rate(taken, 2, true)); } line.set_attribute( "condition-coverage", rate_detailed(total_taken, number*2, true)); } } }