constraints: make get_common_relationship() take an estate
[smatch.git] / check_db_info.c
blobe1f0766306ed168f7d7fef8456329eafb6c1073e
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 void match_return(struct expression *ret_value)
17 struct smatch_state *state;
18 struct range_list *rl;
19 long long val;
21 ret_value = strip_expr(ret_value);
22 if (!ret_value)
23 return;
25 if (ret_value->type == EXPR_CALL) {
26 rl = db_return_vals(ret_value);
27 if (rl)
28 sm_msg("info: return_value %s", show_ranges(rl));
29 else
30 sm_msg("info: return_value unknown");
31 return;
34 if (get_value(ret_value, &val)) {
35 sm_msg("info: return_value %lld", val);
36 return;
38 state = get_state_expr(SMATCH_EXTRA, ret_value);
39 if (!state) {
40 sm_msg("info: return_value unknown");
41 return;
44 sm_msg("info: return_value %s", state->name);
47 void check_db_info(int id)
49 if (!option_info)
50 return;
51 my_id = id;
52 add_hook(&match_return, RETURN_HOOK);