@@ -72,7 +72,7 @@ class java_bytecode_instrumentt:public messaget
72
72
void instrument_code (exprt &expr);
73
73
void add_expr_instrumentation (code_blockt &block, const exprt &expr);
74
74
void prepend_instrumentation (codet &code, code_blockt &instrumentation);
75
- codet instrument_expr (const exprt &expr);
75
+ optionalt< codet> instrument_expr (const exprt &expr);
76
76
};
77
77
78
78
const std::vector<std::string> exception_needed_classes = { // NOLINT
@@ -328,13 +328,12 @@ void java_bytecode_instrumentt::add_expr_instrumentation(
328
328
code_blockt &block,
329
329
const exprt &expr)
330
330
{
331
- codet expr_instrumentation=instrument_expr (expr);
332
- if (expr_instrumentation!=code_skipt ())
331
+ if (optionalt<codet> expr_instrumentation = instrument_expr (expr))
333
332
{
334
- if (expr_instrumentation. get_statement ()== ID_block)
335
- block.append (to_code_block (expr_instrumentation));
333
+ if (expr_instrumentation-> get_statement () == ID_block)
334
+ block.append (to_code_block (* expr_instrumentation));
336
335
else
337
- block.move_to_operands (expr_instrumentation);
336
+ block.move_to_operands (* expr_instrumentation);
338
337
}
339
338
}
340
339
@@ -475,17 +474,15 @@ void java_bytecode_instrumentt::instrument_code(exprt &expr)
475
474
// / either assertions or runtime exceptions.
476
475
// / \param expr: the expression for which we compute
477
476
// / instrumentation
478
- // / \return: The instrumentation required for `expr`
479
- codet java_bytecode_instrumentt::instrument_expr (
480
- const exprt &expr)
477
+ // / \return: The instrumentation for `expr` if required
478
+ optionalt<codet> java_bytecode_instrumentt::instrument_expr (const exprt &expr)
481
479
{
482
480
code_blockt result;
483
481
// First check our operands:
484
482
forall_operands (it, expr)
485
483
{
486
- codet op_result=instrument_expr (*it);
487
- if (op_result!=code_skipt ())
488
- result.move_to_operands (op_result);
484
+ if (optionalt<codet> op_result = instrument_expr (*it))
485
+ result.move_to_operands (*op_result);
489
486
}
490
487
491
488
// Add any check due at this node:
@@ -556,7 +553,7 @@ codet java_bytecode_instrumentt::instrument_expr(
556
553
}
557
554
558
555
if (result==code_blockt ())
559
- return code_skipt () ;
556
+ return {} ;
560
557
else
561
558
return result;
562
559
}
0 commit comments