36 :
log(message_handler)
41 const std::string &taint_file_name,
45 const std::optional<std::string> &json_file_name);
68 for(goto_programt::instructionst::iterator
69 it=goto_function.body.instructions.begin();
70 it!=goto_function.body.instructions.end();
81 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);
95 std::string suffix = std::string(
100 for(
const auto &p : parents)
101 identifiers.insert(
id2string(p) + suffix);
107 for(
const auto &i : identifiers)
110 i == rule.function_identifier ||
113 "java::" +
id2string(rule.function_identifier) +
":"))
122 log.
debug() <<
"MATCH " << rule.id <<
" on " << identifier
129 bool have_this = !code_type.
parameters().empty() &&
130 code_type.
parameters().front().get_bool(ID_C_this);
145 have_this ? rule.parameter_number : rule.parameter_number - 1;
156 "`this` implies at least one argument in function call");
166 codet code_set_may{ID_set_may};
168 code_set_may.op0() = where;
188 not_exprt(get_may), annotated_location));
194 codet code_clear_may{ID_clear_may};
195 code_clear_may.
operands().resize(2);
196 code_clear_may.op0() = where;
197 code_clear_may.
op1() =
209 if(!insert_before.
empty())
211 goto_function.body.insert_before_swap(it, insert_before);
213 while(!it->is_function_call()) ++it;
216 if(!insert_after.
empty())
218 goto_function.body.destructive_insert(
219 std::next(it), insert_after);
225 const std::string &taint_file_name,
229 const std::optional<std::string> &json_file_name)
234 bool use_json = json_file_name.has_value();
236 log.
status() <<
"Reading taint file '" << taint_file_name <<
"'"
249 taint.output(mstream);
250 mstream << messaget::eom;
261 bool have_entry_point=
273 <<
"we will consider the heads of all functions as reachable"
283 gf_entry.second.body_available() &&
312 custom_bitvector_analysis(goto_functions, ns);
316 custom_bitvector_analysis.
output(ns, goto_functions, std::cout);
322 if(!gf_entry.second.body.has_assertion())
327 if(gf_entry.first ==
"__actual_thread_spawn")
334 if(!i_it->is_assert())
342 if(custom_bitvector_analysis[i_it].has_values.is_false())
345 exprt result = custom_bitvector_analysis.
eval(i_it->condition(), i_it);
354 <<
"******** Function " << symbol.
display_name() <<
'\n';
361 json_stringt(i_it->source_location().get_property_class())},
362 {
"file",
json_stringt(i_it->source_location().get_file())},
369 std::cout << i_it->source_location();
370 if(!i_it->source_location().get_comment().empty())
371 std::cout <<
": " << i_it->source_location().get_comment();
373 if(!i_it->source_location().get_property_class().empty())
374 std::cout <<
" (" << i_it->source_location().get_property_class()
384 std::ofstream json_out(json_file_name.value());
388 log.
error() <<
"Failed to open json output '" << json_file_name.value()
393 log.
status() <<
"Analysis result is written to '"
396 json_out << json_result <<
'\n';
401 catch(
const char *error_msg)
406 catch(
const std::string &error_msg)
413 log.
error() <<
"Caught unexpected error in taint_analysist::operator()"
421 const std::string &taint_file_name,
424 const std::optional<std::string> &json_file_name)
Operator to return the address of an object.
virtual void output(const namespacet &ns, const irep_idt &function_id, const goto_programt &goto_program, std::ostream &out) const
Output the abstract states for a single function.
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Non-graph-based representation of the class hierarchy.
idst get_parents_trans(const irep_idt &id) const
std::vector< irep_idt > idst
goto_instruction_codet representation of a function call statement.
const parameterst & parameters() const
Data structure for representing an arbitrary statement in a program.
exprt eval(const exprt &src, locationt loc)
static bool has_get_must_or_may(const exprt &)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
A collection of goto functions.
function_mapt function_map
::goto_functiont goto_functiont
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
This class represents an instruction in the GOTO intermediate representation.
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
const source_locationt & source_location() const
bool is_function_call() const
const exprt::operandst & call_arguments() const
Get the arguments of a FUNCTION_CALL.
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
static instructiont make_end_function(const source_locationt &l=source_locationt::nil())
instructionst::iterator targett
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
static instructiont make_function_call(const code_function_callt &_code, const source_locationt &l=source_locationt::nil())
Create a function call instruction.
static instructiont make_other(const goto_instruction_codet &_code, const source_locationt &l=source_locationt::nil())
targett add(instructiont &&instruction)
Adds a given instruction at the end.
static instructiont make_goto(targett _target, const source_locationt &l=source_locationt::nil())
bool empty() const
Is the program empty?
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
jsont & push_back(const jsont &json)
Class that provides messages with a built-in verbosity 'level'.
mstreamt & status() const
void conditional_output(mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
Generate output to message_stream using output_generator if the configured verbosity is at least as h...
message_handlert & get_message_handler()
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
A side_effect_exprt that returns a non-deterministically chosen value.
void set_comment(const irep_idt &comment)
void set_property_class(const irep_idt &property_class)
const irep_idt & get_identifier() const
const irep_idt & display_name() const
Return language specific display name if present.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
bool operator()(const std::string &taint_file_name, const symbol_tablet &, goto_functionst &, bool show_full, const std::optional< std::string > &json_file_name)
void instrument(const namespacet &, goto_functionst &)
taint_analysist(message_handlert &message_handler)
class_hierarchyt class_hierarchy
The Boolean constant true.
bool has_prefix(const std::string &s, const std::string &prefix)
Field-insensitive, location-sensitive bitvector analysis.
#define forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
bool is_true(const literalt &l)
API to expression classes for Pointers.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
symbol_exprt return_value_symbol(const irep_idt &identifier, const namespacet &ns)
produces the symbol that is used to store the return value of the function with the given identifier
exprt simplify_expr(exprt src, const namespacet &ns)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
bool taint_analysis(goto_modelt &goto_model, const std::string &taint_file_name, message_handlert &message_handler, bool show_full, const std::optional< std::string > &json_file_name)
bool taint_parser(const std::string &file_name, taint_parse_treet &dest, message_handlert &message_handler)