hooks: add a SIZEOF_HOOK
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 18:58:28 +0000 (19 21:58 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 18:58:28 +0000 (19 21:58 +0300)
This passes the thing you are taking a sizeof() of.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch.h
smatch_flow.c
smatch_hooks.c

index 28c8531..0be4f4e 100644 (file)
--- a/smatch.h
+++ b/smatch.h
@@ -93,6 +93,7 @@ enum hook_type {
        CASE_HOOK,
        ASM_HOOK,
        CAST_HOOK,
+       SIZEOF_HOOK,
        BASE_HOOK,
        FUNC_DEF_HOOK,
        END_FUNC_HOOK,
index 2ede12e..ec811a6 100644 (file)
@@ -177,7 +177,9 @@ void __split_expr(struct expression *expr)
                __split_expr(expr->cast_expression);
                break;
        case EXPR_SIZEOF:
-               /* there isn't anything to pass a client from inside a sizeof() */
+               if (expr->cast_expression)
+                       __pass_to_client(strip_parens(expr->cast_expression),
+                                        SIZEOF_HOOK);
                break;
        case EXPR_OFFSETOF:
        case EXPR_ALIGNOF:
index 6817f43..3f84fd0 100644 (file)
@@ -107,6 +107,9 @@ void add_hook(void *func, enum hook_type type)
        case CAST_HOOK:
                container->data_type = EXPR_PTR;
                break;
+       case SIZEOF_HOOK:
+               container->data_type = EXPR_PTR;
+               break;
        case BASE_HOOK:
                container->data_type = SYMBOL_PTR;
                break;