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
19 #include "smatch_slist.h"
22 static struct stree
*ignored
;
23 static struct stree
*ignored_from_file
;
25 void add_ignore(int owner
, const char *name
, struct symbol
*sym
)
27 set_state_stree(&ignored
, owner
, name
, sym
, &ignore
);
30 int is_ignored(int owner
, const char *name
, struct symbol
*sym
)
32 return !!get_state_stree(ignored
, owner
, name
, sym
);
35 void add_ignore_expr(int owner
, struct expression
*expr
)
40 name
= expr_to_str_sym(expr
, &sym
);
43 add_ignore(owner
, name
, sym
);
47 int is_ignored_expr(int owner
, struct expression
*expr
)
53 name
= expr_to_str_sym(expr
, &sym
);
56 ret
= is_ignored(owner
, name
, sym
);
61 name
= get_macro_name(expr
->pos
);
62 if (name
&& get_state_stree(ignored_from_file
, owner
, name
, NULL
))
65 name
= get_function();
66 if (name
&& get_state_stree(ignored_from_file
, owner
, name
, NULL
))
72 static void clear_ignores(void)
79 static void load_ignores(void)
82 const char *name
, *str
;
86 snprintf(buf
, sizeof(buf
), "%s.ignored_warnings", option_project_str
);
87 token
= get_tokens_file(buf
);
90 if (token_type(token
) != TOKEN_STREAMBEGIN
)
93 while (token_type(token
) != TOKEN_STREAMEND
) {
94 if (token_type(token
) != TOKEN_IDENT
)
96 name
= show_ident(token
->ident
);
98 owner
= id_from_name(name
);
100 if (token_type(token
) != TOKEN_IDENT
)
102 str
= show_ident(token
->ident
);
105 set_state_stree_perm(&ignored_from_file
, owner
, str
, NULL
, &ignore
);
110 void register_smatch_ignore(int id
)
112 add_hook(&clear_ignores
, AFTER_FUNC_HOOK
);