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