11f5207b7SJohn Levon /*
21f5207b7SJohn Levon  * Copyright (C) 2010 Dan Carpenter.
31f5207b7SJohn Levon  *
41f5207b7SJohn Levon  * This program is free software; you can redistribute it and/or
51f5207b7SJohn Levon  * modify it under the terms of the GNU General Public License
61f5207b7SJohn Levon  * as published by the Free Software Foundation; either version 2
71f5207b7SJohn Levon  * of the License, or (at your option) any later version.
81f5207b7SJohn Levon  *
91f5207b7SJohn Levon  * This program is distributed in the hope that it will be useful,
101f5207b7SJohn Levon  * but WITHOUT ANY WARRANTY; without even the implied warranty of
111f5207b7SJohn Levon  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
121f5207b7SJohn Levon  * GNU General Public License for more details.
131f5207b7SJohn Levon  *
141f5207b7SJohn Levon  * You should have received a copy of the GNU General Public License
151f5207b7SJohn Levon  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
161f5207b7SJohn Levon  */
171f5207b7SJohn Levon 
181f5207b7SJohn Levon #include "smatch.h"
19*efe51d0cSJohn Levon #include "smatch_slist.h"
201f5207b7SJohn Levon 
211f5207b7SJohn Levon static int my_id;
221f5207b7SJohn Levon static int returned;
231f5207b7SJohn Levon 
match_return(struct expression * ret_value)241f5207b7SJohn Levon static void match_return(struct expression *ret_value)
251f5207b7SJohn Levon {
261f5207b7SJohn Levon 	if (__inline_fn)
271f5207b7SJohn Levon 		return;
281f5207b7SJohn Levon 	if (is_reachable())
291f5207b7SJohn Levon 		returned = 1;
301f5207b7SJohn Levon }
311f5207b7SJohn Levon 
match_func_end(struct symbol * sym)321f5207b7SJohn Levon static void match_func_end(struct symbol *sym)
331f5207b7SJohn Levon {
341f5207b7SJohn Levon 	if (__inline_fn)
351f5207b7SJohn Levon 		return;
36*efe51d0cSJohn Levon 	if (out_of_memory() || taking_too_long())
37*efe51d0cSJohn Levon 		return;
381f5207b7SJohn Levon 	if (!is_reachable() && !returned)
391f5207b7SJohn Levon 		sm_info("info: add to no_return_funcs");
401f5207b7SJohn Levon 	returned = 0;
411f5207b7SJohn Levon }
421f5207b7SJohn Levon 
check_no_return(int id)431f5207b7SJohn Levon void check_no_return(int id)
441f5207b7SJohn Levon {
451f5207b7SJohn Levon 	if (!option_info)
461f5207b7SJohn Levon 		return;
471f5207b7SJohn Levon 	my_id = id;
481f5207b7SJohn Levon 	add_hook(&match_return, RETURN_HOOK);
491f5207b7SJohn Levon 	add_hook(&match_func_end, END_FUNC_HOOK);
501f5207b7SJohn Levon }
51