@@ -64,6 +64,7 @@ SCENARIO("call_graph",
64
64
// }
65
65
// void C() { }
66
66
// void D() { }
67
+ // void E() { }
67
68
68
69
goto_modelt goto_model;
69
70
code_typet void_function_type;
@@ -101,6 +102,8 @@ SCENARIO("call_graph",
101
102
create_void_function_symbol (" C" , code_skipt ()));
102
103
goto_model.symbol_table .add (
103
104
create_void_function_symbol (" D" , code_skipt ()));
105
+ goto_model.symbol_table .add (
106
+ create_void_function_symbol (" E" , code_skipt ()));
104
107
105
108
stream_message_handlert msg (std::cout);
106
109
goto_convert (goto_model, msg);
@@ -111,7 +114,7 @@ SCENARIO("call_graph",
111
114
{
112
115
THEN (" We expect A -> { A, B, B }, B -> { C, D }" )
113
116
{
114
- const auto &check_graph=call_graph_from_goto_functions.graph ;
117
+ const auto &check_graph=call_graph_from_goto_functions.edges ;
115
118
REQUIRE (check_graph.size ()==5 );
116
119
REQUIRE (multimap_key_matches (check_graph, " A" , {" A" , " B" , " B" }));
117
120
REQUIRE (multimap_key_matches (check_graph, " B" , {" C" , " D" }));
@@ -128,7 +131,7 @@ SCENARIO("call_graph",
128
131
call_graph_from_goto_functions.get_inverted ();
129
132
THEN (" We expect A -> { A }, B -> { A, A }, C -> { B }, D -> { B }" )
130
133
{
131
- const auto &check_graph=inverse_call_graph_from_goto_functions.graph ;
134
+ const auto &check_graph=inverse_call_graph_from_goto_functions.edges ;
132
135
REQUIRE (check_graph.size ()==5 );
133
136
REQUIRE (multimap_key_matches (check_graph, " A" , {" A" }));
134
137
REQUIRE (multimap_key_matches (check_graph, " B" , {" A" , " A" }));
@@ -143,9 +146,9 @@ SCENARIO("call_graph",
143
146
THEN (" We expect two callsites for the A -> B edge, one for all others" )
144
147
{
145
148
const auto &check_callsites=call_graph_from_goto_functions.callsites ;
146
- for (const auto &edge : call_graph_from_goto_functions.graph )
149
+ for (const auto &edge : call_graph_from_goto_functions.edges )
147
150
{
148
- if (edge==call_grapht::grapht ::value_type (" A" , " B" ))
151
+ if (edge==call_grapht::edgest ::value_type (" A" , " B" ))
149
152
REQUIRE (check_callsites.at (edge).size ()==2 );
150
153
else
151
154
REQUIRE (check_callsites.at (edge).size ()==1 );
@@ -167,7 +170,7 @@ SCENARIO("call_graph",
167
170
call_grapht::create_from_root_function (goto_model, " B" , false );
168
171
THEN (" We expect only B -> C and B -> D in the resulting graph" )
169
172
{
170
- const auto &check_graph=call_graph_from_b.graph ;
173
+ const auto &check_graph=call_graph_from_b.edges ;
171
174
REQUIRE (check_graph.size ()==2 );
172
175
REQUIRE (multimap_key_matches (check_graph, " B" , {" C" , " D" }));
173
176
}
@@ -183,6 +186,11 @@ SCENARIO("call_graph",
183
186
for (node_indext i=0 ; i<exported.size (); ++i)
184
187
nodes_by_name[exported[i].function ]=i;
185
188
189
+ THEN (" We expect 5 nodes" )
190
+ {
191
+ REQUIRE (exported.size () == 5 );
192
+ }
193
+
186
194
THEN (" We expect edges A -> { A, B }, B -> { C, D }" )
187
195
{
188
196
// Note that means the extra A -> B edge has gone away (the grapht
@@ -228,6 +236,14 @@ SCENARIO("call_graph",
228
236
REQUIRE (predecessors.count (" B" ));
229
237
REQUIRE (predecessors.count (" D" ));
230
238
}
239
+
240
+ THEN (" We expect {E} to be able to reach E" )
241
+ {
242
+ std::set<irep_idt> predecessors =
243
+ get_reaching_functions (exported, " E" );
244
+ REQUIRE (predecessors.size () == 1 );
245
+ REQUIRE (predecessors.count (" E" ));
246
+ }
231
247
}
232
248
233
249
WHEN (" The call graph, with call sites, is exported as a grapht" )
@@ -241,6 +257,11 @@ SCENARIO("call_graph",
241
257
for (node_indext i=0 ; i<exported.size (); ++i)
242
258
nodes_by_name[exported[i].function ]=i;
243
259
260
+ THEN (" We expect 5 nodes" )
261
+ {
262
+ REQUIRE (exported.size () == 5 );
263
+ }
264
+
244
265
THEN (" We expect edges A -> { A, B }, B -> { C, D }" )
245
266
{
246
267
// Note that means the extra A -> B edge has gone away (the grapht
0 commit comments