From 770b779999bbdb2e2b190ae3c0eabcbf86f552f9 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 27 Jun 2018 14:28:59 +0000 Subject: [PATCH] Make skip_typecast widely available --- src/goto-instrument/goto_program2code.cpp | 15 ++++----------- src/util/expr_util.cpp | 8 ++++++++ src/util/expr_util.h | 3 +++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/goto-instrument/goto_program2code.cpp b/src/goto-instrument/goto_program2code.cpp index 4ff366aaa51..9694c2781d1 100644 --- a/src/goto-instrument/goto_program2code.cpp +++ b/src/goto-instrument/goto_program2code.cpp @@ -13,22 +13,15 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include +#include #include +#include +#include +#include #include #include -#include -#include #include -static const exprt &skip_typecast(const exprt &expr) -{ - if(expr.id()!=ID_typecast) - return expr; - - return skip_typecast(to_typecast_expr(expr).op()); -} - void goto_program2codet::operator()() { // labels stored for cleanup diff --git a/src/util/expr_util.cpp b/src/util/expr_util.cpp index b539254859d..8d3c3ca3d59 100644 --- a/src/util/expr_util.cpp +++ b/src/util/expr_util.cpp @@ -201,3 +201,11 @@ if_exprt lift_if(const exprt &src, std::size_t operand_number) return result; } + +const exprt &skip_typecast(const exprt &expr) +{ + if(expr.id()!=ID_typecast) + return expr; + + return skip_typecast(to_typecast_expr(expr).op()); +} diff --git a/src/util/expr_util.h b/src/util/expr_util.h index 1e827ffb9f6..5c7d37b0b95 100644 --- a/src/util/expr_util.h +++ b/src/util/expr_util.h @@ -72,4 +72,7 @@ bool has_subtype(const typet &, const irep_idt &id, const namespacet &); /// lift up an if_exprt one level if_exprt lift_if(const exprt &, std::size_t operand_number); +/// find the expression nested inside typecasts, if any +const exprt &skip_typecast(const exprt &expr); + #endif // CPROVER_UTIL_EXPR_UTIL_H