Skip to content

Commit 1c1bd87

Browse files
committed
Add default options to goto-analyzer
1 parent 56c3499 commit 1c1bd87

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

+32-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ goto_analyzer_parse_optionst::goto_analyzer_parse_optionst(
5656
{
5757
}
5858

59+
void goto_analyzer_parse_optionst::set_default_analysis_flags(optionst &options)
60+
{
61+
// Checks enabled by default in v6.0+.
62+
options.set_option("bounds-check", true);
63+
options.set_option("pointer-check", true);
64+
options.set_option("pointer-primitive-check", true);
65+
options.set_option("div-by-zero-check", true);
66+
options.set_option("signed-overflow-check", true);
67+
options.set_option("undefined-shift-check", true);
68+
69+
// Default malloc failure profile chosen to be returning null.
70+
options.set_option("malloc-may-fail", true);
71+
options.set_option("malloc-fail-null", true);
72+
73+
// This is in-line with the options we set for CBMC in cbmc_parse_optionst
74+
// with the exception of unwinding-assertions, which don't make sense in
75+
// the context of abstract interpretation.
76+
}
77+
5978
void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
6079
{
6180
if(config.set(cmdline))
@@ -67,7 +86,19 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
6786
if(cmdline.isset("function"))
6887
options.set_option("function", cmdline.get_value("function"));
6988

70-
// all checks supported by goto_check
89+
// Enable flags that in combination provide analysis with no surprises
90+
// (expected checks and no unsoundness by missing checks).
91+
if(!cmdline.isset("no-standard-checks"))
92+
{
93+
goto_analyzer_parse_optionst::set_default_analysis_flags(options);
94+
PARSE_OPTIONS_GOTO_CHECK_NEGATIVE_DEFAULT_CHECKS(cmdline, options);
95+
}
96+
else if(cmdline.isset("no-standard-checks"))
97+
{
98+
PARSE_OPTIONS_GOTO_CHECK_POSITIVE_DEFAULT_CHECKS(cmdline, options);
99+
}
100+
101+
// all (other) checks supported by goto_check
71102
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
72103

73104
// The user should either select:

src/goto-analyzer/goto_analyzer_parse_options.h

+3
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ class goto_analyzer_parse_optionst: public parse_options_baset
188188
virtual bool process_goto_program(const optionst &options);
189189

190190
virtual int perform_analysis(const optionst &options);
191+
192+
// TODO: Add documentation
193+
static void set_default_analysis_flags(optionst &options);
191194
};
192195

193196
#endif // CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H

0 commit comments

Comments
 (0)