4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
16 typedef void (*reg_func
) (int id
);
17 void register_smatch_extra(int id
);
18 void register_smatch_ignore(int id
);
19 void register_implications(int id
);
20 void register_function_hooks(int id
);
21 void check_null_deref(int id
);
22 void check_overflow(int id
);
23 void check_locking(int id
);
24 void check_memory(int id
);
25 void check_frees_argument(int id
);
26 void check_leaks(int id
);
27 void check_allocation_funcs(int id
);
28 /* <- your test goes here */
29 /* void register_template(int id); */
31 static const reg_func reg_funcs
[] = {
32 ®ister_smatch_extra
, /* smatch_extra always has to be first */
33 ®ister_smatch_ignore
,
38 // &check_allocation_funcs,
40 // &check_frees_argument,
42 /* <- your test goes here */
43 /* ®ister_template, */
45 ®ister_implications
, /* implications always has to be last */
49 static void help(void)
51 printf("Usage: smatch [smatch arguments][sparse arguments] file.c\n");
52 printf("--debug: print lots of debug output.\n");
53 printf("--debug-implied: print debug output about implications.\n");
54 printf("--assume-loops: assume loops always go through at least once.\n");
55 printf("--known-conditions: don't branch for known conditions.");
59 int main(int argc
, char **argv
)
64 bin_dir
= dirname(alloc_string(argv
[0]));
66 /* The script IDs start at 1.
67 0 is used for internal stuff. */
68 create_function_hash();
69 for(i
= 0; (func
= reg_funcs
[i
]); i
++){
72 register_function_hooks(-1);
75 if (!strcmp(argv
[1], "--debug")) {
77 } else if (!strcmp(argv
[1], "--debug-implied")) {
78 debug_implied_states
= 1;
79 } else if (!strcmp(argv
[1], "--no-implied")) {
80 option_no_implied
= 1;
81 } else if (!strcmp(argv
[1], "--assume-loops")) {
82 option_assume_loops
= 1;
83 } else if (!strcmp(argv
[1], "--known-conditions")) {
84 option_known_conditions
= 1;
85 } else if (!strcmp(argv
[1], "--help")) {