2 * sparse/smatch_project.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 * This file is only for very generic stuff, that is reusable
12 * between projects. If you need something special create a
13 * check_your_project.c.
18 #include "smatch_extra.h"
20 static void register_no_return_funcs(void)
26 if (option_project
== PROJ_NONE
)
27 strcpy(name
, "no_return_funcs");
29 snprintf(name
, 256, "%s.no_return_funcs", option_project_str
);
31 token
= get_tokens_file(name
);
34 if (token_type(token
) != TOKEN_STREAMBEGIN
)
37 while (token_type(token
) != TOKEN_STREAMEND
) {
38 if (token_type(token
) != TOKEN_IDENT
)
40 func
= show_ident(token
->ident
);
41 add_function_hook(func
, &__match_nullify_path_hook
, NULL
);
47 static void return_implies(struct expression
*call_expr
, int param
, char *key
, char *value
)
49 struct range_list
*rl
;
50 struct expression
*arg
;
52 if (call_expr
->type
== EXPR_ASSIGNMENT
)
53 call_expr
= strip_expr(call_expr
->right
);
55 arg
= get_argument_from_call_expr(call_expr
->args
, param
);
56 parse_value_ranges_type(get_type(call_expr
), value
, &rl
);
57 set_extra_expr_nomod(arg
, alloc_estate_range_list(rl
));
60 static void register_ignored_macros(void)
66 if (option_project
== PROJ_NONE
)
67 strcpy(name
, "ignored_macros");
69 snprintf(name
, 256, "%s.ignored_macros", option_project_str
);
71 token
= get_tokens_file(name
);
74 if (token_type(token
) != TOKEN_STREAMBEGIN
)
77 while (token_type(token
) != TOKEN_STREAMEND
) {
78 if (token_type(token
) != TOKEN_IDENT
)
80 macro
= alloc_string(show_ident(token
->ident
));
81 add_ptr_list(&__ignored_macros
, macro
);
87 void register_project(int id
)
89 register_no_return_funcs();
90 register_ignored_macros();
91 add_db_return_implies_callback(RANGE_CAP
, &return_implies
);