@@ -348,9 +348,9 @@ static void add_equations_for_symbol_resolution(
348
348
else if (
349
349
lhs.type ().id () != ID_pointer && has_char_pointer_subtype (lhs.type (), ns))
350
350
{
351
- if (rhs.type ().id () == ID_struct)
351
+ if (rhs.type ().id () == ID_struct || rhs. type (). id () == ID_struct_tag )
352
352
{
353
- const struct_typet &struct_type = to_struct_type (rhs.type ());
353
+ const struct_typet &struct_type = to_struct_type (ns. follow ( rhs.type () ));
354
354
for (const auto &comp : struct_type.components ())
355
355
{
356
356
if (is_char_pointer_type (comp.type ()))
@@ -374,20 +374,22 @@ static void add_equations_for_symbol_resolution(
374
374
// / This is meant to be used on the lhs of an equation with string subtype.
375
375
// / \param lhs: expression which is either of string type, or a symbol
376
376
// / representing a struct with some string members
377
+ // / \param ns: namespace to resolve type tags
377
378
// / \return if lhs is a string return this string, if it is a struct return the
378
379
// / members of the expression that have string type.
379
- static std::vector<exprt> extract_strings_from_lhs (const exprt &lhs)
380
+ static std::vector<exprt>
381
+ extract_strings_from_lhs (const exprt &lhs, const namespacet &ns)
380
382
{
381
383
std::vector<exprt> result;
382
384
if (lhs.type () == string_typet ())
383
385
result.push_back (lhs);
384
- else if (lhs.type ().id () == ID_struct)
386
+ else if (lhs.type ().id () == ID_struct || lhs. type (). id () == ID_struct_tag )
385
387
{
386
- const struct_typet &struct_type = to_struct_type (lhs.type ());
388
+ const struct_typet &struct_type = to_struct_type (ns. follow ( lhs.type () ));
387
389
for (const auto &comp : struct_type.components ())
388
390
{
389
391
const std::vector<exprt> strings_in_comp = extract_strings_from_lhs (
390
- member_exprt (lhs, comp.get_name (), comp.type ()));
392
+ member_exprt (lhs, comp.get_name (), comp.type ()), ns );
391
393
result.insert (
392
394
result.end (), strings_in_comp.begin (), strings_in_comp.end ());
393
395
}
@@ -396,10 +398,12 @@ static std::vector<exprt> extract_strings_from_lhs(const exprt &lhs)
396
398
}
397
399
398
400
// / \param expr: an expression
401
+ // / \param ns: namespace to resolve type tags
399
402
// / \return all subexpressions of type string which are not if_exprt expressions
400
403
// / this includes expressions of the form `e.x` if e is a symbol subexpression
401
404
// / with a field `x` of type string
402
- static std::vector<exprt> extract_strings (const exprt &expr)
405
+ static std::vector<exprt>
406
+ extract_strings (const exprt &expr, const namespacet &ns)
403
407
{
404
408
std::vector<exprt> result;
405
409
for (auto it = expr.depth_begin (); it != expr.depth_end ();)
@@ -411,7 +415,7 @@ static std::vector<exprt> extract_strings(const exprt &expr)
411
415
}
412
416
else if (it->id () == ID_symbol)
413
417
{
414
- for (const exprt &e : extract_strings_from_lhs (*it))
418
+ for (const exprt &e : extract_strings_from_lhs (*it, ns ))
415
419
result.push_back (e);
416
420
it.next_sibling_or_parent ();
417
421
}
@@ -438,9 +442,12 @@ static void add_string_equation_to_symbol_resolution(
438
442
}
439
443
else if (has_subtype (eq.lhs ().type (), ID_string, ns))
440
444
{
441
- if (eq.rhs ().type ().id () == ID_struct)
445
+ if (
446
+ eq.rhs ().type ().id () == ID_struct ||
447
+ eq.rhs ().type ().id () == ID_struct_tag)
442
448
{
443
- const struct_typet &struct_type = to_struct_type (eq.rhs ().type ());
449
+ const struct_typet &struct_type =
450
+ to_struct_type (ns.follow (eq.rhs ().type ()));
444
451
for (const auto &comp : struct_type.components ())
445
452
{
446
453
const member_exprt lhs_data (eq.lhs (), comp.get_name (), comp.type ());
@@ -484,15 +491,15 @@ union_find_replacet string_identifiers_resolution_from_equations(
484
491
if (required_equations.insert (i).second )
485
492
equations_to_treat.push (i);
486
493
487
- std::vector<exprt> rhs_strings = extract_strings (eq.rhs ());
494
+ std::vector<exprt> rhs_strings = extract_strings (eq.rhs (), ns );
488
495
for (const auto &expr : rhs_strings)
489
496
equation_map.add (i, expr);
490
497
}
491
498
else if (
492
499
eq.lhs ().type ().id () != ID_pointer &&
493
500
has_subtype (eq.lhs ().type (), ID_string, ns))
494
501
{
495
- std::vector<exprt> lhs_strings = extract_strings_from_lhs (eq.lhs ());
502
+ std::vector<exprt> lhs_strings = extract_strings_from_lhs (eq.lhs (), ns );
496
503
497
504
for (const auto &expr : lhs_strings)
498
505
equation_map.add (i, expr);
@@ -504,7 +511,7 @@ union_find_replacet string_identifiers_resolution_from_equations(
504
511
<< format (eq.lhs ().type ()) << eom;
505
512
}
506
513
507
- for (const exprt &expr : extract_strings (eq.rhs ()))
514
+ for (const exprt &expr : extract_strings (eq.rhs (), ns ))
508
515
equation_map.add (i, expr);
509
516
}
510
517
}
0 commit comments