19
19
20
20
#include " path_symex.h"
21
21
22
- // #define DEBUG
22
+ // #define DEBUG
23
23
24
24
#ifdef DEBUG
25
25
#include < iostream>
@@ -133,26 +133,31 @@ bool path_symext::propagate(const exprt &src)
133
133
else if (src.id ()==ID_plus)
134
134
{
135
135
forall_operands (it, src)
136
- if (!propagate (*it)) return false ;
136
+ if (!propagate (*it))
137
+ return false ;
137
138
return true ;
138
139
}
139
140
else if (src.id ()==ID_array)
140
141
{
141
142
forall_operands (it, src)
142
- if (!propagate (*it)) return false ;
143
+ if (!propagate (*it))
144
+ return false ;
143
145
return true ;
144
146
}
145
147
else if (src.id ()==ID_vector)
146
148
{
147
149
forall_operands (it, src)
148
- if (!propagate (*it)) return false ;
150
+ if (!propagate (*it))
151
+ return false ;
149
152
return true ;
150
153
}
151
154
else if (src.id ()==ID_if)
152
155
{
153
156
const if_exprt &if_expr=to_if_expr (src);
154
- if (!propagate (if_expr.true_case ())) return false ;
155
- if (!propagate (if_expr.false_case ())) return false ;
157
+ if (!propagate (if_expr.true_case ()) ||
158
+ !propagate (if_expr.false_case ()))
159
+ return false ;
160
+
156
161
return true ;
157
162
}
158
163
else if (src.id ()==ID_array_of)
@@ -244,7 +249,8 @@ inline static typet c_sizeof_type_rec(const exprt &expr)
244
249
forall_operands (it, expr)
245
250
{
246
251
typet t=c_sizeof_type_rec (*it);
247
- if (t.is_not_nil ()) return t;
252
+ if (t.is_not_nil ())
253
+ return t;
248
254
}
249
255
}
250
256
@@ -298,7 +304,8 @@ void path_symext::symex_malloc(
298
304
mp_integer elements=alloc_size/elem_size;
299
305
300
306
if (elements*elem_size==alloc_size)
301
- object_type=array_typet (tmp_type, from_integer (elements, tmp_size.type ()));
307
+ object_type=
308
+ array_typet (tmp_type, from_integer (elements, tmp_size.type ()));
302
309
}
303
310
}
304
311
}
@@ -323,8 +330,6 @@ void path_symext::symex_malloc(
323
330
size_symbol.type =tmp_size.type ();
324
331
size_symbol.mode =ID_C;
325
332
326
- // state.var_map(size_symbol.name, suffix, size_symbol.type);
327
-
328
333
assign (state,
329
334
size_symbol.symbol_expr (),
330
335
size);
@@ -336,15 +341,14 @@ void path_symext::symex_malloc(
336
341
// value
337
342
symbolt value_symbol;
338
343
339
- value_symbol.base_name =" dynamic_object" +std::to_string (state.var_map .dynamic_count );
344
+ value_symbol.base_name =
345
+ " dynamic_object" +std::to_string (state.var_map .dynamic_count );
340
346
value_symbol.name =" symex_dynamic::" +id2string (value_symbol.base_name );
341
347
value_symbol.is_lvalue =true ;
342
348
value_symbol.type =object_type;
343
349
value_symbol.type .set (" #dynamic" , true );
344
350
value_symbol.mode =ID_C;
345
351
346
- // state.var_map(value_symbol.name, suffix, value_symbol.type);
347
-
348
352
address_of_exprt rhs;
349
353
350
354
if (object_type.id ()==ID_array)
@@ -385,11 +389,11 @@ void path_symext::assign_rec(
385
389
const exprt &ssa_lhs,
386
390
const exprt &ssa_rhs)
387
391
{
388
- // const typet &ssa_lhs_type=state.var_map.ns.follow(ssa_lhs.type());
392
+ // const typet &ssa_lhs_type=state.var_map.ns.follow(ssa_lhs.type());
389
393
390
394
#ifdef DEBUG
391
395
std::cout << " assign_rec: " << ssa_lhs.pretty () << std::endl;
392
- // std::cout << "ssa_lhs_type: " << ssa_lhs_type.id() << std::endl;
396
+ // std::cout << "ssa_lhs_type: " << ssa_lhs_type.id() << std::endl;
393
397
#endif
394
398
395
399
if (ssa_lhs.id ()==ID_symbol)
@@ -446,7 +450,8 @@ void path_symext::assign_rec(
446
450
state.record_step ();
447
451
path_symex_stept &step=*state.history ;
448
452
449
- if (!guard.empty ()) step.guard =conjunction (guard);
453
+ if (!guard.empty ())
454
+ step.guard =conjunction (guard);
450
455
step.full_lhs =ssa_lhs;
451
456
step.ssa_lhs =new_lhs;
452
457
step.ssa_rhs =ssa_rhs;
@@ -579,7 +584,8 @@ void path_symext::assign_rec(
579
584
{
580
585
exprt new_rhs=
581
586
ssa_rhs.is_nil ()?ssa_rhs:
582
- simplify_expr (member_exprt (ssa_rhs, components[i].get_name (), components[i].type ()),
587
+ simplify_expr (
588
+ member_exprt (ssa_rhs, components[i].get_name (), components[i].type ()),
583
589
state.var_map .ns );
584
590
assign_rec (state, guard, operands[i], new_rhs);
585
591
}
@@ -601,7 +607,11 @@ void path_symext::assign_rec(
601
607
{
602
608
exprt new_rhs=
603
609
ssa_rhs.is_nil ()?ssa_rhs:
604
- simplify_expr (index_exprt (ssa_rhs, from_integer (i, index_type ()), array_type.subtype ()),
610
+ simplify_expr (
611
+ index_exprt (
612
+ ssa_rhs,
613
+ from_integer (i, index_type ()),
614
+ array_type.subtype ()),
605
615
state.var_map .ns );
606
616
assign_rec (state, guard, operands[i], new_rhs);
607
617
}
@@ -618,7 +628,11 @@ void path_symext::assign_rec(
618
628
{
619
629
exprt new_rhs=
620
630
ssa_rhs.is_nil ()?ssa_rhs:
621
- simplify_expr (index_exprt (ssa_rhs, from_integer (i, index_type ()), vector_type.subtype ()),
631
+ simplify_expr (
632
+ index_exprt (
633
+ ssa_rhs,
634
+ from_integer (i, index_type ()),
635
+ vector_type.subtype ()),
622
636
state.var_map .ns );
623
637
assign_rec (state, guard, operands[i], new_rhs);
624
638
}
@@ -670,7 +684,9 @@ void path_symext::function_call_rec(
670
684
state.locs .function_map .find (function_identifier);
671
685
672
686
if (f_it==state.locs .function_map .end ())
673
- throw " failed to find `" +id2string (function_identifier)+" ' in function_map" ;
687
+ throw
688
+ " failed to find `" +id2string (function_identifier)+
689
+ " ' in function_map" ;
674
690
675
691
const locst::function_entryt &function_entry=f_it->second ;
676
692
@@ -690,7 +706,8 @@ void path_symext::function_call_rec(
690
706
}
691
707
692
708
// push a frame on the call stack
693
- path_symex_statet::threadt &thread=state.threads [state.get_current_thread ()];
709
+ path_symex_statet::threadt &thread=
710
+ state.threads [state.get_current_thread ()];
694
711
thread.call_stack .push_back (path_symex_statet::framet ());
695
712
thread.call_stack .back ().current_function =function_identifier;
696
713
thread.call_stack .back ().return_location =thread.pc .next_loc ();
@@ -741,7 +758,7 @@ void path_symext::function_call_rec(
741
758
const if_exprt &if_expr=to_if_expr (function);
742
759
exprt guard=if_expr.cond ();
743
760
744
- if (state.is_lazy ())
761
+ if (state.is_lazy ())
745
762
{
746
763
const exprt &case_expr=state.restore_branch ()?
747
764
if_expr.true_case ():if_expr.false_case ();
@@ -755,7 +772,8 @@ void path_symext::function_call_rec(
755
772
path_symex_statet &false_state=further_states.back ();
756
773
false_state.record_branch_step (false );
757
774
false_state.history ->guard =not_exprt (guard);
758
- function_call_rec (further_states.back (), call, if_expr.false_case (), further_states);
775
+ function_call_rec (
776
+ further_states.back (), call, if_expr.false_case (), further_states);
759
777
}
760
778
761
779
// do the true-case in 'state'
@@ -767,6 +785,7 @@ void path_symext::function_call_rec(
767
785
}
768
786
}
769
787
else
788
+ // NOLINTNEXTLINE(readability/throw) as message is correctly uppercase
770
789
throw " TODO: function_call " +function.id_string ();
771
790
}
772
791
@@ -885,11 +904,10 @@ void path_symext::do_goto(
885
904
#endif
886
905
887
906
#ifdef PATH_SYMEX_FORK
888
- if (pid==- 1 )
889
- // forking failed so continue as if PATH_SYMEX_FORK were undefined
907
+ // forking failed so continue as if PATH_SYMEX_FORK were undefined
908
+ if (pid==- 1 ) // NOLINT(readability/braces)
890
909
#endif
891
910
{
892
-
893
911
#ifdef PATH_SYMEX_LAZY_STATE
894
912
// lazily copy the state into 'further_states'
895
913
further_states.push_back (path_symex_statet::lazy_copy (state));
@@ -905,9 +923,9 @@ void path_symext::do_goto(
905
923
}
906
924
907
925
#ifdef PATH_SYMEX_FORK
908
- if (pid!= 0 )
909
- // parent process (regardless of any possible fork errors)
910
- // should finish to explore all current 'further_states'
926
+ // parent process (regardless of any possible fork errors )
927
+ // should finish to explore all current 'further_states'
928
+ if (pid!= 0 ) // NOLINT(readability/braces)
911
929
#endif
912
930
{
913
931
// branch not taken case
@@ -1016,7 +1034,8 @@ void path_symext::operator()(
1016
1034
1017
1035
// ordering of the following matters due to vector instability
1018
1036
path_symex_statet::threadt &new_thread=state.add_thread ();
1019
- path_symex_statet::threadt &old_thread=state.threads [state.get_current_thread ()];
1037
+ path_symex_statet::threadt &old_thread=
1038
+ state.threads [state.get_current_thread ()];
1020
1039
new_thread.pc =loc.branch_target ;
1021
1040
new_thread.local_vars =old_thread.local_vars ;
1022
1041
}
@@ -1028,7 +1047,7 @@ void path_symext::operator()(
1028
1047
break ;
1029
1048
1030
1049
case GOTO:
1031
- if (state.is_lazy ())
1050
+ if (state.is_lazy ())
1032
1051
do_goto (state, state.restore_branch ());
1033
1052
else
1034
1053
do_goto (state, further_states);
@@ -1042,7 +1061,7 @@ void path_symext::operator()(
1042
1061
1043
1062
case THROW:
1044
1063
state.record_step ();
1045
- throw " THROW not yet implemented" ;
1064
+ throw " THROW not yet implemented" ; // NOLINT(readability/throw)
1046
1065
1047
1066
case ASSUME:
1048
1067
state.record_step ();
@@ -1081,7 +1100,7 @@ void path_symext::operator()(
1081
1100
1082
1101
case ATOMIC_END:
1083
1102
if (!state.inside_atomic_section )
1084
- throw " ATOMIC_END unmatched" ;
1103
+ throw " ATOMIC_END unmatched" ; // NOLINT(readability/throw)
1085
1104
1086
1105
state.record_step ();
1087
1106
state.next_pc ();
@@ -1095,7 +1114,8 @@ void path_symext::operator()(
1095
1114
1096
1115
case FUNCTION_CALL:
1097
1116
state.record_step ();
1098
- function_call (state, to_code_function_call (instruction.code ), further_states);
1117
+ function_call (
1118
+ state, to_code_function_call (instruction.code ), further_states);
1099
1119
break ;
1100
1120
1101
1121
case OTHER:
0 commit comments