CBMC
goto_check_c.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Checks for Errors in C/C++ Programs
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_ANSI_C_GOTO_CHECK_C_H
13 #define CPROVER_ANSI_C_GOTO_CHECK_C_H
14 
16 
17 class goto_modelt;
18 class namespacet;
19 class optionst;
20 class message_handlert;
21 
22 void goto_check_c(
23  const namespacet &ns,
24  const optionst &options,
25  goto_functionst &goto_functions,
26  message_handlert &message_handler);
27 
28 void goto_check_c(
29  const irep_idt &function_identifier,
30  goto_functionst::goto_functiont &goto_function,
31  const namespacet &ns,
32  const optionst &options,
33  message_handlert &message_handler);
34 
35 void goto_check_c(
36  const optionst &options,
37  goto_modelt &goto_model,
38  message_handlert &message_handler);
39 
40 #define OPT_GOTO_CHECK \
41  "(bounds-check)(pointer-check)(memory-leak-check)(memory-cleanup-check)" \
42  "(div-by-zero-check)(float-div-by-zero-check)" \
43  "(enum-range-check)" \
44  "(signed-overflow-check)(unsigned-overflow-check)" \
45  "(pointer-overflow-check)(conversion-check)(undefined-shift-check)" \
46  "(float-overflow-check)(nan-check)(no-built-in-assertions)" \
47  "(pointer-primitive-check)" \
48  "(retain-trivial-checks)" \
49  "(error-label):" \
50  "(no-assertions)(no-assumptions)" \
51  "(assert-to-assume)" \
52  "(no-bounds-check)(no-pointer-check)(no-signed-overflow-check)" \
53  "(no-pointer-primitive-check)(no-undefined-shift-check)" \
54  "(no-div-by-zero-check)"
55 
56 // clang-format off
57 #define HELP_GOTO_CHECK \
58  " {y--no-standard-checks} \t disable default checks (more information in manpage)\n" /* NOLINT(whitespace/line_length) */ \
59  " {y--bounds-check} \t enable array bounds checks (default on)\n" \
60  " {y--no-bounds-check} \t disable array bounds checks\n" \
61  " {y--pointer-check} \t enable pointer checks (default on)\n" \
62  " {y--no-pointer-check} \t disable pointer checks\n" \
63  " {y--memory-leak-check} \t enable memory leak checks\n" \
64  " {y--memory-cleanup-check} \t enable memory cleanup checks\n" \
65  " {y--div-by-zero-check} \t " \
66  "enable division by zero checks on integers (default on)\n" \
67  " {y--float-div-by-zero-check} \t " \
68  "enable division by zero checks on floating-point numbers (default off)\n" \
69  " {y--no-div-by-zero-check} \t disable division by zero checks\n" \
70  " {y--signed-overflow-check} \t " \
71  "enable signed arithmetic over- and underflow checks (default on)\n" \
72  " {y--no-signed-overflow-check} \t " \
73  "disable signed arithmetic over- and underflow checks\n" \
74  " {y--unsigned-overflow-check} \t " \
75  "enable arithmetic over- and underflow checks\n" \
76  " {y--pointer-overflow-check} \t " \
77  "enable pointer arithmetic over- and underflow checks\n" \
78  " {y--conversion-check} \t " \
79  "check whether values can be represented after type cast\n" \
80  " {y--undefined-shift-check} \t check shift greater than bit-width " \
81  "(default on)\n" \
82  " {y--no-undefined-shift-check} \t disable check for shift greater than " \
83  "bit-width\n" \
84  " {y--float-overflow-check} \t check floating-point for +/-Inf\n" \
85  " {y--nan-check} \t check floating-point for NaN\n" \
86  " {y--enum-range-check} \t " \
87  "checks that all enum type expressions have values in the enum range\n" \
88  " {y--pointer-primitive-check} \t " \
89  "checks that all pointers in pointer primitives are valid or null (default " \
90  "on)\n" \
91  " {y--no-pointer-primitive-check} \t " \
92  "disable checks that all pointers in pointer primitives are valid or null\n" \
93  " {y--retain-trivial-checks} \t include checks that are trivially true\n" \
94  " {y--error-label} {ulabel} \t check that label {ulabel} is unreachable\n" \
95  " {y--no-built-in-assertions} \t ignore assertions in built-in library\n" \
96  " {y--no-assertions} \t ignore user assertions\n" \
97  " {y--no-assumptions} \t ignore user assumptions\n" \
98  " {y--assert-to-assume} \t convert user assertions to assumptions\n"
99 // clang-format on
100 
101 #define PARSE_OPTION_OVERRIDE(cmdline, options, option) \
102  if(cmdline.isset(option)) \
103  options.set_option(option, true); \
104  if(cmdline.isset("no-" option)) \
105  options.set_option(option, false); \
106  (void)0
107 
108 // clang-format off
109 #define PARSE_OPTIONS_GOTO_CHECK(cmdline, options) \
110  options.set_option("memory-leak-check", cmdline.isset("memory-leak-check")); \
111  options.set_option("memory-cleanup-check", cmdline.isset("memory-cleanup-check")); /* NOLINT(whitespace/line_length) */ \
112  options.set_option("enum-range-check", cmdline.isset("enum-range-check")); \
113  options.set_option("unsigned-overflow-check", cmdline.isset("unsigned-overflow-check")); /* NOLINT(whitespace/line_length) */ \
114  options.set_option("pointer-overflow-check", cmdline.isset("pointer-overflow-check")); /* NOLINT(whitespace/line_length) */ \
115  options.set_option("conversion-check", cmdline.isset("conversion-check")); \
116  options.set_option("float-overflow-check", cmdline.isset("float-overflow-check")); /* NOLINT(whitespace/line_length) */ \
117  options.set_option("nan-check", cmdline.isset("nan-check")); \
118  options.set_option("built-in-assertions", !cmdline.isset("no-built-in-assertions")); /* NOLINT(whitespace/line_length) */ \
119  options.set_option("retain-trivial-checks", \
120  cmdline.isset("retain-trivial-checks")); \
121  options.set_option("assertions", !cmdline.isset("no-assertions")); /* NOLINT(whitespace/line_length) */ \
122  options.set_option("assumptions", !cmdline.isset("no-assumptions")); /* NOLINT(whitespace/line_length) */ \
123  options.set_option("assert-to-assume", cmdline.isset("assert-to-assume")); /* NOLINT(whitespace/line_length) */ \
124  options.set_option("retain-trivial", cmdline.isset("retain-trivial")); /* NOLINT(whitespace/line_length) */ \
125  if(cmdline.isset("error-label")) \
126  options.set_option("error-label", cmdline.get_values("error-label")); \
127  PARSE_OPTION_OVERRIDE(cmdline, options, "bounds-check"); \
128  PARSE_OPTION_OVERRIDE(cmdline, options, "pointer-check"); \
129  PARSE_OPTION_OVERRIDE(cmdline, options, "div-by-zero-check"); \
130  PARSE_OPTION_OVERRIDE(cmdline, options, "float-div-by-zero-check"); \
131  PARSE_OPTION_OVERRIDE(cmdline, options, "signed-overflow-check"); \
132  PARSE_OPTION_OVERRIDE(cmdline, options, "undefined-shift-check"); \
133  PARSE_OPTION_OVERRIDE(cmdline, options, "pointer-primitive-check"); \
134  (void)0
135 // clang-format on
136 
137 #endif // CPROVER_ANALYSES_GOTO_CHECK_C_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
A collection of goto functions.
::goto_functiont goto_functiont
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
void goto_check_c(const namespacet &ns, const optionst &options, goto_functionst &goto_functions, message_handlert &message_handler)
Goto Programs with Functions.