dereferences_param: mark more parameters as dereferenced
[smatch.git] / smatch_type_links.c
blob49eb4fb980271db0676d5b3dade001d1c05095c5
1 /*
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
20 * member.
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
24 * table.
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
41 * stuff.
44 #include "smatch.h"
45 #include "smatch_slist.h"
46 #include "smatch_extra.h"
48 static int my_id;
50 static void match_assign(struct expression *expr)
52 struct symbol *type;
54 if (!is_void_pointer(expr->left))
55 return;
57 type = get_type(expr->right);
58 if (!type || type->type != SYM_PTR)
59 return;
60 type = get_real_base_type(type);
61 if (!type || type->type != SYM_STRUCT)
62 return;
64 sql_insert_data_info(expr->left, TYPE_LINK, type_to_str(type));
67 void register_type_links(int id)
69 if (!option_info)
70 return;
71 my_id = id;
73 add_hook(&match_assign, ASSIGNMENT_HOOK);