check_kernel: add support for with_intel_display()
[smatch.git] / smatch_refcount.c
blob454324cfe2e239c7a0c610ab6ef50a3bab836ca1
1 /*
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
18 #include "smatch.h"
19 #include "smatch_extra.h"
20 #include "smatch_slist.h"
22 static int my_id;
24 STATE(inc);
25 STATE(dec);
27 static void match_inc(struct expression *expr, const char *name, struct symbol *sym)
29 set_state(my_id, name, sym, &inc);
32 static void match_dec(struct expression *expr, const char *name, struct symbol *sym)
34 set_state(my_id, name, sym, &dec);
37 int was_inced(const char *name, struct symbol *sym)
39 if (has_possible_state(my_id, name, sym, &inc))
40 return true;
41 return false;
44 void register_refcount(int id)
46 my_id = id;
48 if (option_project != PROJ_KERNEL)
49 return;
51 add_modification_hook(my_id, &set_undefined);
53 add_refcount_inc_hook(&match_inc);
54 add_refcount_dec_hook(&match_dec);