@@ -336,44 +336,57 @@ 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
+ 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
- UNREACHABLE;
352
+ stack.emplace_back (if_expr->true_case ());
353
+ stack.emplace_back (if_expr->false_case ());
362
354
}
355
+ else if (const auto string_node = node_at (to_array_string_expr (current)))
356
+ f (*string_node);
357
+ else
358
+ UNREACHABLE;
363
359
}
364
360
}
365
- else if (node.kind == nodet::STRING)
361
+ }
362
+
363
+ void string_dependenciest::for_each_dependency (
364
+ const string_nodet &node,
365
+ std::function<void (const builtin_function_nodet &)> f) const
366
+ {
367
+ std::for_each (
368
+ node.dependencies .begin (),
369
+ node.dependencies .end (),
370
+ [&](const std::size_t &index ) { f (builtin_function_nodes[index ]); });
371
+ }
372
+
373
+ void string_dependenciest::for_each_successor (
374
+ const nodet &node,
375
+ const std::function<void (const nodet &)> &f) const
376
+ {
377
+ if (node.kind == nodet::BUILTIN)
366
378
{
367
- const auto &s_node = string_nodes[node.index ];
368
- std::for_each (
369
- s_node.dependencies .begin (),
370
- s_node.dependencies .end (),
371
- [&](const std::size_t &index ) { // NOLINT
372
- f (nodet (builtin_function_nodes[index ]));
373
- });
379
+ for_each_dependency (
380
+ builtin_function_nodes[node.index ],
381
+ [&](const string_nodet &n) { return f (nodet (n)); });
374
382
}
375
383
else
376
- UNREACHABLE;
384
+ {
385
+ INVARIANT (node.kind == nodet::STRING, " nodes are either BUILTIN or STRING" );
386
+ for_each_dependency (
387
+ string_nodes[node.index ],
388
+ [&](const builtin_function_nodet &n) { return f (nodet (n)); });
389
+ }
377
390
}
378
391
379
392
void string_dependenciest::for_each_node (
0 commit comments