allocations: add some more allocation functions
[smatch.git] / smatch_goto_tracker.c
blob17a363eb7e58405c4ef8427b04a6b6e73e24fd0c
1 /*
2 * Copyright (C) 2021 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 * The kernel uses gotos a lot for unwinding. So it's useful to be able to
20 * track all the gotos so we can check error codes are set etc.
24 #include "smatch.h"
26 static int my_id;
28 static void match_goto(struct statement *stmt)
30 if (stmt->type != STMT_GOTO)
31 return;
32 set_state(my_id, "goto", NULL, &true_state);
35 struct sm_state *get_goto_sm_state(void)
37 return get_sm_state(my_id, "goto", NULL);
40 void register_goto_tracker(int id)
42 my_id = id;
44 add_hook(&match_goto, STMT_HOOK);