|
32 | 32 | #include <util/simplify_expr.h>
|
33 | 33 | #include <util/std_expr.h>
|
34 | 34 | #include <util/string2int.h>
|
| 35 | +#include <util/string_constant.h> |
35 | 36 |
|
36 | 37 | #include <goto-programs/cfg.h>
|
37 | 38 | #include <goto-programs/class_hierarchy.h>
|
38 | 39 | #include <goto-programs/resolve_inherited_component.h>
|
| 40 | + |
39 | 41 | #include <analyses/cfg_dominators.h>
|
| 42 | +#include <analyses/uncaught_exceptions_analysis.h> |
40 | 43 |
|
41 | 44 | #include <limits>
|
42 | 45 | #include <algorithm>
|
@@ -2248,10 +2251,39 @@ void java_bytecode_convert_methodt::convert_athrow(
|
2248 | 2251 | codet &c,
|
2249 | 2252 | exprt::operandst &results) const
|
2250 | 2253 | {
|
2251 |
| - side_effect_expr_throwt throw_expr; |
2252 |
| - throw_expr.add_source_location() = location; |
2253 |
| - throw_expr.copy_to_operands(op[0]); |
2254 |
| - c = code_expressiont(throw_expr); |
| 2254 | + if( |
| 2255 | + uncaught_exceptions_domaint::get_exception_type(op[0].type()) == |
| 2256 | + "java::java.lang.AssertionError") |
| 2257 | + { |
| 2258 | + // we translate athrow into |
| 2259 | + // ASSERT false; |
| 2260 | + // ASSUME false: |
| 2261 | + code_assertt assert_code; |
| 2262 | + assert_code.assertion() = false_exprt(); |
| 2263 | + source_locationt assert_location = location; // copy |
| 2264 | + assert_location.set_comment("assertion at " + location.as_string()); |
| 2265 | + assert_location.set("user-provided", true); |
| 2266 | + assert_location.set_property_class(ID_assertion); |
| 2267 | + assert_code.add_source_location() = assert_location; |
| 2268 | + |
| 2269 | + code_assumet assume_code; |
| 2270 | + assume_code.assumption() = false_exprt(); |
| 2271 | + source_locationt assume_location = location; // copy |
| 2272 | + assume_location.set("user-provided", true); |
| 2273 | + assume_code.add_source_location() = assume_location; |
| 2274 | + |
| 2275 | + code_blockt ret_block; |
| 2276 | + ret_block.move_to_operands(assert_code); |
| 2277 | + ret_block.move_to_operands(assume_code); |
| 2278 | + c = ret_block; |
| 2279 | + } |
| 2280 | + else |
| 2281 | + { |
| 2282 | + side_effect_expr_throwt throw_expr; |
| 2283 | + throw_expr.add_source_location() = location; |
| 2284 | + throw_expr.copy_to_operands(op[0]); |
| 2285 | + c = code_expressiont(throw_expr); |
| 2286 | + } |
2255 | 2287 | results[0] = op[0];
|
2256 | 2288 | }
|
2257 | 2289 |
|
|
0 commit comments