overflow: ignore "x = &foo[ARRAY_SIZE(foo)];"
[smatch.git] / check_assigned_expr.c
blobc81307d428c25dce57cd56758768fc0e57fdd051
1 /*
2 * sparse/check_assigned_expr.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
11 * This is not a check. It just saves an struct expression pointer
12 * whenever something is assigned. This can be used later on by other scripts.
15 #include "smatch.h"
16 #include "smatch_slist.h"
18 int check_assigned_expr_id;
19 static int my_id;
21 static struct smatch_state *alloc_my_state(struct expression *expr)
23 struct smatch_state *state;
24 char *name;
26 state = __alloc_smatch_state(0);
27 expr = strip_expr(expr);
28 name = get_variable_from_expr_complex(expr, NULL);
29 state->name = alloc_sname(name);
30 free_string(name);
31 state->data = expr;
32 return state;
35 static void match_assignment(struct expression *expr)
37 set_state_expr(my_id, expr->left, alloc_my_state(expr->right));
40 void check_assigned_expr(int id)
42 my_id = check_assigned_expr_id = id;
43 add_hook(&match_assignment, ASSIGNMENT_HOOK);