2 * Copyright (C) 2016 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 #include "smatch_extra.h"
20 #include "smatch_slist.h"
26 static void handle_test_functions(struct expression
*expr
)
28 struct expression
*tmp
;
29 struct statement
*stmt
;
32 if (expr
->type
!= EXPR_CALL
||
33 expr
->fn
->type
!= EXPR_SYMBOL
||
34 !expr
->fn
->symbol_name
)
36 if (!strstr(expr
->fn
->symbol_name
->name
, "test"))
39 while ((tmp
= expr_get_parent_expr(expr
))) {
45 stmt
= expr_get_parent_stmt(expr
);
46 if (!stmt
|| stmt
->type
!= STMT_IF
)
49 set_true_false_states(my_id
, "dec_path", NULL
, &zero_path
, NULL
);
52 static void match_dec(struct expression
*expr
, const char *name
, struct symbol
*sym
)
54 handle_test_functions(expr
);
57 int on_atomic_dec_path(void)
59 return get_state(my_id
, "dec_path", NULL
) == &zero_path
;
62 void register_kernel_atomic_dec_test_path(int id
)
66 if (option_project
!= PROJ_KERNEL
)
69 add_refcount_dec_hook(&match_dec
);