37 const std::string &taint_file_name,
41 const std::string &json_file_name);
63 for(goto_programt::instructionst::iterator
64 it=goto_function.body.instructions.begin();
65 it!=goto_function.body.instructions.end();
68 const goto_programt::instructiont &instruction=*it;
72 switch(instruction.type)
80 if(
function.
id()==ID_symbol)
85 std::set<irep_idt> identifiers;
87 identifiers.insert(identifier);
89 irep_idt class_id=
function.get(ID_C_class);
101 for(
const auto &p : parents)
108 for(
const auto &i : identifiers)
109 if(i==rule.function_identifier ||
112 "java::"+
id2string(rule.function_identifier)+
":"))
120 debug() <<
"MATCH " << rule.id <<
" on " << identifier <<
eom;
128 code_type.
parameters().front().get_bool(ID_C_this);
134 const symbolt &return_value_symbol=
143 have_this?rule.parameter_number:rule.parameter_number-1;
152 assert(!function_call.
arguments().empty());
162 codet code_set_may(
"set_may");
164 code_set_may.
op0()=where;
168 t->make_other(code_set_may);
169 t->source_location=instruction.source_location;
180 t->source_location=instruction.source_location;
181 t->source_location.set_property_class(
183 t->source_location.set_comment(rule.message);
189 codet code_clear_may(
"clear_may");
190 code_clear_may.
operands().resize(2);
191 code_clear_may.
op0()=where;
192 code_clear_may.
op1()=
195 t->make_other(code_clear_may);
196 t->source_location=instruction.source_location;
215 goto_function.body.destructive_insert(next, tmp);
221 const std::string &taint_file_name,
225 const std::string &json_file_name)
230 bool use_json=!json_file_name.empty();
232 status() <<
"Reading taint file `" << taint_file_name
237 error() <<
"Failed to read taint definition file" <<
eom;
242 <<
" taint definitions" <<
eom;
247 status() <<
"Instrumenting taint" <<
eom;
255 bool have_entry_point=
262 status() <<
"Working from entry point" <<
eom;
266 status() <<
"No entry point found; " 267 <<
"we will consider the heads of all functions as reachable" 275 if(f_it->second.body_available() &&
281 t->make_function_call(call);
302 custom_bitvector_analysis(goto_functions, ns);
306 custom_bitvector_analysis.
output(ns, goto_functions, std::cout);
312 if(!f_it->second.body.has_assertion())
317 if(f_it->first==
"__actual_thread_spawn")
324 if(!i_it->is_assert())
329 if(custom_bitvector_analysis[i_it].has_values.is_false())
343 <<
"******** Function " << symbol.
display_name() <<
'\n';
355 json_result.
array.push_back(json);
359 std::cout << i_it->source_location;
360 if(!i_it->source_location.get_comment().empty())
361 std::cout <<
": " << i_it->source_location.get_comment();
363 if(!i_it->source_location.get_property_class().empty())
365 << i_it->source_location.get_property_class() <<
")";
374 std::ofstream json_out(json_file_name);
378 error() <<
"Failed to open json output `" 379 << json_file_name <<
"'" <<
eom;
383 status() <<
"Analysis result is written to `" 384 << json_file_name <<
"'" <<
eom;
386 json_out << json_result <<
'\n';
391 catch(
const char *error_msg)
396 catch(
const std::string &error_msg)
409 const std::string &taint_file_name,
412 const std::string &json_file_name)
Field-insensitive, location-sensitive bitvector analysis.
virtual bool lookup(const irep_idt &name, const symbolt *&symbol) const
targett add_instruction()
Adds an instruction at the end.
const std::string & id2string(const irep_idt &d)
exprt simplify_expr(const exprt &src, const namespacet &ns)
void output(std::ostream &) const
instructionst instructions
The list of instructions in the goto program.
const irep_idt & get_identifier() const
bool empty() const
Is the program empty?
symbol_tablet symbol_table
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
virtual void output(const namespacet &ns, const goto_functionst &goto_functions, std::ostream &out) const
bool taint_analysis(goto_modelt &goto_model, const std::string &taint_file_name, message_handlert &message_handler, bool show_full, const std::string &json_file_name)
class_hierarchyt class_hierarchy
class symbol_exprt symbol_expr() const
produces a symbol_exprt for a symbol
void instrument(const namespacet &, goto_functionst &)
static irep_idt entry_point()
static bool has_get_must_or_may(const exprt &)
A side effect that returns a non-deterministically chosen value.
virtual void set_message_handler(message_handlert &_message_handler)
goto_function_templatet< goto_programt > goto_functiont
Operator to return the address of an object.
function_mapt function_map
bool has_prefix(const std::string &s, const std::string &prefix)
std::vector< irep_idt > idst
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
const irep_idt & display_name() const
bool taint_parser(const std::string &file_name, taint_parse_treet &dest, message_handlert &message_handler)
message_handlert & get_message_handler()
Base class for all expressions.
const parameterst & parameters() const
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
bool operator()(const std::string &taint_file_name, const symbol_tablet &, goto_functionst &, bool show_full, const std::string &json_file_name)
exprt eval(const exprt &src, locationt loc)
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
void destructive_append(goto_program_templatet< codeT, guardT > &p)
Appends the given program, which is destroyed.
A statement in a programming language.
A generic base class for expressions that are predicates, i.e., boolean-typed, and that take exactly ...
#define forall_goto_functions(it, functions)
#define forall_goto_program_instructions(it, program)
message_handlert * message_handler
idst get_parents_trans(const irep_idt &id) const
goto_functionst goto_functions
json_objectt json(const source_locationt &location)
const code_function_callt & to_code_function_call(const codet &code)
instructionst::iterator targett