void summarizer_fwt::compute_summary_rec(const function_namet &function_name, const exprt &precondition, bool context_sensitive) { local_SSAt &SSA = ssa_db.get(function_name); //TODO: make const // recursively compute summaries for function calls inline_summaries(function_name,SSA,precondition,context_sensitive); status() << "Analyzing function " << function_name << eom; #if 0 { std::ostringstream out; out << "Function body for " << function_name << " to be analyzed: " << std::endl; for(local_SSAt::nodest::iterator n = SSA.nodes.begin(); n!=SSA.nodes.end(); n++) { if(!n->empty()) n->output(out,SSA.ns); } out << "(enable) " << from_expr(SSA.ns, "", SSA.get_enabling_exprs()) << "\n"; debug() << out.str() << eom; } #endif // create summary summaryt summary; summary.params = SSA.params; summary.globals_in = SSA.globals_in; summary.globals_out = SSA.globals_out; summary.fw_precondition = precondition; if(!options.get_bool_option("havoc")) { do_summary(function_name,SSA,summary,true_exprt(),context_sensitive); } if(!options.get_bool_option("competition-mode")) { std::ostringstream out; out << std::endl << "Summary for function " << function_name << std::endl; summary.output(out,SSA.ns); status() << out.str() << eom; } // store summary in db summary_db.put(function_name,summary); }
void summarizer_bwt::compute_summary_rec(const function_namet &function_name, const exprt &postcondition, bool context_sensitive) { local_SSAt &SSA = ssa_db.get(function_name); const summaryt &old_summary = summary_db.get(function_name); // recursively compute summaries for function calls inline_summaries(function_name,SSA,old_summary, postcondition,context_sensitive, options.get_bool_option("sufficient")); status() << "Analyzing function " << function_name << eom; // create summary summaryt summary; summary.params = SSA.params; summary.globals_in = SSA.globals_in; summary.globals_out = SSA.globals_out; summary.bw_postcondition = postcondition; if(!options.get_bool_option("havoc")) { do_summary(function_name,SSA,old_summary,summary,context_sensitive); } // store summary in db summary_db.put(function_name,summary); { std::ostringstream out; out << std::endl << "Summary for function " << function_name << std::endl; summary_db.get(function_name).output(out,SSA.ns); status() << out.str() << eom; } }
void summarizer_fw_termt::compute_summary_rec( const function_namet &function_name, const exprt &precondition, bool context_sensitive) { if(options.get_bool_option("competition-mode") && summary_db.exists(ID__start) && summary_db.get(ID__start).terminates==NO) { return; } local_SSAt &SSA=ssa_db.get(function_name); // recursively compute summaries for function calls threevalt calls_terminate=YES; bool has_function_calls=false; inline_summaries( function_name, SSA, precondition, context_sensitive, calls_terminate, has_function_calls); status() << "Analyzing function " << function_name << eom; { std::ostringstream out; out << "Function body for " << function_name << " to be analyzed: " << std::endl; for(local_SSAt::nodest::iterator n=SSA.nodes.begin(); n!=SSA.nodes.end(); n++) { if(!n->empty()) n->output(out, SSA.ns); } out << "(enable) " << from_expr(SSA.ns, "", SSA.get_enabling_exprs()) << "\n"; debug() << out.str() << eom; } bool has_loops=false; for(local_SSAt::nodest::iterator n_it=SSA.nodes.begin(); n_it!=SSA.nodes.end(); n_it++) { if(n_it->loophead!=SSA.nodes.end()) { has_loops=true; break; } } debug() << "function " << (has_function_calls ? "has" : "does not have") << " function calls" << eom; debug() << "function calls terminate: " << threeval2string(calls_terminate) << eom; debug() << "function " << (has_loops ? "has loops" : "does not have loops") << eom; // create summary summaryt summary; summary.params=SSA.params; summary.globals_in=SSA.globals_in; summary.globals_out=SSA.globals_out; summary.fw_precondition=precondition; summary.terminates=UNKNOWN; // compute summary if(!options.get_bool_option("havoc")) { // We are not allowed to assume the assertions here, // otherwise we might cut off all terminating executions // and classify the program as non-terminating. do_summary(function_name, SSA, summary, true_exprt(), context_sensitive); } // check termination status() << "Computing termination argument for " << function_name << eom; // check non-termination if we haven't analyzed this function yet, // otherwise the termination status is UNKNOWN anyways if(!summary_db.exists(function_name)) { do_nontermination(function_name, SSA, summary); } if(summary.terminates==UNKNOWN) { bool has_terminating_function_calls= has_function_calls && calls_terminate==YES; if(!has_loops && !has_function_calls) { status() << "Function trivially terminates" << eom; summary.terminates=YES; } else if(!has_loops && has_function_calls && calls_terminate==YES) { status() << "Function terminates" << eom; summary.terminates=YES; } else if(has_function_calls && calls_terminate!=YES) { summary.terminates=calls_terminate; } else if(has_loops && (!has_function_calls || has_terminating_function_calls)) { do_termination(function_name, SSA, summary); } } { std::ostringstream out; out << std::endl << "Summary for function " << function_name << std::endl; summary.output(out, SSA.ns); status() << out.str() << eom; } // store summary in db summary_db.put(function_name, summary); }
void summarizer_bw_termt::compute_summary_rec( const function_namet &function_name, const exprt &postcondition, bool context_sensitive) { local_SSAt &SSA=ssa_db.get(function_name); const summaryt &old_summary=summary_db.get(function_name); // recursively compute summaries for function calls inline_summaries( function_name, SSA, old_summary, postcondition, context_sensitive, false); status() << "Analyzing function " << function_name << eom; bool has_loops=false; for(local_SSAt::nodest::iterator n_it=SSA.nodes.begin(); n_it!=SSA.nodes.end(); n_it++) { if(n_it->loophead!=SSA.nodes.end()) { has_loops=true; break; } } debug() << "function " << (has_loops ? "has loops" : "does not have loops") << eom; // create summary summaryt summary; summary.params=SSA.params; summary.globals_in=SSA.globals_in; summary.globals_out=SSA.globals_out; summary.bw_postcondition=postcondition; do_nontermination(function_name, SSA, old_summary, summary); if(!options.get_bool_option("havoc") && summary.terminates!=NO) { if(!has_loops) { do_summary(function_name, SSA, old_summary, summary, context_sensitive); } else { do_summary_term( function_name, SSA, old_summary, summary, context_sensitive); } } // store summary in db summary_db.put(function_name, summary); { std::ostringstream out; out << std::endl << "Summary for function " << function_name << std::endl; summary_db.get(function_name).output(out, SSA.ns); status() << out.str() << eom; } }