2 * sparse/smatch_containers.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 #include "smatch_slist.h"
13 static struct tracker_list
*member_list
;
15 int is_member(struct expression
*expr
)
17 if (expr
->type
== EXPR_DEREF
)
22 void set_default_state(int owner
, struct smatch_state
*state
)
24 default_state
[owner
] = state
;
27 void reset_on_container_modified(int owner
, struct expression
*expr
)
32 return; /* this stuff is taking too long */
37 expr
= strip_expr(expr
);
38 name
= get_variable_from_expr(expr
, &sym
);
41 add_tracker(&member_list
, owner
, name
, sym
);
46 static void match_assign_call(struct expression
*expr
)
51 struct expression
*left
;
53 left
= strip_expr(expr
->left
);
54 name
= get_variable_from_expr(left
, &sym
);
58 FOR_EACH_PTR(member_list
, tmp
) {
59 if (!default_state
[tmp
->owner
])
62 && !strncmp(tmp
->name
, name
, strlen(name
))) {
63 set_state(tmp
->owner
, tmp
->name
, tmp
->sym
, default_state
[tmp
->owner
]);
66 } END_FOR_EACH_PTR(tmp
);
71 static void match_func_end(struct symbol
*sym
)
73 free_trackers_and_list(&member_list
);
76 void register_containers(int id
)
78 add_hook(&match_assign_call
, CALL_ASSIGNMENT_HOOK
);
79 add_hook(&match_func_end
, END_FUNC_HOOK
);