2 * Copyright (C) 2015 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_slist.h"
25 static void match_while_count_down(struct expression
*expr
)
27 struct statement
*stmt
= __cur_stmt
;
29 if (expr
->type
!= EXPR_POSTOP
|| expr
->op
!= SPECIAL_DECREMENT
)
32 if (!stmt
|| stmt
->type
!= STMT_ITERATOR
)
35 set_true_false_states_expr(my_id
, strip_expr(expr
->unop
), NULL
, &timed_out
);
38 static void match_test(struct expression
*expr
)
43 sm
= get_sm_state_expr(my_id
, expr
);
44 if (!sm
|| !slist_has_state(sm
->possible
, &timed_out
))
47 name
= expr_to_str(expr
);
48 sm_msg("warn: should this be '%s == -1'", name
);
52 void check_postop_timeout(int id
)
55 add_hook(&match_while_count_down
, CONDITION_HOOK
);
56 add_hook(&match_test
, CONDITION_HOOK
);
57 add_modification_hook(my_id
, &set_undefined
);