ranges: rename possibly_true_range_lists() to possibly_true_rl()
[smatch.git] / check_db_info.c
blobd9c3d3a14e07eeec9b05134694f1cf9cf438785d
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 ret_value = strip_expr(ret_value);
33 if (!ret_value)
34 return;
36 if (get_implied_range_list(ret_value, &rl))
37 add_return_range(rl);
38 else
39 add_return_range(alloc_whole_rl(type));
42 static void match_end_func(struct symbol *sym)
44 if (!return_ranges)
45 return;
46 sm_msg("info: function_return_values '%s' %s",
47 show_ranges(return_ranges), global_static());
48 return_ranges = NULL;
51 void check_db_info(int id)
53 if (!option_info)
54 return;
55 my_id = id;
56 add_hook(&match_return, RETURN_HOOK);
57 add_hook(&match_end_func, END_FUNC_HOOK);