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_type(int id
);
28 void check_allocation_funcs(int id
);
29 /* <- your test goes here */
30 /* void register_template(int id); */
32 static const reg_func reg_funcs
[] = {
33 ®ister_smatch_extra
, /* smatch_extra always has to be first */
34 ®ister_smatch_ignore
,
40 // &check_allocation_funcs,
42 // &check_frees_argument,
44 /* <- your test goes here */
45 /* ®ister_template, */
47 ®ister_implications
, /* implications always has to be last */
51 static void help(void)
53 printf("Usage: smatch [smatch arguments][sparse arguments] file.c\n");
54 printf("--debug: print lots of debug output.\n");
55 printf("--debug-implied: print debug output about implications.\n");
56 printf("--no-implied: ignore implications.\n");
57 printf("--assume-loops: assume loops always go through at least once.\n");
58 printf("--known-conditions: don't branch for known conditions.\n");
59 printf("--help: print this helpfull message.\n");
63 int main(int argc
, char **argv
)
68 bin_dir
= dirname(alloc_string(argv
[0]));
70 /* The script IDs start at 1.
71 0 is used for internal stuff. */
72 create_function_hash();
73 for(i
= 0; (func
= reg_funcs
[i
]); i
++){
76 register_function_hooks(-1);
79 if (!strcmp(argv
[1], "--debug")) {
81 } else if (!strcmp(argv
[1], "--debug-implied")) {
82 debug_implied_states
= 1;
83 } else if (!strcmp(argv
[1], "--no-implied")) {
84 option_no_implied
= 1;
85 } else if (!strcmp(argv
[1], "--assume-loops")) {
86 option_assume_loops
= 1;
87 } else if (!strcmp(argv
[1], "--known-conditions")) {
88 option_known_conditions
= 1;
89 } else if (!strcmp(argv
[1], "--help")) {