Skip to content

Commit 3dd3877

Browse files
Refactor has_char_pointer_subtype with has_subtype
We reuse has_subtype to simplify the function. Also get rid of the namespace argument that was not used.
1 parent 4699c13 commit 3dd3877

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -345,33 +345,14 @@ bool has_subtype(
345345
}
346346

347347
/// \param type: a type
348-
/// \param ns: namespace
349348
/// \return true if a subtype of `type` is an pointer of characters.
350349
/// The meaning of "subtype" is in the algebraic datatype sense:
351350
/// for example, the subtypes of a struct are the types of its
352351
/// components, the subtype of a pointer is the type it points to,
353352
/// etc...
354-
static bool has_char_pointer_subtype(const typet &type, const namespacet &ns)
353+
static bool has_char_pointer_subtype(const typet &type)
355354
{
356-
if(is_char_pointer_type(type))
357-
return true;
358-
359-
if(type.id() == ID_struct || type.id() == ID_union)
360-
{
361-
const struct_union_typet &struct_type = to_struct_union_type(type);
362-
for(const auto &comp : struct_type.components())
363-
{
364-
if(has_char_pointer_subtype(comp.type(), ns))
365-
return true;
366-
}
367-
}
368-
369-
for(const auto &t : type.subtypes())
370-
{
371-
if(has_char_pointer_subtype(t, ns))
372-
return true;
373-
}
374-
return false;
355+
return has_subtype(type, is_char_pointer_type);
375356
}
376357

377358
/// \param type: a type
@@ -471,7 +452,7 @@ static union_find_replacet generate_symbol_resolution_from_equations(
471452
// function applications can be ignored because they will be replaced
472453
// in the convert_function_application step of dec_solve
473454
}
474-
else if(has_char_pointer_subtype(lhs.type(), ns))
455+
else if(has_char_pointer_subtype(lhs.type()))
475456
{
476457
if(rhs.type().id() == ID_struct)
477458
{

0 commit comments

Comments
 (0)