Skip to content

Commit 1b308af

Browse files
author
thk123
committed
Fixing lint errors in files touched by PR #338
Corrected lint errors in some files as they were touched by #338. There are some outstanding errors that I wasn't sure how to fix: - The formatting of the CBMC help message
1 parent 1029635 commit 1b308af

File tree

4 files changed

+89
-60
lines changed

4 files changed

+89
-60
lines changed

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,12 @@ void record_function_outputs(
109109
code_blockt &init_code,
110110
symbol_tablet &symbol_table)
111111
{
112-
//const code_typet::parameterst &parameters=
113-
// to_code_type(function.type).parameters();
114-
115112
bool has_return_value=
116113
to_code_type(function.type).return_type()!=empty_typet();
117114

118115
if(has_return_value)
119116
{
120-
//record return value
117+
// record return value
121118
codet output(ID_output);
122119
output.operands().resize(2);
123120

@@ -194,7 +191,8 @@ bool ansi_c_entry_point(
194191
forall_symbol_base_map(it, symbol_table.symbol_base_map, config.main)
195192
{
196193
// look it up
197-
symbol_tablet::symbolst::const_iterator s_it=symbol_table.symbols.find(it->second);
194+
symbol_tablet::symbolst::const_iterator s_it=
195+
symbol_table.symbols.find(it->second);
198196

199197
if(s_it==symbol_table.symbols.end()) continue;
200198

@@ -456,7 +454,9 @@ bool ansi_c_entry_point(
456454
const exprt &arg1=parameters[1];
457455

458456
exprt index_expr(ID_index, arg1.type().subtype());
459-
index_expr.copy_to_operands(argv_symbol.symbol_expr(), gen_zero(index_type()));
457+
index_expr.copy_to_operands(
458+
argv_symbol.symbol_expr(),
459+
gen_zero(index_type()));
460460

461461
// disable bounds check on that one
462462
index_expr.set("bounds_check", false);

src/ansi-c/ansi_c_language.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ bool ansi_c_languaget::typecheck(
169169
{
170170
symbol_tablet new_symbol_table;
171171

172-
if(ansi_c_typecheck(parse_tree, new_symbol_table, module, get_message_handler()))
172+
if(ansi_c_typecheck(
173+
parse_tree,
174+
new_symbol_table,
175+
module,
176+
get_message_handler()))
177+
{
173178
return true;
179+
}
174180

175181
remove_internal_symbols(new_symbol_table);
176182

src/cbmc/cbmc_parse_options.cpp

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ void cbmc_parse_optionst::eval_verbosity()
117117
if(cmdline.isset("verbosity"))
118118
{
119119
v=unsafe_string2unsigned(cmdline.get_value("verbosity"));
120-
if(v>10) v=10;
120+
if(v>10)
121+
v=10;
121122
}
122123

123124
ui_message_handler.set_verbosity(v);
@@ -192,8 +193,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
192193
if(cmdline.isset("localize-faults"))
193194
options.set_option("localize-faults", true);
194195
if(cmdline.isset("localize-faults-method"))
195-
options.set_option("localize-faults-method",
196-
cmdline.get_value("localize-faults-method"));
196+
{
197+
options.set_option(
198+
"localize-faults-method",
199+
cmdline.get_value("localize-faults-method"));
200+
}
197201

198202
if(cmdline.isset("unwind"))
199203
options.set_option("unwind", cmdline.get_value("unwind"));
@@ -239,23 +243,29 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
239243
if(cmdline.isset("cover"))
240244
options.set_option("unwinding-assertions", false);
241245
else
242-
options.set_option("unwinding-assertions",
246+
{
247+
options.set_option(
248+
"unwinding-assertions",
243249
cmdline.isset("unwinding-assertions"));
250+
}
244251

245252
// generate unwinding assumptions otherwise
246-
options.set_option("partial-loops",
247-
cmdline.isset("partial-loops"));
253+
options.set_option(
254+
"partial-loops",
255+
cmdline.isset("partial-loops"));
248256

249257
if(options.get_bool_option("partial-loops") &&
250258
options.get_bool_option("unwinding-assertions"))
251259
{
252-
error() << "--partial-loops and --unwinding-assertions must not be given together" << eom;
260+
error() << "--partial-loops and --unwinding-assertions "
261+
<< "must not be given together" << eom;
253262
exit(1); // should contemplate EX_USAGE from sysexits.h
254263
}
255264

256265
// remove unused equations
257-
options.set_option("slice-formula",
258-
cmdline.isset("slice-formula"));
266+
options.set_option(
267+
"slice-formula",
268+
cmdline.isset("slice-formula"));
259269

260270
// simplify if conditions and branches
261271
if(cmdline.isset("no-simplify-if"))
@@ -293,105 +303,108 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
293303
}
294304

295305
if(cmdline.isset("max-node-refinement"))
296-
options.set_option("max-node-refinement", cmdline.get_value("max-node-refinement"));
306+
options.set_option(
307+
"max-node-refinement",
308+
cmdline.get_value("max-node-refinement"));
297309

298310
if(cmdline.isset("aig"))
299311
options.set_option("aig", true);
300312

301313
// SMT Options
302-
bool version_set = false;
314+
bool version_set=false;
303315

304316
if(cmdline.isset("smt1"))
305317
{
306318
options.set_option("smt1", true);
307319
options.set_option("smt2", false);
308-
version_set = true;
320+
version_set=true;
309321
}
310322

311323
if(cmdline.isset("smt2"))
312324
{
313-
options.set_option("smt1", false);// If both are given, smt2 takes precedence
325+
// If both are given, smt2 takes precedence
326+
options.set_option("smt1", false);
314327
options.set_option("smt2", true);
315-
version_set = true;
328+
version_set=true;
316329
}
317330

318331
if(cmdline.isset("fpa"))
319332
options.set_option("fpa", true);
320333

321334

322-
bool solver_set = false;
335+
bool solver_set=false;
323336

324337
if(cmdline.isset("boolector"))
325338
{
326-
options.set_option("boolector", true), solver_set = true;
339+
options.set_option("boolector", true), solver_set=true;
327340
if(!version_set)
328-
options.set_option("smt2", true), version_set = true;
341+
options.set_option("smt2", true), version_set=true;
329342
}
330343

331344
if(cmdline.isset("mathsat"))
332345
{
333-
options.set_option("mathsat", true), solver_set = true;
346+
options.set_option("mathsat", true), solver_set=true;
334347
if(!version_set)
335-
options.set_option("smt2", true), version_set = true;
348+
options.set_option("smt2", true), version_set=true;
336349
}
337350

338351
if(cmdline.isset("cvc3"))
339352
{
340-
options.set_option("cvc3", true), solver_set = true;
353+
options.set_option("cvc3", true), solver_set=true;
341354
if(!version_set)
342-
options.set_option("smt1", true), version_set = true;
355+
options.set_option("smt1", true), version_set=true;
343356
}
344357

345358
if(cmdline.isset("cvc4"))
346359
{
347-
options.set_option("cvc4", true), solver_set = true;
360+
options.set_option("cvc4", true), solver_set=true;
348361
if(!version_set)
349-
options.set_option("smt2", true), version_set = true;
362+
options.set_option("smt2", true), version_set=true;
350363
}
351364

352365
if(cmdline.isset("yices"))
353366
{
354-
options.set_option("yices", true), solver_set = true;
367+
options.set_option("yices", true), solver_set=true;
355368
if(!version_set)
356-
options.set_option("smt2", true), version_set = true;
369+
options.set_option("smt2", true), version_set=true;
357370
}
358371

359372
if(cmdline.isset("z3"))
360373
{
361-
options.set_option("z3", true), solver_set = true;
374+
options.set_option("z3", true), solver_set=true;
362375
if(!version_set)
363-
options.set_option("smt2", true), version_set = true;
376+
options.set_option("smt2", true), version_set=true;
364377
}
365378

366379
if(cmdline.isset("opensmt"))
367380
{
368-
options.set_option("opensmt", true), solver_set = true;
381+
options.set_option("opensmt", true), solver_set=true;
369382
if(!version_set)
370-
options.set_option("smt1", true), version_set = true;
383+
options.set_option("smt1", true), version_set=true;
371384
}
372385

373386
if(version_set && !solver_set)
374387
{
375388
if(cmdline.isset("outfile"))
376389
{
377390
// outfile and no solver should give standard compliant SMT-LIB
378-
options.set_option("generic", true), solver_set = true;
391+
options.set_option("generic", true), solver_set=true;
379392
}
380393
else
381394
{
382395
if(options.get_bool_option("smt1"))
383396
{
384-
options.set_option("boolector", true), solver_set = true;
397+
options.set_option("boolector", true), solver_set=true;
385398
}
386399
else
387400
{
388401
assert(options.get_bool_option("smt2"));
389-
options.set_option("z3", true), solver_set = true;
402+
options.set_option("z3", true), solver_set=true;
390403
}
391404
}
392405
}
393406
// Either have solver and standard version set, or neither.
394-
assert(version_set == solver_set);
407+
assert(version_set==solver_set);
395408

396409
if(cmdline.isset("beautify"))
397410
options.set_option("beautify", true);
@@ -401,8 +414,9 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
401414
else
402415
options.set_option("sat-preprocessor", true);
403416

404-
options.set_option("pretty-names",
405-
!cmdline.isset("no-pretty-names"));
417+
options.set_option(
418+
"pretty-names",
419+
!cmdline.isset("no-pretty-names"));
406420

407421
if(cmdline.isset("outfile"))
408422
options.set_option("outfile", cmdline.get_value("outfile"));
@@ -457,7 +471,6 @@ int cbmc_parse_optionst::doit()
457471

458472
if(cmdline.isset("module") ||
459473
cmdline.isset("gen-interface"))
460-
461474
{
462475
error() << "This version of CBMC has no support for "
463476
" hardware modules. Please use hw-cbmc." << eom;
@@ -514,7 +527,8 @@ int cbmc_parse_optionst::doit()
514527
return 0; // should contemplate EX_OK from sysexits.h
515528
}
516529

517-
if(cmdline.isset("show-reachable-properties")) // may replace --show-properties
530+
// may replace --show-properties
531+
if(cmdline.isset("show-reachable-properties"))
518532
{
519533
const namespacet ns(symbol_table);
520534

@@ -668,11 +682,15 @@ int cbmc_parse_optionst::get_goto_program(
668682

669683
if(!cmdline.args.empty())
670684
{
671-
if(parse()) return 6;
672-
if(typecheck()) return 6;
685+
if(parse())
686+
return 6;
687+
if(typecheck())
688+
return 6;
673689
int get_modules_ret=get_modules(bmc);
674-
if(get_modules_ret!=-1) return get_modules_ret;
675-
if(binaries.empty() && final()) return 6;
690+
if(get_modules_ret!=-1)
691+
return get_modules_ret;
692+
if(binaries.empty() && final())
693+
return 6;
676694

677695
// we no longer need any parse trees or language files
678696
clear_parse();
@@ -685,9 +703,14 @@ int cbmc_parse_optionst::get_goto_program(
685703
{
686704
status() << "Reading GOTO program from file " << eom;
687705

688-
if(read_object_and_link(*it, symbol_table, goto_functions,
689-
get_message_handler()))
706+
if(read_object_and_link(
707+
*it,
708+
symbol_table,
709+
goto_functions,
710+
get_message_handler()))
711+
{
690712
return 6;
713+
}
691714
}
692715

693716
if(!binaries.empty())
@@ -851,7 +874,9 @@ bool cbmc_parse_optionst::process_goto_program(
851874

852875
// remove function pointers
853876
status() << "Removal of function pointers and virtual functions" << eom;
854-
remove_function_pointers(symbol_table, goto_functions,
877+
remove_function_pointers(
878+
symbol_table,
879+
goto_functions,
855880
cmdline.isset("pointer-check"));
856881
remove_virtual_functions(symbol_table, goto_functions);
857882

@@ -887,8 +912,10 @@ bool cbmc_parse_optionst::process_goto_program(
887912
if(cmdline.isset("string-abstraction"))
888913
{
889914
status() << "String Abstraction" << eom;
890-
string_abstraction(symbol_table,
891-
get_message_handler(), goto_functions);
915+
string_abstraction(
916+
symbol_table,
917+
get_message_handler(),
918+
goto_functions);
892919
}
893920

894921
// add failed symbols

src/java_bytecode/java_entry_point.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Author: Daniel Kroening, [email protected]
2121
#include <util/namespace.h>
2222
#include <util/pointer_offset_size.h>
2323
#include <util/i2string.h>
24-
#include <util/prefix.h>
2524
#include <ansi-c/c_types.h>
2625
#include <ansi-c/string_constant.h>
2726

@@ -30,8 +29,6 @@ Author: Daniel Kroening, [email protected]
3029
#include "java_entry_point.h"
3130
#include "java_object_factory.h"
3231

33-
//#include "zero_initializer.h"
34-
3532
#define INITIALIZE CPROVER_PREFIX "initialize"
3633

3734
/*******************************************************************\
@@ -46,8 +43,7 @@ Function: create_initialize
4643
4744
\*******************************************************************/
4845

49-
namespace {
50-
void create_initialize(symbol_tablet &symbol_table)
46+
static void create_initialize(symbol_tablet &symbol_table)
5147
{
5248
symbolt initialize;
5349
initialize.name=INITIALIZE;
@@ -72,7 +68,7 @@ void create_initialize(symbol_tablet &symbol_table)
7268
if(symbol_table.add(initialize))
7369
throw "failed to add "+std::string(INITIALIZE);
7470
}
75-
}
71+
7672

7773
/*******************************************************************\
7874
@@ -217,7 +213,7 @@ void java_record_outputs(
217213

218214
if(has_return_value)
219215
{
220-
//record return value
216+
// record return value
221217
codet output(ID_output);
222218
output.operands().resize(2);
223219

0 commit comments

Comments
 (0)