extra: small fix for when the database is disabled but we have inline info
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 15 Apr 2013 08:49:11 +0000 (15 11:49 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 15 Apr 2013 08:49:11 +0000 (15 11:49 +0300)
This is to change how this is handled:

foo(&bar);

In the original code if there wasn't a cross function database then it
just resets the struct.  But in the new code if we have the information in
the in-memory database then we use that instead of blindly clearing it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_extra.c

index 79ea0dc..a65276d 100644 (file)
@@ -434,6 +434,12 @@ static void match_function_call(struct expression *expr)
        struct expression *tmp;
        struct state_list *slist;
 
+       /* if we have the db this is handled in smatch_function_hooks.c */
+       if (!option_no_db)
+               return;
+       if (inlinable(expr->fn))
+               return;
+
        slist = get_all_states(SMATCH_EXTRA);
 
        FOR_EACH_PTR(expr->args, arg) {
@@ -1334,8 +1340,7 @@ void register_smatch_extra_late(int id)
        add_hook(&match_pointer_as_array, OP_HOOK);
        add_db_fn_call_callback(DEREFERENCE, &set_param_dereferenced);
        add_indirect_modification_hook(SMATCH_EXTRA, reset_struct_members);
-       if (option_no_db)
-               add_hook(&match_function_call, FUNCTION_CALL_HOOK);
+       add_hook(&match_function_call, FUNCTION_CALL_HOOK);
        add_hook(&match_assign, ASSIGNMENT_HOOK);
        add_hook(&unop_expr, OP_HOOK);
        add_hook(&asm_expr, ASM_HOOK);