2 * Copyright (C) 2021 Oracle
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 #include "smatch_slist.h"
20 #include "smatch_extra.h"
24 void __set_param_modified_helper(struct expression
*expr
, struct smatch_state
*state
)
26 set_state_expr(my_id
, expr
, state
);
29 void __set_param_modified_helper_sym(const char *name
, struct symbol
*sym
,
30 struct smatch_state
*state
)
32 set_state(my_id
, name
, sym
, state
);
35 static struct smatch_state
*unmatched_state(struct sm_state
*sm
)
37 return alloc_bstate(0, 0);
40 static void return_info_callback(int return_id
, char *return_ranges
,
41 struct expression
*returned_expr
,
43 const char *printed_name
,
46 unsigned long long bits_set
;
48 struct smatch_state
*estate
;
49 struct bit_info
*binfo
;
52 estate
= get_state(SMATCH_EXTRA
, sm
->name
, sm
->sym
);
53 if (estate_get_single_value(estate
, &sval
))
56 binfo
= sm
->state
->data
;
57 bits_set
= binfo
->set
;
62 sprintf(buffer
, "0x%llx", bits_set
);
63 sql_insert_return_states(return_id
, return_ranges
, BIT_SET
, param
, printed_name
, buffer
);
66 void register_param_bits_set(int id
)
70 set_dynamic_states(my_id
);
72 add_unmatched_state_hook(my_id
, &unmatched_state
);
73 add_merge_hook(my_id
, &merge_bstates
);
75 add_return_info_callback(my_id
, return_info_callback
);