Skip to content

Commit 0e2f389

Browse files
author
Daniel Kroening
authored
Merge pull request #376 from tautschnig/lint-cleanup
Code cleanup to increase cpplint-cleanliness
2 parents 29e0f32 + e501a05 commit 0e2f389

File tree

734 files changed

+18121
-13390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

734 files changed

+18121
-13390
lines changed

src/aa-path-symex/path_symex.cpp

+54-34
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Author: Daniel Kroening, [email protected]
1919

2020
#include "path_symex.h"
2121

22-
//#define DEBUG
22+
// #define DEBUG
2323

2424
#ifdef DEBUG
2525
#include <iostream>
@@ -133,26 +133,31 @@ bool path_symext::propagate(const exprt &src)
133133
else if(src.id()==ID_plus)
134134
{
135135
forall_operands(it, src)
136-
if(!propagate(*it)) return false;
136+
if(!propagate(*it))
137+
return false;
137138
return true;
138139
}
139140
else if(src.id()==ID_array)
140141
{
141142
forall_operands(it, src)
142-
if(!propagate(*it)) return false;
143+
if(!propagate(*it))
144+
return false;
143145
return true;
144146
}
145147
else if(src.id()==ID_vector)
146148
{
147149
forall_operands(it, src)
148-
if(!propagate(*it)) return false;
150+
if(!propagate(*it))
151+
return false;
149152
return true;
150153
}
151154
else if(src.id()==ID_if)
152155
{
153156
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+
156161
return true;
157162
}
158163
else if(src.id()==ID_array_of)
@@ -244,7 +249,8 @@ inline static typet c_sizeof_type_rec(const exprt &expr)
244249
forall_operands(it, expr)
245250
{
246251
typet t=c_sizeof_type_rec(*it);
247-
if(t.is_not_nil()) return t;
252+
if(t.is_not_nil())
253+
return t;
248254
}
249255
}
250256

@@ -298,7 +304,8 @@ void path_symext::symex_malloc(
298304
mp_integer elements=alloc_size/elem_size;
299305

300306
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()));
302309
}
303310
}
304311
}
@@ -323,8 +330,6 @@ void path_symext::symex_malloc(
323330
size_symbol.type=tmp_size.type();
324331
size_symbol.mode=ID_C;
325332

326-
//state.var_map(size_symbol.name, suffix, size_symbol.type);
327-
328333
assign(state,
329334
size_symbol.symbol_expr(),
330335
size);
@@ -336,15 +341,14 @@ void path_symext::symex_malloc(
336341
// value
337342
symbolt value_symbol;
338343

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);
340346
value_symbol.name="symex_dynamic::"+id2string(value_symbol.base_name);
341347
value_symbol.is_lvalue=true;
342348
value_symbol.type=object_type;
343349
value_symbol.type.set("#dynamic", true);
344350
value_symbol.mode=ID_C;
345351

346-
//state.var_map(value_symbol.name, suffix, value_symbol.type);
347-
348352
address_of_exprt rhs;
349353

350354
if(object_type.id()==ID_array)
@@ -385,11 +389,11 @@ void path_symext::assign_rec(
385389
const exprt &ssa_lhs,
386390
const exprt &ssa_rhs)
387391
{
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());
389393

390394
#ifdef DEBUG
391395
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;
393397
#endif
394398

395399
if(ssa_lhs.id()==ID_symbol)
@@ -446,7 +450,8 @@ void path_symext::assign_rec(
446450
state.record_step();
447451
path_symex_stept &step=*state.history;
448452

449-
if(!guard.empty()) step.guard=conjunction(guard);
453+
if(!guard.empty())
454+
step.guard=conjunction(guard);
450455
step.full_lhs=ssa_lhs;
451456
step.ssa_lhs=new_lhs;
452457
step.ssa_rhs=ssa_rhs;
@@ -579,7 +584,8 @@ void path_symext::assign_rec(
579584
{
580585
exprt new_rhs=
581586
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()),
583589
state.var_map.ns);
584590
assign_rec(state, guard, operands[i], new_rhs);
585591
}
@@ -601,7 +607,11 @@ void path_symext::assign_rec(
601607
{
602608
exprt new_rhs=
603609
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()),
605615
state.var_map.ns);
606616
assign_rec(state, guard, operands[i], new_rhs);
607617
}
@@ -618,7 +628,11 @@ void path_symext::assign_rec(
618628
{
619629
exprt new_rhs=
620630
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()),
622636
state.var_map.ns);
623637
assign_rec(state, guard, operands[i], new_rhs);
624638
}
@@ -670,7 +684,9 @@ void path_symext::function_call_rec(
670684
state.locs.function_map.find(function_identifier);
671685

672686
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";
674690

675691
const locst::function_entryt &function_entry=f_it->second;
676692

@@ -690,7 +706,8 @@ void path_symext::function_call_rec(
690706
}
691707

692708
// 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()];
694711
thread.call_stack.push_back(path_symex_statet::framet());
695712
thread.call_stack.back().current_function=function_identifier;
696713
thread.call_stack.back().return_location=thread.pc.next_loc();
@@ -741,7 +758,7 @@ void path_symext::function_call_rec(
741758
const if_exprt &if_expr=to_if_expr(function);
742759
exprt guard=if_expr.cond();
743760

744-
if (state.is_lazy())
761+
if(state.is_lazy())
745762
{
746763
const exprt &case_expr=state.restore_branch()?
747764
if_expr.true_case():if_expr.false_case();
@@ -755,7 +772,8 @@ void path_symext::function_call_rec(
755772
path_symex_statet &false_state=further_states.back();
756773
false_state.record_branch_step(false);
757774
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);
759777
}
760778

761779
// do the true-case in 'state'
@@ -767,6 +785,7 @@ void path_symext::function_call_rec(
767785
}
768786
}
769787
else
788+
// NOLINTNEXTLINE(readability/throw) as message is correctly uppercase
770789
throw "TODO: function_call "+function.id_string();
771790
}
772791

@@ -885,11 +904,10 @@ void path_symext::do_goto(
885904
#endif
886905

887906
#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)
890909
#endif
891910
{
892-
893911
#ifdef PATH_SYMEX_LAZY_STATE
894912
// lazily copy the state into 'further_states'
895913
further_states.push_back(path_symex_statet::lazy_copy(state));
@@ -905,9 +923,9 @@ void path_symext::do_goto(
905923
}
906924

907925
#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)
911929
#endif
912930
{
913931
// branch not taken case
@@ -1016,7 +1034,8 @@ void path_symext::operator()(
10161034

10171035
// ordering of the following matters due to vector instability
10181036
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()];
10201039
new_thread.pc=loc.branch_target;
10211040
new_thread.local_vars=old_thread.local_vars;
10221041
}
@@ -1028,7 +1047,7 @@ void path_symext::operator()(
10281047
break;
10291048

10301049
case GOTO:
1031-
if (state.is_lazy())
1050+
if(state.is_lazy())
10321051
do_goto(state, state.restore_branch());
10331052
else
10341053
do_goto(state, further_states);
@@ -1042,7 +1061,7 @@ void path_symext::operator()(
10421061

10431062
case THROW:
10441063
state.record_step();
1045-
throw "THROW not yet implemented";
1064+
throw "THROW not yet implemented"; // NOLINT(readability/throw)
10461065

10471066
case ASSUME:
10481067
state.record_step();
@@ -1081,7 +1100,7 @@ void path_symext::operator()(
10811100

10821101
case ATOMIC_END:
10831102
if(!state.inside_atomic_section)
1084-
throw "ATOMIC_END unmatched";
1103+
throw "ATOMIC_END unmatched"; // NOLINT(readability/throw)
10851104

10861105
state.record_step();
10871106
state.next_pc();
@@ -1095,7 +1114,8 @@ void path_symext::operator()(
10951114

10961115
case FUNCTION_CALL:
10971116
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);
10991119
break;
11001120

11011121
case OTHER:

src/aa-path-symex/path_symex_state.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Author: Daniel Kroening, [email protected]
2020

2121
#include "path_symex_state.h"
2222

23-
//#define DEBUG
23+
// #define DEBUG
2424

2525
#ifdef DEBUG
2626
#include <iostream>
@@ -131,7 +131,8 @@ path_symex_statet::var_statet &path_symex_statet::get_var_state(
131131

132132
var_valt &var_val=
133133
var_info.is_shared()?shared_vars:threads[current_thread].local_vars;
134-
if(var_val.size()<=var_info.number) var_val.resize(var_info.number+1);
134+
if(var_val.size()<=var_info.number)
135+
var_val.resize(var_info.number+1);
135136
return var_val[var_info.number];
136137
}
137138

@@ -150,7 +151,7 @@ Function: path_symex_statet::read
150151
exprt path_symex_statet::read(const exprt &src, bool propagate)
151152
{
152153
#ifdef DEBUG
153-
//std::cout << "path_symex_statet::read " << src.pretty() << std::endl;
154+
// std::cout << "path_symex_statet::read " << src.pretty() << std::endl;
154155
#endif
155156

156157
// This has five phases!
@@ -174,7 +175,7 @@ exprt path_symex_statet::read(const exprt &src, bool propagate)
174175
exprt tmp5=simplify_expr(tmp4, var_map.ns);
175176

176177
#ifdef DEBUG
177-
//std::cout << " ==> " << tmp.pretty() << std::endl;
178+
// std::cout << " ==> " << tmp.pretty() << std::endl;
178179
#endif
179180

180181
return tmp5;
@@ -633,7 +634,8 @@ exprt path_symex_statet::instantiate_rec_address(
633634
{
634635
if_exprt if_expr=to_if_expr(src);
635636
if_expr.true_case()=instantiate_rec_address(if_expr.true_case(), propagate);
636-
if_expr.false_case()=instantiate_rec_address(if_expr.false_case(), propagate);
637+
if_expr.false_case()=
638+
instantiate_rec_address(if_expr.false_case(), propagate);
637639
if_expr.cond()=instantiate_rec(if_expr.cond(), propagate);
638640
return if_expr;
639641
}
@@ -771,7 +773,8 @@ bool path_symex_statet::check_assertion(
771773
exprt assertion=read(instruction.guard);
772774

773775
// trivial?
774-
if(assertion.is_true()) return true; // no error
776+
if(assertion.is_true())
777+
return true; // no error
775778

776779
// the path constraint
777780
decision_procedure << history;

0 commit comments

Comments
 (0)