File tree Expand file tree Collapse file tree 3 files changed +30
-38
lines changed Expand file tree Collapse file tree 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
5555 for (const goto_programt::instructiont &instruction :
5656 goto_program.instructions )
5757 {
58- if (instruction.is_assign ())
58+ if (! instruction.is_assign ())
5959 {
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+ }
6362
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 ();
7066
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 ;
7677 }
7778 }
7879
Original file line number Diff line number Diff line change @@ -501,7 +501,7 @@ Function: remove_const_function_pointerst::try_resolve_expression
501501bool remove_const_function_pointerst::try_resolve_expression (
502502 const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const)
503503{
504- const exprt & simplified_expr=simplify_expr (expr, ns);
504+ exprt simplified_expr=simplify_expr (expr, ns);
505505 bool resolved;
506506 expressionst resolved_expressions;
507507 bool is_resolved_expression_const;
@@ -693,25 +693,19 @@ bool remove_const_function_pointerst::try_resolve_index_of(
693693 try_resolve_expression (
694694 array_entry, array_contents, is_entry_const);
695695
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)
711697 {
712698 LOG (" Failed to resolve array value" , array_entry);
713699 return false ;
714700 }
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+ }
715709 }
716710 }
717711 }
Original file line number Diff line number Diff line change @@ -374,13 +374,10 @@ void remove_function_pointerst::remove_function_pointer(
374374
375375 found_functions=fpr (functions);
376376
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 ());
384381
385382 if (functions.size ()==1 )
386383 {
You can’t perform that action at this time.
0 commit comments