param_set: don't save if the parent is set
[smatch.git] / smatch_ignore.c
blobeb06a0512a910270446c525fd0dffe0e79ea453e
1 /*
2 * Copyright (C) 2009 Dan Carpenter.
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_slist.h"
21 STATE(ignore);
22 static struct stree *ignored;
24 void add_ignore(int owner, const char *name, struct symbol *sym)
26 set_state_stree(&ignored, owner, name, sym, &ignore);
29 int is_ignored(int owner, const char *name, struct symbol *sym)
31 return !!get_state_stree(ignored, owner, name, sym);
34 void add_ignore_expr(int owner, struct expression *expr)
36 struct symbol *sym;
37 char *name;
39 name = expr_to_str_sym(expr, &sym);
40 if (!name || !sym)
41 return;
42 add_ignore(owner, name, sym);
43 free_string(name);
46 int is_ignored_expr(int owner, struct expression *expr)
48 struct symbol *sym;
49 char *name;
50 int ret;
52 name = expr_to_str_sym(expr, &sym);
53 if (!name && !sym)
54 return 0;
55 ret = is_ignored(owner, name, sym);
56 free_string(name);
57 return ret;
60 static void clear_ignores(void)
62 if (__inline_fn)
63 return;
64 free_stree(&ignored);
67 void register_smatch_ignore(int id)
69 add_hook(&clear_ignores, AFTER_FUNC_HOOK);