@@ -27,6 +27,54 @@ Date: December 2016
27
27
28
28
#include < analyses/uncaught_exceptions_analysis.h>
29
29
30
+ // / Lowers high-level exception descriptions into low-level operations suitable
31
+ // / for symex and other analyses that don't understand the THROW or CATCH GOTO
32
+ // / instructions.
33
+ // /
34
+ // / The instructions affected by the lowering are:
35
+ // /
36
+ // / THROW, whose operand must be a code_expressiont wrapping a
37
+ // / side_effect_expr_throwt. This starts propagating an exception, aborting
38
+ // / functions until a suitable catch point is found.
39
+ // /
40
+ // / CATCH with a code_push_catcht operand, which commences a region in which
41
+ // / exceptions should be caught, commonly a try block.
42
+ // / It specifies one or more exception tags to handle
43
+ // / (in instruction->code.exception_list()) and a corresponding GOTO program
44
+ // / target for each (in instruction->targets).
45
+ // / Thrown instructions are currently always matched to tags using
46
+ // / java_instanceof, so a language frontend wanting to use this class
47
+ // / must use exceptions with a Java-compatible structure.
48
+ // /
49
+ // / CATCH with a code_pop_catcht operand terminates a try-block begun by
50
+ // / a code_push_catcht. At present the try block consists of the instructions
51
+ // / between the push and the pop *in program order*, not according to dynamic
52
+ // / control flow, so goto_convert_exceptions must ensure that control-flow
53
+ // / within the try block does not leave this range.
54
+ // /
55
+ // / CATCH with a code_landingpadt operand marks a point where exceptional
56
+ // / control flow terminates and normal control flow resumes, typically the top
57
+ // / of a catch or finally block, and the target of a code_push_catcht
58
+ // / describing the correponding try block. It gives an lvalue expression that
59
+ // / should be assigned the caught exception, typically a local variable.
60
+ // /
61
+ // / FUNCTION_CALL instructions are also affected: if the callee may abort
62
+ // / due to an escaping instruction, a dispatch sequence is inserted to check
63
+ // / whether the callee aborted and propagate the exception further if so.
64
+ // /
65
+ // / Exception propagation is implemented using a global variable per function
66
+ // / (named function_name#exception_value) that carries a reference to an
67
+ // / in-flight exception, or is null during normal control flow.
68
+ // / THROW assigns it a reference to the thrown instance; CALL instructions
69
+ // / copy between the exception_value for the callee and caller, catch_push
70
+ // / and catch_pop instructions indicate how they should be checked to dispatch
71
+ // / the right exception type to the right catch block, and landingpad
72
+ // / instructions copy back to an ordinary local variable (or other expression)
73
+ // / and set #exception_value back to null, indicating the exception has been
74
+ // / caught and normal control flow resumed.
75
+ // /
76
+ // / Note that remove_exceptions introduces java_instanceof comparisons at
77
+ // / present, so a remove_instanceof may be necessary after it completes.
30
78
class remove_exceptionst
31
79
{
32
80
typedef std::vector<std::pair<
0 commit comments