extra: handle MOD_ASSIGN better
[smatch.git] / check_db_info.c
blobb55980a02d7f85ee8e558b5b1fa04f33d8b44517
1 /*
2 * smatch/check_db_info.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
11 #include "smatch_extra.h"
13 static int my_id;
15 static struct range_list *return_ranges;
17 static void add_return_range(struct range_list *rl)
19 rl = cast_rl(cur_func_return_type(), rl);
20 if (!return_ranges) {
21 return_ranges = rl;
22 return;
24 return_ranges = rl_union(return_ranges, rl);
27 static void match_return(struct expression *ret_value)
29 struct range_list *rl;
30 struct symbol *type = cur_func_return_type();
32 if (__inline_fn)
33 return;
34 ret_value = strip_expr(ret_value);
35 if (!ret_value)
36 return;
38 if (get_implied_rl(ret_value, &rl))
39 add_return_range(rl);
40 else
41 add_return_range(alloc_whole_rl(type));
44 static void match_end_func(struct symbol *sym)
46 if (__inline_fn)
47 return;
48 if (!return_ranges)
49 return;
50 sql_insert_return_values(show_rl(return_ranges));
51 return_ranges = NULL;
54 void check_db_info(int id)
56 my_id = id;
57 add_hook(&match_return, RETURN_HOOK);
58 add_hook(&match_end_func, END_FUNC_HOOK);