Skip to content

if function is not in the function map, treat as if it has no body #2636

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 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions regression/goto-instrument/assembly_call_graph_test/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
void* thr(void * arg) {
#ifdef __GNUC__
__asm__ __volatile__ ("mfence": : :"memory");
#elif defined(_MSC_VER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this #else in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a straight copy+paste of the code you put above!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, "in that case" was if we're no longer using anything MSVC-specific

__asm mfence;
#endif
}

int main()
{
thr(0);
}
11 changes: 11 additions & 0 deletions regression/goto-instrument/assembly_call_graph_test/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--reachable-call-graph
main -> thr
__CPROVER__start -> __CPROVER_initialize
__CPROVER__start -> main
thr -> __asm_mfence
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
9 changes: 7 additions & 2 deletions src/analyses/call_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ call_grapht::call_grapht(
{
irep_idt function=pending_stack.top();
pending_stack.pop();
const goto_programt &goto_program=
goto_functions.function_map.at(function).body;

nodes.insert(function);

// if function is not in function_map, assume function has no body
const auto &it = goto_functions.function_map.find(function);
if(it == goto_functions.function_map.end())
continue;

const goto_programt &goto_program = it->second.body;

forall_callsites(
goto_program,
[&](goto_programt::const_targett i_it, const irep_idt &callee)
Expand Down
12 changes: 8 additions & 4 deletions src/goto-programs/slice_global_inits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ void slice_global_inits(goto_modelt &goto_model)
const irep_idt &id = directed_graph[node_idx].function;
if(id == INITIALIZE_FUNCTION)
continue;
const goto_functionst::goto_functiont &goto_function
=goto_functions.function_map.at(id);
const goto_programt &goto_program=goto_function.body;

// assume function has no body if it is not in the function map
const auto &it = goto_functions.function_map.find(id);
if(it == goto_functions.function_map.end())
continue;

const goto_programt &goto_program = it->second.body;

forall_goto_program_instructions(i_it, goto_program)
{
const codet &code=i_it->code;
const codet &code = i_it->code;
find_symbols(code, symbols, true, false);
const exprt &expr = i_it->guard;
find_symbols(expr, symbols, true, false);
Expand Down