Skip to content

Use correct function ID for return from function without body #4225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/goto-programs/json_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ void convert_return(
json_call_return["internal"] = jsont::json_boolean(step.internal);
json_call_return["thread"] = json_numbert(std::to_string(step.thread_nr));

const irep_idt &function_identifier =
(step.type == goto_trace_stept::typet::FUNCTION_CALL) ? step.called_function
: step.function_id;
const irep_idt &function_identifier = step.called_function;

const symbolt &symbol = ns.lookup(function_identifier);
json_call_return["function"] =
Expand Down
4 changes: 2 additions & 2 deletions src/goto-programs/xml_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ void convert(
xml_call_return.set_attribute("thread", std::to_string(step.thread_nr));
xml_call_return.set_attribute("step_nr", std::to_string(step.step_nr));

const symbolt &symbol = ns.lookup(step.function_id);
const symbolt &symbol = ns.lookup(step.called_function);
xmlt &xml_function=xml_call_return.new_element("function");
xml_function.set_attribute(
"display_name", id2string(symbol.display_name()));
xml_function.set_attribute("identifier", id2string(step.function_id));
xml_function.set_attribute("identifier", id2string(symbol.name));
xml_function.new_element()=xml(symbol.location);

if(xml_location.name!="")
Expand Down
6 changes: 4 additions & 2 deletions src/goto-symex/symex_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ void goto_symext::symex_function_call_code(
no_body(identifier);

// record the return
target.function_return(state.guard.as_expr(), state.source, hidden);
target.function_return(
state.guard.as_expr(), identifier, state.source, hidden);

if(call.lhs().is_not_nil())
{
Expand Down Expand Up @@ -374,7 +375,8 @@ void goto_symext::symex_end_of_function(statet &state)
const bool hidden = state.top().hidden_function;

// first record the return
target.function_return(state.guard.as_expr(), state.source, hidden);
target.function_return(
state.guard.as_expr(), state.source.function_id, state.source, hidden);

// then get rid of the frame
pop_frame(state);
Expand Down
8 changes: 6 additions & 2 deletions src/goto-symex/symex_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ class symex_targett

/// Record return from a function.
/// \param guard: Precondition for returning from a function
/// \param function_id: Name of the function from which we return
/// \param source: Pointer to location in the input GOTO program of this
/// \param hidden: Should this step be recorded as hidden?
/// function return
virtual void
function_return(const exprt &guard, const sourcet &source, bool hidden) = 0;
virtual void function_return(
const exprt &guard,
const irep_idt &function_id,
const sourcet &source,
bool hidden) = 0;

/// Record a location.
/// \param guard: Precondition for reaching this location
Expand Down
2 changes: 2 additions & 0 deletions src/goto-symex/symex_target_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ void symex_target_equationt::function_call(

void symex_target_equationt::function_return(
const exprt &guard,
const irep_idt &function_id,
const sourcet &source,
const bool hidden)
{
SSA_steps.emplace_back(source, goto_trace_stept::typet::FUNCTION_RETURN);
SSA_stept &SSA_step=SSA_steps.back();

SSA_step.guard = guard;
SSA_step.called_function = function_id;
SSA_step.hidden = hidden;

merge_ireps(SSA_step);
Expand Down
7 changes: 5 additions & 2 deletions src/goto-symex/symex_target_equation.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ class symex_target_equationt:public symex_targett
bool hidden);

/// \copydoc symex_targett::function_return()
virtual void
function_return(const exprt &guard, const sourcet &source, bool hidden);
virtual void function_return(
const exprt &guard,
const irep_idt &function_id,
const sourcet &source,
bool hidden);

/// \copydoc symex_targett::location()
virtual void location(
Expand Down