File tree 3 files changed +30
-38
lines changed
3 files changed +30
-38
lines changed Original file line number Diff line number Diff line change @@ -55,24 +55,25 @@ bool does_remove_constt::operator()() const
55
55
for (const goto_programt::instructiont &instruction :
56
56
goto_program.instructions )
57
57
{
58
- if (instruction.is_assign ())
58
+ if (! instruction.is_assign ())
59
59
{
60
- const code_assignt assign=to_code_assign (instruction.code );
61
- const typet &rhs_type=assign.rhs ().type ();
62
- const typet &lhs_type=assign.lhs ().type ();
60
+ continue ;
61
+ }
63
62
64
- // Compare the types recursively for a point where the rhs is more
65
- // const that the lhs
66
- if (!is_type_at_least_as_const_as (lhs_type, rhs_type))
67
- {
68
- return true ;
69
- }
63
+ const code_assignt &assign=to_code_assign (instruction.code );
64
+ const typet &rhs_type=assign.rhs ().type ();
65
+ const typet &lhs_type=assign.lhs ().type ();
70
66
71
- bool sub_expr_lose_const=does_expr_lose_const (assign.rhs ());
72
- if (sub_expr_lose_const)
73
- {
74
- return true ;
75
- }
67
+ // Compare the types recursively for a point where the rhs is more
68
+ // const that the lhs
69
+ if (!is_type_at_least_as_const_as (lhs_type, rhs_type))
70
+ {
71
+ return true ;
72
+ }
73
+
74
+ if (does_expr_lose_const (assign.rhs ()))
75
+ {
76
+ return true ;
76
77
}
77
78
}
78
79
Original file line number Diff line number Diff line change @@ -501,7 +501,7 @@ Function: remove_const_function_pointerst::try_resolve_expression
501
501
bool remove_const_function_pointerst::try_resolve_expression (
502
502
const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const)
503
503
{
504
- const exprt & simplified_expr=simplify_expr (expr, ns);
504
+ exprt simplified_expr=simplify_expr (expr, ns);
505
505
bool resolved;
506
506
expressionst resolved_expressions;
507
507
bool is_resolved_expression_const;
@@ -693,25 +693,19 @@ bool remove_const_function_pointerst::try_resolve_index_of(
693
693
try_resolve_expression (
694
694
array_entry, array_contents, is_entry_const);
695
695
696
- if (resolved_value)
697
- {
698
- for (const exprt &resolved_array_entry : array_contents)
699
- {
700
- if (resolved_array_entry .is_zero ())
701
- {
702
- continue ;
703
- }
704
- else
705
- {
706
- out_expressions.push_back (resolved_array_entry);
707
- }
708
- }
709
- }
710
- else
696
+ if (!resolved_value)
711
697
{
712
698
LOG (" Failed to resolve array value" , array_entry);
713
699
return false ;
714
700
}
701
+
702
+ for (const exprt &resolved_array_entry : array_contents)
703
+ {
704
+ if (!resolved_array_entry.is_zero ())
705
+ {
706
+ out_expressions.push_back (resolved_array_entry);
707
+ }
708
+ }
715
709
}
716
710
}
717
711
}
Original file line number Diff line number Diff line change @@ -374,13 +374,10 @@ void remove_function_pointerst::remove_function_pointer(
374
374
375
375
found_functions=fpr (functions);
376
376
377
- // Consistency checks
378
- // Reported optimized function pointer call, but didn't find any functions
379
- assert (!found_functions || !functions.empty ());
380
-
381
- // Reported didn't optimize function pointer call, but did find some
382
- // functions to replace with
383
- assert (found_functions || functions.empty ());
377
+ // Either found_functions is true therefore the functions should not
378
+ // be empty
379
+ // Or found_functions is false therefore the functions should be empty
380
+ assert (found_functions != functions.empty ());
384
381
385
382
if (functions.size ()==1 )
386
383
{
You can’t perform that action at this time.
0 commit comments