@@ -615,6 +615,7 @@ void path_symext::function_call_rec(
615
615
thread.call_stack .back ().current_function =function_identifier;
616
616
thread.call_stack .back ().return_location =thread.pc .next_loc ();
617
617
thread.call_stack .back ().return_lhs =call.lhs ();
618
+ thread.call_stack .back ().return_rhs =nil_exprt ();
618
619
619
620
#if 0
620
621
for(loc_reft l=function_entry_point; ; ++l)
@@ -720,9 +721,7 @@ Function: path_symext::return_from_function
720
721
721
722
\*******************************************************************/
722
723
723
- void path_symext::return_from_function (
724
- path_symex_statet &state,
725
- const exprt &return_value)
724
+ void path_symext::return_from_function (path_symex_statet &state)
726
725
{
727
726
path_symex_statet::threadt &thread=state.threads [state.get_current_thread ()];
728
727
@@ -740,9 +739,10 @@ void path_symext::return_from_function(
740
739
thread.pc =thread.call_stack .back ().return_location ;
741
740
742
741
// assign the return value
743
- if (return_value .is_not_nil () &&
742
+ if (thread. call_stack . back (). return_rhs .is_not_nil () &&
744
743
thread.call_stack .back ().return_lhs .is_not_nil ())
745
- assign (state, thread.call_stack .back ().return_lhs , return_value);
744
+ assign (state, thread.call_stack .back ().return_lhs ,
745
+ thread.call_stack .back ().return_rhs );
746
746
747
747
// restore the local variables
748
748
for (path_symex_statet::var_state_mapt::const_iterator
@@ -758,6 +758,30 @@ void path_symext::return_from_function(
758
758
759
759
/* ******************************************************************\
760
760
761
+ Function: path_symext::set_return_value
762
+
763
+ Inputs:
764
+
765
+ Outputs:
766
+
767
+ Purpose:
768
+
769
+ \*******************************************************************/
770
+
771
+ void path_symext::set_return_value (
772
+ path_symex_statet &state,
773
+ const exprt &v)
774
+ {
775
+ path_symex_statet::threadt &thread=
776
+ state.threads [state.get_current_thread ()];
777
+
778
+ // returning from very last function?
779
+ if (!thread.call_stack .empty ())
780
+ thread.call_stack .back ().return_rhs =v;
781
+ }
782
+
783
+ /* ******************************************************************\
784
+
761
785
Function: path_symext::do_goto
762
786
763
787
Inputs:
@@ -892,17 +916,16 @@ void path_symext::operator()(
892
916
case END_FUNCTION:
893
917
// pop the call stack
894
918
state.record_step ();
895
- return_from_function (state, nil_exprt () );
919
+ return_from_function (state);
896
920
break ;
897
921
898
922
case RETURN:
899
- // pop the call stack
900
- {
901
- state.record_step ();
902
- exprt return_val=instruction.code .operands ().size ()==1 ?
903
- instruction.code .op0 ():nil_exprt ();
904
- return_from_function (state, return_val);
905
- }
923
+ // sets the return value
924
+ state.record_step ();
925
+
926
+ if (instruction.code .operands ().size ()==1 )
927
+ set_return_value (state, instruction.code .op0 ());
928
+
906
929
break ;
907
930
908
931
case START_THREAD:
0 commit comments