@@ -295,98 +295,112 @@ Function: goto_analyzer_parse_optionst::doit
295
295
296
296
int goto_analyzer_parse_optionst::doit ()
297
297
{
298
- if (cmdline. isset ( " version " ))
298
+ try
299
299
{
300
- std::cout << CBMC_VERSION << std::endl;
301
- return 0 ;
302
- }
300
+ if (cmdline.isset (" version" ))
301
+ {
302
+ std::cout << CBMC_VERSION << std::endl;
303
+ return 0 ;
304
+ }
303
305
304
- //
305
- // command line options
306
- //
306
+ //
307
+ // command line options
308
+ //
309
+
310
+ optionst options;
311
+ get_command_line_options (options);
312
+ eval_verbosity ();
307
313
308
- optionst options;
309
- get_command_line_options (options);
310
- eval_verbosity ();
314
+ //
315
+ // Print a banner
316
+ //
317
+ status () << " GOTO-ANALYSER version " CBMC_VERSION " "
318
+ << sizeof (void *)*8 << " -bit "
319
+ << config.this_architecture () << " "
320
+ << config.this_operating_system () << eom;
311
321
312
- //
313
- // Print a banner
314
- //
315
- status () << " GOTO-ANALYSER version " CBMC_VERSION " "
316
- << sizeof (void *)*8 << " -bit "
317
- << config.this_architecture () << " "
318
- << config.this_operating_system () << eom;
322
+ register_languages ();
319
323
320
- register_languages ( );
324
+ goto_model. set_message_handler ( get_message_handler () );
321
325
322
- goto_model.set_message_handler (get_message_handler ());
326
+ if (goto_model (cmdline.args ))
327
+ return 6 ;
323
328
324
- if (goto_model (cmdline. args ))
325
- return 6 ;
329
+ if (process_goto_program (options ))
330
+ return 6 ;
326
331
327
- if (process_goto_program (options))
328
- return 6 ;
332
+ if (cmdline.isset (" taint" ))
333
+ {
334
+ std::string taint_file=cmdline.get_value (" taint" );
329
335
330
- if (cmdline.isset (" taint" ))
331
- {
332
- std::string taint_file=cmdline.get_value (" taint" );
336
+ if (cmdline.isset (" show-taint" ))
337
+ {
338
+ taint_analysis (goto_model, taint_file, get_message_handler (), true , " " );
339
+ return 0 ;
340
+ }
341
+ else
342
+ {
343
+ std::string json_file=cmdline.get_value (" json" );
344
+ bool result=taint_analysis (
345
+ goto_model,
346
+ taint_file,
347
+ get_message_handler (),
348
+ false ,
349
+ json_file);
350
+ return result?10 :0 ;
351
+ }
352
+ }
333
353
334
- if (cmdline.isset (" show-taint " ))
354
+ if (cmdline.isset (" unreachable-instructions " ))
335
355
{
336
- taint_analysis (goto_model, taint_file, get_message_handler (), true , " " );
356
+ const std::string json_file=cmdline.get_value (" json" );
357
+
358
+ if (json_file.empty ())
359
+ unreachable_instructions (goto_model, false , std::cout);
360
+ else if (json_file==" -" )
361
+ unreachable_instructions (goto_model, true , std::cout);
362
+ else
363
+ {
364
+ std::ofstream ofs (json_file);
365
+ if (!ofs)
366
+ {
367
+ error () << " Failed to open json output `"
368
+ << json_file << " '" << eom;
369
+ return 6 ;
370
+ }
371
+
372
+ unreachable_instructions (goto_model, true , ofs);
373
+ }
374
+
337
375
return 0 ;
338
376
}
339
- else
340
- {
341
- std::string json_file=cmdline.get_value (" json" );
342
- bool result=taint_analysis (
343
- goto_model,
344
- taint_file,
345
- get_message_handler (),
346
- false ,
347
- json_file);
348
- return result?10 :0 ;
349
- }
350
- }
351
-
352
- if (cmdline.isset (" unreachable-instructions" ))
353
- {
354
- const std::string json_file=cmdline.get_value (" json" );
355
377
356
- if (json_file.empty ())
357
- unreachable_instructions (goto_model, false , std::cout);
358
- else if (json_file==" -" )
359
- unreachable_instructions (goto_model, true , std::cout);
360
- else
378
+ if (cmdline.isset (" show-local-may-alias" ))
361
379
{
362
- std::ofstream ofs (json_file);
363
- if (!ofs)
380
+ namespacet ns (goto_model.symbol_table );
381
+
382
+ forall_goto_functions (it, goto_model.goto_functions )
364
383
{
365
- error () << " Failed to open json output `"
366
- << json_file << " '" << eom;
367
- return 6 ;
384
+ std::cout << " >>>>\n " ;
385
+ std::cout << " >>>> " << it->first << ' \n ' ;
386
+ std::cout << " >>>>\n " ;
387
+ local_may_aliast local_may_alias (it->second );
388
+ local_may_alias.output (std::cout, it->second , ns);
389
+ std::cout << ' \n ' ;
368
390
}
369
391
370
- unreachable_instructions (goto_model, true , ofs) ;
392
+ return 0 ;
371
393
}
372
394
373
- return 0 ;
374
- }
375
-
376
- if (cmdline.isset (" show-local-may-alias" ))
377
- {
378
- namespacet ns (goto_model.symbol_table );
395
+ label_properties (goto_model);
379
396
380
- forall_goto_functions (it, goto_model. goto_functions )
397
+ if (cmdline. isset ( " show-properties " ) )
381
398
{
382
- std::cout << " >>>>\n " ;
383
- std::cout << " >>>> " << it->first << ' \n ' ;
384
- std::cout << " >>>>\n " ;
385
- local_may_aliast local_may_alias (it->second );
386
- local_may_alias.output (std::cout, it->second , ns);
387
- std::cout << ' \n ' ;
399
+ show_properties (goto_model, get_ui ());
400
+ return 0 ;
388
401
}
389
402
403
+ <<<<<<< HEAD
390
404
return 0 ;
391
405
}
392
406
@@ -415,10 +429,30 @@ int goto_analyzer_parse_optionst::doit()
415
429
error () << " Failed to open output file `"
416
430
<< outfile << " '" << eom;
417
431
return 6 ;
432
+ =======
433
+ if (set_properties ())
434
+ return 7 ;
435
+
436
+
437
+ // Output file factory
438
+ std::ostream *out;
439
+ const std::string outfile = options.get_option (" outfile" );
440
+ if (outfile == " -" )
441
+ out = &std::cout;
442
+ else
443
+ {
444
+ out = new std::ofstream (outfile);
445
+ if (!*out)
446
+ {
447
+ error () << " Failed to open output file `"
448
+ << outfile << " '" << eom;
449
+ return 6 ;
450
+ }
451
+ >>>>>>> 1f65b1a... Catch exceptions thrown in doit ().
418
452
}
419
- }
420
453
421
454
455
+ <<<<<<< HEAD
422
456
// Run the analysis
423
457
bool result=true ;
424
458
if (options.get_bool_option (" show" ))
@@ -441,10 +475,57 @@ int goto_analyzer_parse_optionst::doit()
441
475
return result?10 :0 ;
442
476
443
477
478
+ =======
479
+ // Run the analysis
480
+ bool result = true ;
481
+ if (options.get_bool_option (" show" ))
482
+ result = static_show_domain (goto_model, options, get_message_handler (), *out);
483
+
484
+ else if (options.get_bool_option (" verify" ))
485
+ result = static_analyzer (goto_model, options, get_message_handler (), *out);
486
+
487
+ else if (options.get_bool_option (" simplify" ))
488
+ result = static_simplifier (goto_model, options, get_message_handler (), *out);
489
+ else
490
+ {
491
+ error () << " No task given" << eom;
492
+ return 6 ;
493
+ }
494
+
495
+ if (out != &std::cout)
496
+ delete out;
497
+
498
+ return result?10 :0 ;
499
+
500
+ >>>>>>> 1f65b1a... Catch exceptions thrown in doit ().
444
501
// Final defensive error case
445
502
error () << " no analysis option given -- consider reading --help"
446
503
<< eom;
447
504
return 6 ;
505
+ }
506
+ catch (const char *e)
507
+ {
508
+ error () << e << eom;
509
+ return 6 ;
510
+ }
511
+
512
+ catch (const std::string e)
513
+ {
514
+ error () << e << eom;
515
+ return 6 ;
516
+ }
517
+
518
+ catch (int x)
519
+ {
520
+ return x;
521
+ }
522
+
523
+ catch (std::bad_alloc)
524
+ {
525
+ error () << " Out of memory" << eom;
526
+ return 6 ;
527
+ }
528
+
448
529
}
449
530
450
531
/* ******************************************************************\
0 commit comments