2 * Copyright (C) 2010 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
22 #include "smatch_slist.h"
23 #include "smatch_extra.h"
24 #include "smatch_function_hashtable.h"
26 #define UNKNOWN_SIZE -1
28 static int my_size_id
;
30 static DEFINE_HASHTABLE_INSERT(insert_func
, char, int);
31 static DEFINE_HASHTABLE_SEARCH(search_func
, char, int);
32 static struct hashtable
*allocation_funcs
;
34 static char *get_fn_name(struct expression
*expr
)
36 if (expr
->type
!= EXPR_CALL
)
38 if (expr
->fn
->type
!= EXPR_SYMBOL
)
40 return expr_to_var(expr
->fn
);
43 static int is_allocation_function(struct expression
*expr
)
48 func
= get_fn_name(expr
);
51 if (search_func(allocation_funcs
, func
))
57 static void add_allocation_function(const char *func
, void *call_back
, int param
)
59 insert_func(allocation_funcs
, (char *)func
, (int *)1);
60 add_function_assign_hook(func
, call_back
, INT_PTR(param
));
63 static int estate_to_size(struct smatch_state
*state
)
67 if (!state
|| !estate_rl(state
))
69 sval
= estate_max(state
);
73 static struct smatch_state
*size_to_estate(int size
)
77 sval
.type
= &int_ctype
;
80 return alloc_estate_sval(sval
);
83 static struct range_list
*size_to_rl(int size
)
87 sval
.type
= &int_ctype
;
90 return alloc_rl(sval
, sval
);
93 static struct smatch_state
*unmatched_size_state(struct sm_state
*sm
)
95 return size_to_estate(UNKNOWN_SIZE
);
98 static void set_size_undefined(struct sm_state
*sm
, struct expression
*mod_expr
)
100 set_state(sm
->owner
, sm
->name
, sm
->sym
, size_to_estate(UNKNOWN_SIZE
));
103 static struct smatch_state
*merge_size_func(struct smatch_state
*s1
, struct smatch_state
*s2
)
105 return merge_estates(s1
, s2
);
108 void set_param_buf_size(const char *name
, struct symbol
*sym
, char *key
, char *value
)
110 struct range_list
*rl
= NULL
;
111 struct smatch_state
*state
;
114 if (strncmp(key
, "$", 1) != 0)
117 snprintf(fullname
, 256, "%s%s", name
, key
+ 1);
119 str_to_rl(&int_ctype
, value
, &rl
);
120 if (!rl
|| is_whole_rl(rl
))
122 state
= alloc_estate_rl(rl
);
123 set_state(my_size_id
, fullname
, sym
, state
);
126 static int bytes_per_element(struct expression
*expr
)
132 if (expr
->type
== EXPR_STRING
)
134 if (expr
->type
== EXPR_PREOP
&& expr
->op
== '&') {
135 type
= get_type(expr
->unop
);
136 if (type
&& type
->type
== SYM_ARRAY
)
139 type
= get_type(expr
);
143 if (type
->type
!= SYM_PTR
&& type
->type
!= SYM_ARRAY
)
146 type
= get_base_type(type
);
147 return type_bytes(type
);
150 static int bytes_to_elements(struct expression
*expr
, int bytes
)
154 bpe
= bytes_per_element(expr
);
160 static int elements_to_bytes(struct expression
*expr
, int elements
)
164 bpe
= bytes_per_element(expr
);
165 return elements
* bpe
;
168 static int get_initializer_size(struct expression
*expr
)
170 switch (expr
->type
) {
172 return expr
->string
->length
;
173 case EXPR_INITIALIZER
: {
174 struct expression
*tmp
;
177 FOR_EACH_PTR(expr
->expr_list
, tmp
) {
178 if (tmp
->type
== EXPR_INDEX
) {
179 if (tmp
->idx_to
>= i
)
186 } END_FOR_EACH_PTR(tmp
);
190 return get_array_size(expr
);
195 static struct range_list
*db_size_rl
;
196 static int db_size_callback(void *unused
, int argc
, char **argv
, char **azColName
)
198 struct range_list
*tmp
= NULL
;
201 str_to_rl(&int_ctype
, argv
[0], &db_size_rl
);
203 str_to_rl(&int_ctype
, argv
[0], &tmp
);
204 db_size_rl
= rl_union(db_size_rl
, tmp
);
209 static struct range_list
*size_from_db_type(struct expression
*expr
)
211 int this_file_only
= 0;
214 name
= get_member_name(expr
);
215 if (!name
&& is_static(expr
)) {
216 name
= expr_to_var(expr
);
222 if (this_file_only
) {
224 run_sql(db_size_callback
, NULL
,
225 "select size from function_type_size where type = '%s' and file = '%s';",
226 name
, get_filename());
233 run_sql(db_size_callback
, NULL
,
234 "select size from type_size where type = '%s';",
239 static struct range_list
*size_from_db_symbol(struct expression
*expr
)
243 if (expr
->type
!= EXPR_SYMBOL
)
246 if (!sym
|| !sym
->ident
||
247 !(sym
->ctype
.modifiers
& MOD_TOPLEVEL
) ||
248 sym
->ctype
.modifiers
& MOD_STATIC
)
252 run_sql(db_size_callback
, NULL
,
253 "select value from data_info where file = 'extern' and data = '%s' and type = %d;",
254 sym
->ident
->name
, BUF_SIZE
);
258 static struct range_list
*size_from_db(struct expression
*expr
)
260 struct range_list
*rl
;
262 rl
= size_from_db_symbol(expr
);
265 return size_from_db_type(expr
);
268 static void db_returns_buf_size(struct expression
*expr
, int param
, char *unused
, char *math
)
270 struct expression
*call
;
271 struct range_list
*rl
;
274 if (expr
->type
!= EXPR_ASSIGNMENT
)
276 call
= strip_expr(expr
->right
);
278 call_results_to_rl(call
, &int_ctype
, math
, &rl
);
279 rl
= cast_rl(&int_ctype
, rl
);
280 if (rl_to_sval(rl
, &sval
) && sval
.value
== 0)
282 set_state_expr(my_size_id
, expr
->left
, alloc_estate_rl(rl
));
285 static int get_real_array_size_from_type(struct symbol
*type
)
291 if (!type
|| type
->type
!= SYM_ARRAY
)
294 if (!get_implied_value(type
->array_size
, &sval
))
300 int get_real_array_size(struct expression
*expr
)
304 if (expr
->type
== EXPR_PREOP
&& expr
->op
== '&')
306 if (expr
->type
== EXPR_BINOP
) /* array elements foo[5] */
308 return get_real_array_size_from_type(get_type(expr
));
311 static int get_size_from_initializer(struct expression
*expr
)
313 if (expr
->type
!= EXPR_SYMBOL
|| !expr
->symbol
|| !expr
->symbol
->initializer
)
315 if (expr
->symbol
->initializer
== expr
) /* int a = a; */
317 return get_initializer_size(expr
->symbol
->initializer
);
320 static struct range_list
*get_stored_size_bytes(struct expression
*expr
)
322 struct smatch_state
*state
;
324 state
= get_state_expr(my_size_id
, expr
);
327 return estate_rl(state
);
330 static int get_bytes_from_address(struct expression
*expr
)
335 if (expr
->type
!= EXPR_PREOP
|| expr
->op
!= '&')
337 type
= get_type(expr
);
341 if (type
->type
== SYM_PTR
)
342 type
= get_base_type(type
);
344 ret
= type_bytes(type
);
346 return 0; /* ignore char pointers */
351 static struct expression
*remove_addr_fluff(struct expression
*expr
)
353 struct expression
*tmp
;
356 expr
= strip_expr(expr
);
358 /* remove '&' and '*' operations that cancel */
359 while (expr
&& expr
->type
== EXPR_PREOP
&& expr
->op
== '&') {
360 tmp
= strip_expr(expr
->unop
);
361 if (tmp
->type
!= EXPR_PREOP
)
365 expr
= strip_expr(tmp
->unop
);
371 /* "foo + 0" is just "foo" */
372 if (expr
->type
== EXPR_BINOP
&& expr
->op
== '+' &&
373 get_value(expr
->right
, &sval
) && sval
.value
== 0)
379 static int is_last_member_of_struct(struct symbol
*sym
, struct ident
*member
)
385 FOR_EACH_PTR_REVERSE(sym
->symbol_list
, tmp
) {
386 if (i
++ || !tmp
->ident
)
388 if (tmp
->ident
== member
)
391 } END_FOR_EACH_PTR_REVERSE(tmp
);
396 int last_member_is_resizable(struct symbol
*sym
)
398 struct symbol
*last_member
;
402 if (!sym
|| sym
->type
!= SYM_STRUCT
)
405 last_member
= last_ptr_list((struct ptr_list
*)sym
->symbol_list
);
406 if (!last_member
|| !last_member
->ident
)
409 type
= get_real_base_type(last_member
);
410 if (type
->type
== SYM_STRUCT
)
411 return last_member_is_resizable(type
);
412 if (type
->type
!= SYM_ARRAY
)
415 if (!get_implied_value(type
->array_size
, &sval
))
418 if (sval
.value
!= 0 && sval
.value
!= 1)
424 static int get_stored_size_end_struct_bytes(struct expression
*expr
)
427 struct symbol
*base_sym
;
428 struct smatch_state
*state
;
430 if (expr
->type
== EXPR_BINOP
) /* array elements foo[5] */
433 if (expr
->type
== EXPR_PREOP
&& expr
->op
== '&')
434 expr
= strip_parens(expr
->unop
);
436 sym
= expr_to_sym(expr
);
437 if (!sym
|| !sym
->ident
)
439 if (!type_bytes(sym
))
441 if (sym
->type
!= SYM_NODE
)
444 base_sym
= get_real_base_type(sym
);
445 if (!base_sym
|| base_sym
->type
!= SYM_PTR
)
447 base_sym
= get_real_base_type(base_sym
);
448 if (!base_sym
|| base_sym
->type
!= SYM_STRUCT
)
451 if (!is_last_member_of_struct(base_sym
, expr
->member
))
453 if (!last_member_is_resizable(base_sym
))
456 state
= get_state(my_size_id
, sym
->ident
->name
, sym
);
457 if (!estate_to_size(state
) || estate_to_size(state
) == -1)
460 return estate_to_size(state
) - type_bytes(base_sym
) + type_bytes(get_type(expr
));
463 static struct range_list
*alloc_int_rl(int value
)
470 return alloc_rl(sval
, sval
);
473 struct range_list
*get_array_size_bytes_rl(struct expression
*expr
)
475 struct range_list
*ret
= NULL
;
479 if (is_fake_call(expr
))
482 expr
= remove_addr_fluff(expr
);
487 if (expr
->type
== EXPR_STRING
)
488 return alloc_int_rl(expr
->string
->length
);
490 if (expr
->type
== EXPR_BINOP
&& expr
->op
== '+') {
495 if (!get_implied_value(expr
->right
, &offset
))
497 type
= get_type(expr
->left
);
500 if (type
->type
!= SYM_ARRAY
&& type
->type
!= SYM_PTR
)
502 type
= get_real_base_type(type
);
503 bytes
= type_bytes(type
);
506 offset
.value
*= bytes
;
507 size
= get_array_size_bytes(expr
->left
);
510 return alloc_int_rl(size
- offset
.value
);
513 /* buf = malloc(1024); */
514 ret
= get_stored_size_bytes(expr
);
518 size
= get_stored_size_end_struct_bytes(expr
);
520 return alloc_int_rl(size
);
523 size
= get_real_array_size(expr
);
525 return alloc_int_rl(elements_to_bytes(expr
, size
));
527 /* char *foo = "BAR" */
528 size
= get_size_from_initializer(expr
);
530 return alloc_int_rl(elements_to_bytes(expr
, size
));
532 size
= get_bytes_from_address(expr
);
534 return alloc_int_rl(size
);
536 ret
= size_from_db(expr
);
537 if (rl_to_sval(ret
, &sval
) && sval
.value
== -1)
545 int get_array_size_bytes(struct expression
*expr
)
547 struct range_list
*rl
;
550 rl
= get_array_size_bytes_rl(expr
);
551 if (!rl_to_sval(rl
, &sval
))
553 if (sval
.uvalue
>= INT_MAX
)
558 int get_array_size_bytes_max(struct expression
*expr
)
560 struct range_list
*rl
;
563 rl
= get_array_size_bytes_rl(expr
);
570 if (bytes
.uvalue
>= INT_MAX
)
575 int get_array_size_bytes_min(struct expression
*expr
)
577 struct range_list
*rl
;
578 struct data_range
*range
;
580 rl
= get_array_size_bytes_rl(expr
);
584 FOR_EACH_PTR(rl
, range
) {
585 if (range
->min
.value
<= 0)
587 if (range
->max
.value
<= 0)
589 if (range
->min
.uvalue
>= INT_MAX
)
591 return range
->min
.value
;
592 } END_FOR_EACH_PTR(range
);
597 int get_array_size(struct expression
*expr
)
601 return bytes_to_elements(expr
, get_array_size_bytes_max(expr
));
604 static struct expression
*strip_ampersands(struct expression
*expr
)
608 if (expr
->type
!= EXPR_PREOP
)
612 type
= get_type(expr
->unop
);
613 if (!type
|| type
->type
!= SYM_ARRAY
)
618 static void info_record_alloction(struct expression
*buffer
, struct range_list
*rl
)
625 name
= get_member_name(buffer
);
626 if (!name
&& is_static(buffer
))
627 name
= expr_to_var(buffer
);
630 if (rl
&& !is_whole_rl(rl
))
631 sql_insert_function_type_size(name
, show_rl(rl
));
633 sql_insert_function_type_size(name
, "(-1)");
638 static void store_alloc(struct expression
*expr
, struct range_list
*rl
)
642 rl
= clone_rl(rl
); // FIXME!!!
644 rl
= size_to_rl(UNKNOWN_SIZE
);
646 if (rl_min(rl
).value
!= UNKNOWN_SIZE
||
647 rl_max(rl
).value
!= UNKNOWN_SIZE
||
648 get_state_expr(my_size_id
, expr
))
649 set_state_expr(my_size_id
, expr
, alloc_estate_rl(rl
));
651 type
= get_type(expr
);
654 if (type
->type
!= SYM_PTR
)
656 type
= get_real_base_type(type
);
659 if (type
== &void_ctype
)
661 if (type
->type
!= SYM_BASETYPE
&& type
->type
!= SYM_PTR
)
664 info_record_alloction(expr
, rl
);
667 static bool is_array_base(struct expression
*expr
)
671 type
= get_type(expr
);
672 if (type
&& type
->type
== SYM_ARRAY
)
677 static void match_array_assignment(struct expression
*expr
)
679 struct expression
*left
;
680 struct expression
*right
;
681 char *left_member
, *right_member
;
682 struct range_list
*rl
;
688 left
= strip_expr(expr
->left
);
689 right
= strip_expr(expr
->right
);
690 right
= strip_ampersands(right
);
692 if (!is_pointer(left
))
694 /* char buf[24] = "str"; */
695 if (is_array_base(left
))
697 if (is_allocation_function(right
))
700 left_member
= get_member_name(left
);
701 right_member
= get_member_name(right
);
702 if (left_member
&& right_member
&& strcmp(left_member
, right_member
) == 0) {
703 free_string(left_member
);
704 free_string(right_member
);
707 free_string(left_member
);
708 free_string(right_member
);
710 if (get_implied_value(right
, &sval
) && sval
.value
== 0) {
711 rl
= alloc_int_rl(0);
715 rl
= get_array_size_bytes_rl(right
);
716 if (!rl
&& __in_fake_assign
)
720 store_alloc(left
, rl
);
723 static void match_alloc(const char *fn
, struct expression
*expr
, void *_size_arg
)
725 int size_arg
= PTR_INT(_size_arg
);
726 struct expression
*right
;
727 struct expression
*arg
;
728 struct range_list
*rl
;
730 right
= strip_expr(expr
->right
);
731 arg
= get_argument_from_call_expr(right
->args
, size_arg
);
732 get_absolute_rl(arg
, &rl
);
733 rl
= cast_rl(&int_ctype
, rl
);
734 store_alloc(expr
->left
, rl
);
737 static void match_calloc(const char *fn
, struct expression
*expr
, void *_param
)
739 struct expression
*right
;
740 struct expression
*size
, *nr
, *mult
;
741 struct range_list
*rl
;
742 int param
= PTR_INT(_param
);
744 right
= strip_expr(expr
->right
);
745 nr
= get_argument_from_call_expr(right
->args
, param
);
746 size
= get_argument_from_call_expr(right
->args
, param
+ 1);
747 mult
= binop_expression(nr
, '*', size
);
748 if (get_implied_rl(mult
, &rl
))
749 store_alloc(expr
->left
, rl
);
751 store_alloc(expr
->left
, size_to_rl(UNKNOWN_SIZE
));
754 static void match_page(const char *fn
, struct expression
*expr
, void *_unused
)
761 store_alloc(expr
->left
, alloc_rl(page_size
, page_size
));
764 static void match_strndup(const char *fn
, struct expression
*expr
, void *unused
)
766 struct expression
*fn_expr
;
767 struct expression
*size_expr
;
770 fn_expr
= strip_expr(expr
->right
);
771 size_expr
= get_argument_from_call_expr(fn_expr
->args
, 1);
772 if (get_implied_max(size_expr
, &size
)) {
774 store_alloc(expr
->left
, size_to_rl(size
.value
));
776 store_alloc(expr
->left
, size_to_rl(UNKNOWN_SIZE
));
781 static void match_alloc_pages(const char *fn
, struct expression
*expr
, void *_order_arg
)
783 int order_arg
= PTR_INT(_order_arg
);
784 struct expression
*right
;
785 struct expression
*arg
;
788 right
= strip_expr(expr
->right
);
789 arg
= get_argument_from_call_expr(right
->args
, order_arg
);
790 if (!get_implied_value(arg
, &sval
))
792 if (sval
.value
< 0 || sval
.value
> 10)
795 sval
.type
= &int_ctype
;
796 sval
.value
= 1 << sval
.value
;
799 store_alloc(expr
->left
, alloc_rl(sval
, sval
));
802 static int is_type_bytes(struct range_list
*rl
, struct expression
*arg
)
807 if (!rl_to_sval(rl
, &sval
))
810 type
= get_type(arg
);
813 if (type
->type
!= SYM_PTR
)
815 type
= get_real_base_type(type
);
816 if (type
->type
!= SYM_STRUCT
&&
817 type
->type
!= SYM_UNION
)
819 if (sval
.value
!= type_bytes(type
))
824 static void match_call(struct expression
*expr
)
826 struct expression
*arg
;
828 struct range_list
*rl
;
832 FOR_EACH_PTR(expr
->args
, arg
) {
834 type
= get_type(arg
);
835 if (!type
|| (type
->type
!= SYM_PTR
&& type
->type
!= SYM_ARRAY
))
837 rl
= get_array_size_bytes_rl(arg
);
840 if (rl_min(rl
).value
== UNKNOWN_SIZE
&&
841 rl_max(rl
).value
== UNKNOWN_SIZE
)
845 if (is_type_bytes(rl
, arg
))
847 sql_insert_caller_info(expr
, BUF_SIZE
, i
, "$", show_rl(rl
));
848 } END_FOR_EACH_PTR(arg
);
851 static void struct_member_callback(struct expression
*call
, int param
, char *printed_name
, struct sm_state
*sm
)
855 if (!estate_rl(sm
->state
) ||
856 (estate_get_single_value(sm
->state
, &sval
) &&
857 (sval
.value
== -1 || sval
.value
== 0)))
860 sql_insert_caller_info(call
, BUF_SIZE
, param
, printed_name
, sm
->state
->name
);
864 * This is slightly (very) weird because half of this stuff is handled in
865 * smatch_parse_call_math.c which is poorly named. But anyway, add some buf
869 static void print_returned_allocations(int return_id
, char *return_ranges
, struct expression
*expr
)
871 const char *param_math
;
872 struct range_list
*rl
;
876 rl
= get_array_size_bytes_rl(expr
);
877 param_math
= get_allocation_math(expr
);
878 if (!rl
&& !param_math
)
882 rl_to_sval(rl
, &sval
) &&
883 (sval
.value
== -1 || sval
.value
== 0))
887 snprintf(buf
, sizeof(buf
), "%s[%s]", show_rl(rl
), param_math
);
889 snprintf(buf
, sizeof(buf
), "%s", show_rl(rl
));
891 // FIXME: don't store if you can guess the size from the type
892 // FIXME: return if we allocate a parameter $0->bar
893 sql_insert_return_states(return_id
, return_ranges
, BUF_SIZE
, -1, "", buf
);
896 static void record_global_size(struct symbol
*sym
)
904 if (!(sym
->ctype
.modifiers
& MOD_TOPLEVEL
) ||
905 sym
->ctype
.modifiers
& MOD_STATIC
)
908 bytes
= get_array_size_bytes(symbol_expression(sym
));
912 snprintf(buf
, sizeof(buf
), "%d", bytes
);
913 sql_insert_data_info_var_sym(sym
->ident
->name
, sym
, BUF_SIZE
, buf
);
916 void register_buf_size(int id
)
920 set_dynamic_states(my_size_id
);
922 add_unmatched_state_hook(my_size_id
, &unmatched_size_state
);
923 add_merge_hook(my_size_id
, &merge_estates
);
925 select_caller_info_hook(set_param_buf_size
, BUF_SIZE
);
926 select_return_states_hook(BUF_SIZE
, &db_returns_buf_size
);
927 add_split_return_callback(print_returned_allocations
);
929 allocation_funcs
= create_function_hashtable(100);
930 add_allocation_function("malloc", &match_alloc
, 0);
931 add_allocation_function("calloc", &match_calloc
, 0);
932 add_allocation_function("memdup", &match_alloc
, 1);
933 add_allocation_function("realloc", &match_alloc
, 1);
934 if (option_project
== PROJ_KERNEL
) {
935 add_allocation_function("kmalloc", &match_alloc
, 0);
936 add_allocation_function("kmalloc_node", &match_alloc
, 0);
937 add_allocation_function("kzalloc", &match_alloc
, 0);
938 add_allocation_function("kzalloc_node", &match_alloc
, 0);
939 add_allocation_function("vmalloc", &match_alloc
, 0);
940 add_allocation_function("vzalloc", &match_alloc
, 0);
941 add_allocation_function("__vmalloc", &match_alloc
, 0);
942 add_allocation_function("kvmalloc", &match_alloc
, 0);
943 add_allocation_function("kcalloc", &match_calloc
, 0);
944 add_allocation_function("kmalloc_array", &match_calloc
, 0);
945 add_allocation_function("devm_kmalloc_array", &match_calloc
, 1);
946 add_allocation_function("sock_kmalloc", &match_alloc
, 1);
947 add_allocation_function("kmemdup", &match_alloc
, 1);
948 add_allocation_function("kmemdup_user", &match_alloc
, 1);
949 add_allocation_function("dma_alloc_attrs", &match_alloc
, 1);
950 add_allocation_function("pci_alloc_consistent", &match_alloc
, 1);
951 add_allocation_function("pci_alloc_coherent", &match_alloc
, 1);
952 add_allocation_function("devm_kmalloc", &match_alloc
, 1);
953 add_allocation_function("devm_kzalloc", &match_alloc
, 1);
954 add_allocation_function("krealloc", &match_alloc
, 1);
955 add_allocation_function("__alloc_bootmem", &match_alloc
, 0);
956 add_allocation_function("alloc_bootmem", &match_alloc
, 0);
957 add_allocation_function("kmap", &match_page
, 0);
958 add_allocation_function("kmap_atomic", &match_page
, 0);
959 add_allocation_function("get_zeroed_page", &match_page
, 0);
960 add_allocation_function("alloc_page", &match_page
, 0);
961 add_allocation_function("alloc_pages", &match_alloc_pages
, 1);
962 add_allocation_function("alloc_pages_current", &match_alloc_pages
, 1);
963 add_allocation_function("__get_free_pages", &match_alloc_pages
, 1);
964 add_allocation_function("dma_alloc_contiguous", &match_alloc
, 1);
965 add_allocation_function("dma_alloc_coherent", &match_alloc
, 1);
968 add_allocation_function("strndup", match_strndup
, 0);
969 if (option_project
== PROJ_KERNEL
)
970 add_allocation_function("kstrndup", match_strndup
, 0);
972 add_modification_hook(my_size_id
, &set_size_undefined
);
974 add_merge_hook(my_size_id
, &merge_size_func
);
977 add_hook(record_global_size
, BASE_HOOK
);
980 void register_buf_size_late(int id
)
982 /* has to happen after match_alloc() */
983 add_hook(&match_array_assignment
, ASSIGNMENT_HOOK
);
985 add_hook(&match_call
, FUNCTION_CALL_HOOK
);
986 add_member_info_callback(my_size_id
, struct_member_callback
);