constraints: replace get_common_relationship() with get_shared_relations()
[smatch.git] / check_db_info.c
blob2c626576700620ba9b1c952e19cd1d5a7a5fa7da
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 if (!return_ranges) {
20 return_ranges = rl;
21 return;
23 return_ranges = range_list_union(return_ranges, rl);
26 static void match_return(struct expression *ret_value)
28 struct range_list *rl;
30 ret_value = strip_expr(ret_value);
31 if (!ret_value)
32 return;
34 if (get_implied_range_list(ret_value, &rl)) {
35 sm_msg("info: return_value %s %s", show_ranges(rl), global_static());
36 add_return_range(rl);
37 } else {
38 sm_msg("info: return_value unknown %s", global_static());
39 add_return_range(whole_range_list());
43 static void match_end_func(struct symbol *sym)
45 if (!return_ranges)
46 return;
47 sm_msg("info: function_return_values '%s' %s",
48 show_ranges(return_ranges), global_static());
49 return_ranges = NULL;
52 void check_db_info(int id)
54 if (!option_info)
55 return;
56 my_id = id;
57 add_hook(&match_return, RETURN_HOOK);
58 add_hook(&match_end_func, END_FUNC_HOOK);