Skip to content

Commit ddb4f42

Browse files
Added a side effect expr that pushes/pops Java try-catch handlers + irep ids for Java exception handling
These are used to recreate Java try-catch contructs from bytecode.
1 parent ac41f93 commit ddb4f42

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/util/irep_ids.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ java_bytecode_index
738738
java_instanceof
739739
java_super_method_call
740740
java_enum_static_unwind
741+
push_catch
742+
handler
741743
string_constraint
742744
string_not_contains_constraint
743745
cprover_char_literal_func
@@ -800,4 +802,4 @@ cprover_string_to_char_array_func
800802
cprover_string_to_lower_case_func
801803
cprover_string_to_upper_case_func
802804
cprover_string_trim_func
803-
cprover_string_value_of_func
805+
cprover_string_value_of_func

src/util/std_code.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,36 @@ inline const side_effect_expr_throwt &to_side_effect_expr_throw(
11221122
assert(expr.get(ID_statement)==ID_throw);
11231123
return static_cast<const side_effect_expr_throwt &>(expr);
11241124
}
1125+
/*! \brief A side effect that pushes/pops a catch handler
1126+
*/
1127+
class side_effect_expr_catcht:public side_effect_exprt
1128+
{
1129+
public:
1130+
inline side_effect_expr_catcht():side_effect_exprt(ID_push_catch)
1131+
{
1132+
}
1133+
// TODO: change to ID_catch
1134+
inline explicit side_effect_expr_catcht(const irept &exception_list):
1135+
side_effect_exprt(ID_push_catch)
1136+
{
1137+
set(ID_exception_list, exception_list);
1138+
}
1139+
};
1140+
1141+
static inline side_effect_expr_catcht &to_side_effect_expr_catch(exprt &expr)
1142+
{
1143+
assert(expr.id()==ID_side_effect);
1144+
assert(expr.get(ID_statement)==ID_push_catch);
1145+
return static_cast<side_effect_expr_catcht &>(expr);
1146+
}
1147+
1148+
static inline const side_effect_expr_catcht &to_side_effect_expr_catch(
1149+
const exprt &expr)
1150+
{
1151+
assert(expr.id()==ID_side_effect);
1152+
assert(expr.get(ID_statement)==ID_push_catch);
1153+
return static_cast<const side_effect_expr_catcht &>(expr);
1154+
}
11251155

11261156
/*! \brief A try/catch block
11271157
*/

0 commit comments

Comments
 (0)