Skip to content

Commit 1941c6c

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2508 from tautschnig/skip-typecast
Make skip_typecast widely available
2 parents a9e4ce9 + 770b779 commit 1941c6c

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/goto-instrument/goto_program2code.cpp

+4-11
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <sstream>
1515

16-
#include <util/c_types.h>
16+
#include <util/arith_tools.h>
1717
#include <util/config.h>
18+
#include <util/c_types.h>
19+
#include <util/expr_util.h>
20+
#include <util/find_symbols.h>
1821
#include <util/prefix.h>
1922
#include <util/simplify_expr.h>
20-
#include <util/find_symbols.h>
21-
#include <util/arith_tools.h>
2223
#include <util/type_eq.h>
2324

24-
static const exprt &skip_typecast(const exprt &expr)
25-
{
26-
if(expr.id()!=ID_typecast)
27-
return expr;
28-
29-
return skip_typecast(to_typecast_expr(expr).op());
30-
}
31-
3225
void goto_program2codet::operator()()
3326
{
3427
// labels stored for cleanup

src/util/expr_util.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,11 @@ if_exprt lift_if(const exprt &src, std::size_t operand_number)
201201

202202
return result;
203203
}
204+
205+
const exprt &skip_typecast(const exprt &expr)
206+
{
207+
if(expr.id()!=ID_typecast)
208+
return expr;
209+
210+
return skip_typecast(to_typecast_expr(expr).op());
211+
}

src/util/expr_util.h

+3
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ bool has_subtype(const typet &, const irep_idt &id, const namespacet &);
7272
/// lift up an if_exprt one level
7373
if_exprt lift_if(const exprt &, std::size_t operand_number);
7474

75+
/// find the expression nested inside typecasts, if any
76+
const exprt &skip_typecast(const exprt &expr);
77+
7578
#endif // CPROVER_UTIL_EXPR_UTIL_H

0 commit comments

Comments
 (0)