Skip to content

Commit 713d3fe

Browse files
author
Daniel Kroening
authored
Merge pull request #2636 from polgreen/fix_function_map
if function is not in the function map, treat as if it has no body
2 parents da86bdb + ea2d393 commit 713d3fe

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This is a hack to make the test pass on windows. The way CBMC on
2+
// windows handles assembly code needs to be fixed.
3+
// CBMC doesn't recognise __asm mfence as a function.
4+
5+
#ifndef __GNUC__
6+
void __asm_mfence();
7+
#endif
8+
9+
void* thr(void * arg) {
10+
#ifdef __GNUC__
11+
__asm__ __volatile__ ("mfence": : :"memory");
12+
#else
13+
__asm_mfence();
14+
#endif
15+
}
16+
17+
int main()
18+
{
19+
thr(0);
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--reachable-call-graph
4+
main -> thr
5+
__CPROVER__start -> __CPROVER_initialize
6+
__CPROVER__start -> main
7+
thr -> __asm_mfence
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
11+
^warning: ignoring

src/analyses/call_graph.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,16 @@ call_grapht::call_grapht(
8484
{
8585
irep_idt function=pending_stack.top();
8686
pending_stack.pop();
87-
const goto_programt &goto_program=
88-
goto_functions.function_map.at(function).body;
8987

9088
nodes.insert(function);
9189

90+
// if function is not in function_map, assume function has no body
91+
const auto &it = goto_functions.function_map.find(function);
92+
if(it == goto_functions.function_map.end())
93+
continue;
94+
95+
const goto_programt &goto_program = it->second.body;
96+
9297
forall_callsites(
9398
goto_program,
9499
[&](goto_programt::const_targett i_it, const irep_idt &callee)

src/goto-programs/slice_global_inits.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ void slice_global_inits(goto_modelt &goto_model)
5252
const irep_idt &id = directed_graph[node_idx].function;
5353
if(id == INITIALIZE_FUNCTION)
5454
continue;
55-
const goto_functionst::goto_functiont &goto_function
56-
=goto_functions.function_map.at(id);
57-
const goto_programt &goto_program=goto_function.body;
55+
56+
// assume function has no body if it is not in the function map
57+
const auto &it = goto_functions.function_map.find(id);
58+
if(it == goto_functions.function_map.end())
59+
continue;
60+
61+
const goto_programt &goto_program = it->second.body;
5862

5963
forall_goto_program_instructions(i_it, goto_program)
6064
{
61-
const codet &code=i_it->code;
65+
const codet &code = i_it->code;
6266
find_symbols(code, symbols, true, false);
6367
const exprt &expr = i_it->guard;
6468
find_symbols(expr, symbols, true, false);

0 commit comments

Comments
 (0)