Skip to content

Commit

Permalink
Merge pull request diffblue#2605 from NathanJPhillips/feature/cast-fo…
Browse files Browse the repository at this point in the history
…r-code_typet

Added can_cast_type implementation for code_typet
  • Loading branch information
NathanJPhillips authored Jul 25, 2018
2 parents f6c34f2 + f4f4190 commit dbf4384
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ class code_typet:public typet
}
};

template <>
inline bool can_cast_type<code_typet>(const typet &type)
{
return type.id() == ID_code;
}

/*! \brief Cast a generic typet to a \ref code_typet
*
* This is an unchecked conversion. \a type must be known to be \ref
Expand All @@ -986,7 +992,8 @@ class code_typet:public typet
*/
inline const code_typet &to_code_type(const typet &type)
{
PRECONDITION(type.id()==ID_code);
PRECONDITION(can_cast_type<code_typet>(type));
validate_type(type);
return static_cast<const code_typet &>(type);
}

Expand All @@ -995,10 +1002,12 @@ inline const code_typet &to_code_type(const typet &type)
*/
inline code_typet &to_code_type(typet &type)
{
PRECONDITION(type.id()==ID_code);
PRECONDITION(can_cast_type<code_typet>(type));
validate_type(type);
return static_cast<code_typet &>(type);
}


/*! \brief arrays with given size
*/
class array_typet:public type_with_subtypet
Expand Down

0 comments on commit dbf4384

Please sign in to comment.