2 * Copyright (C) 2014 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 * The plan here is to save all the possible values store to a given struct
22 * We will load all the values in to the function_type_val table first then
23 * run a script on that and load all the resulting values into the type_val
26 * So in this file we want to take the union of everything assigned to the
27 * struct member and insert it into the function_type_val at the end.
29 * You would think that we could use smatch_modification_hooks.c or
30 * extra_modification_hook() here to get the information here but in the end we
31 * need to code everything again a third time.
36 * Remember links like:
38 * foo->void_ptr = some_struct.
40 * If we get a some_struct pointer from foo->void_ptr then assume it's the same
45 #include "smatch_slist.h"
46 #include "smatch_extra.h"
50 static void match_assign(struct expression
*expr
)
54 if (!is_void_pointer(expr
->left
))
57 type
= get_type(expr
->right
);
58 if (!type
|| type
->type
!= SYM_PTR
)
60 type
= get_real_base_type(type
);
61 if (!type
|| type
->type
!= SYM_STRUCT
)
64 sql_insert_data_info(expr
->left
, TYPE_LINK
, type_to_str(type
));
67 void register_type_links(int id
)
73 add_hook(&match_assign
, ASSIGNMENT_HOOK
);