From 5267058209f6b18e8f720ca1b12d4382eb896570 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 14 May 2018 13:47:07 +0300 Subject: [PATCH] flow: don't parse inline functions which aren't interesting One thing which is a problem is that inline functions generate tons and tons of duplicate warnings, but the main thing here that I was worried about was that we were filling the DB with nonsense. In the original code, we would parse inline and because they are static and there are no callers in this file then we'd record that "This function is never called". So then the inline calls other functions with "everything is unknown". Then the other callers would sometimes be like, "Ugh... Too much information from too many callers. Let's ignore it all". So now if we have an uncalled inline in a .c file then we say "Ok. This is legit an uncalled inline and everything is unknown". But otherwise we don't even parse it. Signed-off-by: Dan Carpenter --- smatch_flow.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/smatch_flow.c b/smatch_flow.c index 4c8c81a9..e80d7986 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -1678,6 +1678,29 @@ static struct symbol *get_last_scoped_symbol(struct symbol_list *big_list, int u return NULL; } +static bool interesting_function(struct symbol *sym) +{ + static int prev_stream = -1; + static bool prev_answer; + const char *filename; + int len; + + if (!(sym->ctype.modifiers & MOD_INLINE)) + return true; + + if (sym->pos.stream == prev_stream) + return prev_answer; + + prev_stream = sym->pos.stream; + prev_answer = false; + + filename = stream_name(sym->pos.stream); + len = strlen(filename); + if (len > 0 && filename[len - 1] == 'c') + prev_answer = true; + return prev_answer; +} + static void split_inlines_in_scope(struct symbol *sym) { struct symbol *base; @@ -1700,6 +1723,8 @@ static void split_inlines_in_scope(struct symbol *sym) continue; if (!base->inline_stmt) continue; + if (!interesting_function(sym)) + continue; add_inline_function(sym); } END_FOR_EACH_PTR_REVERSE(sym); @@ -1730,30 +1755,6 @@ static struct stree *clone_estates_perm(struct stree *orig) return ret; } -static bool interesting_function(struct symbol *sym) -{ - static int prev_stream = -1; - static bool prev_answer; - const char *filename; - int len; - - - if (!(sym->ctype.modifiers & MOD_INLINE)) - return true; - - if (sym->pos.stream == prev_stream) - return prev_answer; - - prev_stream = sym->pos.stream; - prev_answer = false; - - filename = stream_name(sym->pos.stream); - len = strlen(filename); - if (len > 0 && filename[len - 1] == 'c') - prev_answer = true; - return prev_answer; -} - struct position last_pos; static void split_c_file_functions(struct symbol_list *sym_list) { -- 2.11.4.GIT