Print this page
11506 smatch resync
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/smatch_ignore.c
+++ new/usr/src/tools/smatch/src/smatch_ignore.c
1 1 /*
2 2 * Copyright (C) 2009 Dan Carpenter.
3 3 *
4 4 * This program is free software; you can redistribute it and/or
5 5 * modify it under the terms of the GNU General Public License
6 6 * as published by the Free Software Foundation; either version 2
7 7 * of the License, or (at your option) any later version.
8 8 *
9 9 * This program is distributed in the hope that it will be useful,
10 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 * GNU General Public License for more details.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * You should have received a copy of the GNU General Public License
15 15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
16 16 */
17 17
18 18 #include "smatch.h"
19 19 #include "smatch_slist.h"
20 20
21 21 STATE(ignore);
22 22 static struct stree *ignored;
23 +static struct stree *ignored_from_file;
23 24
24 25 void add_ignore(int owner, const char *name, struct symbol *sym)
25 26 {
26 27 set_state_stree(&ignored, owner, name, sym, &ignore);
27 28 }
28 29
29 30 int is_ignored(int owner, const char *name, struct symbol *sym)
30 31 {
31 32 return !!get_state_stree(ignored, owner, name, sym);
32 33 }
33 34
34 35 void add_ignore_expr(int owner, struct expression *expr)
35 36 {
36 37 struct symbol *sym;
37 38 char *name;
38 39
39 40 name = expr_to_str_sym(expr, &sym);
40 41 if (!name || !sym)
41 42 return;
42 43 add_ignore(owner, name, sym);
43 44 free_string(name);
44 45 }
45 46
46 47 int is_ignored_expr(int owner, struct expression *expr)
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
47 48 {
48 49 struct symbol *sym;
49 50 char *name;
50 51 int ret;
51 52
52 53 name = expr_to_str_sym(expr, &sym);
53 54 if (!name && !sym)
54 55 return 0;
55 56 ret = is_ignored(owner, name, sym);
56 57 free_string(name);
57 - return ret;
58 + if (ret)
59 + return true;
60 +
61 + name = get_macro_name(expr->pos);
62 + if (name && get_state_stree(ignored_from_file, owner, name, NULL))
63 + return true;
64 +
65 + name = get_function();
66 + if (name && get_state_stree(ignored_from_file, owner, name, NULL))
67 + return true;
68 +
69 + return false;
58 70 }
59 71
60 72 static void clear_ignores(void)
61 73 {
62 74 if (__inline_fn)
63 75 return;
64 76 free_stree(&ignored);
65 77 }
66 78
79 +static void load_ignores(void)
80 +{
81 + struct token *token;
82 + const char *name, *str;
83 + int owner;
84 + char buf[64];
85 +
86 + snprintf(buf, sizeof(buf), "%s.ignored_warnings", option_project_str);
87 + token = get_tokens_file(buf);
88 + if (!token)
89 + return;
90 + if (token_type(token) != TOKEN_STREAMBEGIN)
91 + return;
92 + token = token->next;
93 + while (token_type(token) != TOKEN_STREAMEND) {
94 + if (token_type(token) != TOKEN_IDENT)
95 + break;
96 + name = show_ident(token->ident);
97 + token = token->next;
98 + owner = id_from_name(name);
99 +
100 + if (token_type(token) != TOKEN_IDENT)
101 + break;
102 + str = show_ident(token->ident);
103 + token = token->next;
104 +
105 + set_state_stree_perm(&ignored_from_file, owner, str, NULL, &ignore);
106 + }
107 + clear_token_alloc();
108 +}
109 +
67 110 void register_smatch_ignore(int id)
68 111 {
69 112 add_hook(&clear_ignores, AFTER_FUNC_HOOK);
113 + load_ignores();
70 114 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX