@@ -336,47 +336,59 @@ bool add_node(
336
336
return true ;
337
337
}
338
338
339
- void string_dependenciest::for_each_successor (
340
- const nodet &node,
341
- const std::function<void (const nodet &)> &f) const
339
+ void string_dependenciest::for_each_dependency (
340
+ const builtin_function_nodet &node,
341
+ const std::function<void (const string_nodet &)> &f) const
342
342
{
343
- if (node. kind == nodet::BUILTIN )
343
+ for ( const auto &s : node. data -> string_arguments () )
344
344
{
345
- const auto &builtin = builtin_function_nodes[node. index ] ;
346
- for ( const auto &s : builtin. data -> string_arguments ())
345
+ std::vector<std::reference_wrapper< const exprt>> stack ({s}) ;
346
+ while (!stack. empty ())
347
347
{
348
- std::vector<std::reference_wrapper<const exprt>> stack ({s});
349
- while (!stack.empty ())
348
+ const auto current = stack.back ();
349
+ stack.pop_back ();
350
+ if (const auto if_expr = expr_try_dynamic_cast<if_exprt>(current.get ()))
350
351
{
351
- const auto current = stack.back ();
352
- stack.pop_back ();
353
- if (const auto if_expr = expr_try_dynamic_cast<if_exprt>(current.get ()))
354
- {
355
- stack.emplace_back (if_expr->true_case ());
356
- stack.emplace_back (if_expr->false_case ());
357
- }
358
- else if (const auto node = node_at (to_array_string_expr (current)))
359
- f (nodet (*node));
360
- else
361
- {
362
- std::cout << " Warning no node for " << format (current) << std::endl;
363
- // UNREACHABLE;
364
- }
352
+ stack.emplace_back (if_expr->true_case ());
353
+ stack.emplace_back (if_expr->false_case ());
354
+ }
355
+ else if (const auto string_node = node_at (to_array_string_expr (current)))
356
+ f (*string_node);
357
+ else
358
+ {
359
+ std::cout << " Warning no node for " << format (current) << std::endl;
360
+ // UNREACHABLE;
365
361
}
366
362
}
367
363
}
368
- else if (node.kind == nodet::STRING)
364
+ }
365
+
366
+ void string_dependenciest::for_each_dependency (
367
+ const string_nodet &node,
368
+ const std::function<void (const builtin_function_nodet &)> &f) const
369
+ {
370
+ for (const std::size_t &index : node.dependencies )
371
+ f (builtin_function_nodes[index ]);
372
+ }
373
+
374
+ void string_dependenciest::for_each_successor (
375
+ const nodet &node,
376
+ const std::function<void (const nodet &)> &f) const
377
+ {
378
+ switch (node.kind )
369
379
{
370
- const auto &s_node = string_nodes[node.index ];
371
- std::for_each (
372
- s_node.dependencies .begin (),
373
- s_node.dependencies .end (),
374
- [&](const std::size_t &index ) { // NOLINT
375
- f (nodet (builtin_function_nodes[index ]));
376
- });
380
+ case nodet::BUILTIN:
381
+ for_each_dependency (
382
+ builtin_function_nodes[node.index ],
383
+ [&](const string_nodet &n) { return f (nodet (n)); });
384
+ break ;
385
+
386
+ case nodet::STRING:
387
+ for_each_dependency (
388
+ string_nodes[node.index ],
389
+ [&](const builtin_function_nodet &n) { return f (nodet (n)); });
390
+ break ;
377
391
}
378
- else
379
- UNREACHABLE;
380
392
}
381
393
382
394
void string_dependenciest::for_each_node (
0 commit comments