2 * Copyright (C) 2008 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
19 * smatch_extra.c is supposed to track the value of every variable.
31 #include "smatch_slist.h"
32 #include "smatch_extra.h"
36 struct string_list
*__ignored_macros
= NULL
;
37 static int in_warn_on_macro()
39 struct statement
*stmt
;
43 stmt
= get_current_statement();
46 macro
= get_macro_name(stmt
->pos
);
50 FOR_EACH_PTR(__ignored_macros
, tmp
) {
51 if (!strcmp(tmp
, macro
))
53 } END_FOR_EACH_PTR(tmp
);
57 typedef void (mod_hook
)(const char *name
, struct symbol
*sym
, struct smatch_state
*state
);
58 DECLARE_PTR_LIST(void_fn_list
, mod_hook
*);
59 static struct void_fn_list
*extra_mod_hooks
;
60 void add_extra_mod_hook(mod_hook
*fn
)
62 mod_hook
**p
= malloc(sizeof(mod_hook
*));
64 add_ptr_list(&extra_mod_hooks
, p
);
67 void call_extra_mod_hooks(const char *name
, struct symbol
*sym
, struct smatch_state
*state
)
71 FOR_EACH_PTR(extra_mod_hooks
, fn
) {
72 (*fn
)(name
, sym
, state
);
73 } END_FOR_EACH_PTR(fn
);
76 struct sm_state
*set_extra_mod(const char *name
, struct symbol
*sym
, struct smatch_state
*state
)
78 if (in_warn_on_macro())
80 remove_from_equiv(name
, sym
);
81 call_extra_mod_hooks(name
, sym
, state
);
82 return set_state(SMATCH_EXTRA
, name
, sym
, state
);
85 struct sm_state
*set_extra_expr_mod(struct expression
*expr
, struct smatch_state
*state
)
89 struct sm_state
*ret
= NULL
;
91 expr
= strip_expr(expr
);
92 name
= expr_to_var_sym(expr
, &sym
);
95 ret
= set_extra_mod(name
, sym
, state
);
101 void set_extra_nomod(const char *name
, struct symbol
*sym
, struct smatch_state
*state
)
103 struct relation
*rel
;
104 struct smatch_state
*orig_state
;
106 orig_state
= get_state(SMATCH_EXTRA
, name
, sym
);
108 if (!estate_related(orig_state
)) {
109 set_state(SMATCH_EXTRA
, name
, sym
, state
);
113 set_related(state
, estate_related(orig_state
));
114 FOR_EACH_PTR(estate_related(orig_state
), rel
) {
115 if (option_debug_related
)
116 sm_msg("updating related %s to %s", rel
->name
, state
->name
);
117 set_state(SMATCH_EXTRA
, rel
->name
, rel
->sym
, state
);
118 } END_FOR_EACH_PTR(rel
);
122 * This is for return_implies_state() hooks which modify a SMATCH_EXTRA state
124 void set_extra_expr_nomod(struct expression
*expr
, struct smatch_state
*state
)
129 name
= expr_to_var_sym(expr
, &sym
);
132 set_extra_nomod(name
, sym
, state
);
138 static void set_extra_true_false(const char *name
, struct symbol
*sym
,
139 struct smatch_state
*true_state
,
140 struct smatch_state
*false_state
)
142 struct relation
*rel
;
143 struct smatch_state
*orig_state
;
145 if (in_warn_on_macro())
148 orig_state
= get_state(SMATCH_EXTRA
, name
, sym
);
150 if (!estate_related(orig_state
)) {
151 set_true_false_states(SMATCH_EXTRA
, name
, sym
, true_state
, false_state
);
156 set_related(true_state
, estate_related(orig_state
));
158 set_related(false_state
, estate_related(orig_state
));
160 FOR_EACH_PTR(estate_related(orig_state
), rel
) {
161 set_true_false_states(SMATCH_EXTRA
, rel
->name
, rel
->sym
,
162 true_state
, false_state
);
163 } END_FOR_EACH_PTR(rel
);
166 static void set_extra_expr_true_false(struct expression
*expr
,
167 struct smatch_state
*true_state
,
168 struct smatch_state
*false_state
)
173 expr
= strip_expr(expr
);
174 name
= expr_to_var_sym(expr
, &sym
);
177 set_extra_true_false(name
, sym
, true_state
, false_state
);
182 static struct sm_state
*handle_canonical_while_count_down(struct statement
*loop
)
184 struct expression
*iter_var
;
185 struct expression
*condition
;
187 struct smatch_state
*estate
;
190 condition
= strip_expr(loop
->iterator_pre_condition
);
193 if (condition
->type
!= EXPR_PREOP
&& condition
->type
!= EXPR_POSTOP
)
195 if (condition
->op
!= SPECIAL_DECREMENT
)
198 iter_var
= condition
->unop
;
199 sm
= get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
202 if (sval_cmp_val(estate_min(sm
->state
), 0) < 0)
204 start
= estate_max(sm
->state
);
205 if (sval_cmp_val(start
, 0) <= 0)
207 if (!sval_is_max(start
))
210 if (condition
->type
== EXPR_PREOP
) {
211 estate
= alloc_estate_range(sval_type_val(start
.type
, 1), start
);
212 if (estate_has_hard_max(sm
->state
))
213 estate_set_hard_max(estate
);
214 estate_copy_fuzzy_max(estate
, sm
->state
);
215 set_extra_expr_mod(iter_var
, estate
);
217 if (condition
->type
== EXPR_POSTOP
) {
218 estate
= alloc_estate_range(sval_type_val(start
.type
, 0), start
);
219 if (estate_has_hard_max(sm
->state
))
220 estate_set_hard_max(estate
);
221 estate_copy_fuzzy_max(estate
, sm
->state
);
222 set_extra_expr_mod(iter_var
, estate
);
224 return get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
227 static struct sm_state
*handle_canonical_for_inc(struct expression
*iter_expr
,
228 struct expression
*condition
)
230 struct expression
*iter_var
;
232 struct smatch_state
*estate
;
233 sval_t start
, end
, max
;
235 iter_var
= iter_expr
->unop
;
236 sm
= get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
239 if (!estate_get_single_value(sm
->state
, &start
))
241 if (get_implied_max(condition
->right
, &end
))
242 end
= sval_cast(get_type(iter_var
), end
);
244 end
= sval_type_max(get_type(iter_var
));
246 if (get_sm_state_expr(SMATCH_EXTRA
, condition
->left
) != sm
)
249 switch (condition
->op
) {
250 case SPECIAL_UNSIGNED_LT
:
251 case SPECIAL_NOTEQUAL
:
253 if (!sval_is_min(end
))
256 case SPECIAL_UNSIGNED_LTE
:
262 if (sval_cmp(end
, start
) < 0)
264 estate
= alloc_estate_range(start
, end
);
265 if (get_hard_max(condition
->right
, &max
)) {
266 estate_set_hard_max(estate
);
267 if (condition
->op
== '<' ||
268 condition
->op
== SPECIAL_UNSIGNED_LT
||
269 condition
->op
== SPECIAL_NOTEQUAL
)
271 estate_set_fuzzy_max(estate
, max
);
273 set_extra_expr_mod(iter_var
, estate
);
274 return get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
277 static struct sm_state
*handle_canonical_for_dec(struct expression
*iter_expr
,
278 struct expression
*condition
)
280 struct expression
*iter_var
;
282 struct smatch_state
*estate
;
285 iter_var
= iter_expr
->unop
;
286 sm
= get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
289 if (!estate_get_single_value(sm
->state
, &start
))
291 if (!get_implied_min(condition
->right
, &end
))
292 end
= sval_type_min(get_type(iter_var
));
293 if (get_sm_state_expr(SMATCH_EXTRA
, condition
->left
) != sm
)
296 switch (condition
->op
) {
297 case SPECIAL_NOTEQUAL
:
299 if (!sval_is_min(end
) && !sval_is_max(end
))
307 if (sval_cmp(end
, start
) > 0)
309 estate
= alloc_estate_range(end
, start
);
310 estate_set_hard_max(estate
);
311 estate_set_fuzzy_max(estate
, estate_get_fuzzy_max(estate
));
312 set_extra_expr_mod(iter_var
, estate
);
313 return get_sm_state_expr(SMATCH_EXTRA
, iter_var
);
316 static struct sm_state
*handle_canonical_for_loops(struct statement
*loop
)
318 struct expression
*iter_expr
;
319 struct expression
*condition
;
321 if (!loop
->iterator_post_statement
)
323 if (loop
->iterator_post_statement
->type
!= STMT_EXPRESSION
)
325 iter_expr
= loop
->iterator_post_statement
->expression
;
326 if (!loop
->iterator_pre_condition
)
328 if (loop
->iterator_pre_condition
->type
!= EXPR_COMPARE
)
330 condition
= loop
->iterator_pre_condition
;
332 if (iter_expr
->op
== SPECIAL_INCREMENT
)
333 return handle_canonical_for_inc(iter_expr
, condition
);
334 if (iter_expr
->op
== SPECIAL_DECREMENT
)
335 return handle_canonical_for_dec(iter_expr
, condition
);
339 struct sm_state
*__extra_handle_canonical_loops(struct statement
*loop
, struct stree
**stree
)
341 struct sm_state
*ret
;
343 __push_fake_cur_stree();
344 if (!loop
->iterator_post_statement
)
345 ret
= handle_canonical_while_count_down(loop
);
347 ret
= handle_canonical_for_loops(loop
);
348 *stree
= __pop_fake_cur_stree();
352 int __iterator_unchanged(struct sm_state
*sm
)
356 if (get_sm_state(my_id
, sm
->name
, sm
->sym
) == sm
)
361 static void while_count_down_after(struct sm_state
*sm
, struct expression
*condition
)
365 /* paranoid checking. prolly not needed */
366 condition
= strip_expr(condition
);
369 if (condition
->type
!= EXPR_PREOP
&& condition
->type
!= EXPR_POSTOP
)
371 if (condition
->op
!= SPECIAL_DECREMENT
)
373 after_value
= estate_min(sm
->state
);
375 set_extra_mod(sm
->name
, sm
->sym
, alloc_estate_sval(after_value
));
378 void __extra_pre_loop_hook_after(struct sm_state
*sm
,
379 struct statement
*iterator
,
380 struct expression
*condition
)
382 struct expression
*iter_expr
;
384 struct smatch_state
*state
;
387 while_count_down_after(sm
, condition
);
391 iter_expr
= iterator
->expression
;
393 if (condition
->type
!= EXPR_COMPARE
)
395 if (iter_expr
->op
== SPECIAL_INCREMENT
) {
396 limit
= sval_binop(estate_max(sm
->state
), '+',
397 sval_type_val(estate_type(sm
->state
), 1));
399 limit
= sval_binop(estate_min(sm
->state
), '-',
400 sval_type_val(estate_type(sm
->state
), 1));
402 if (!estate_has_hard_max(sm
->state
) && !__has_breaks()) {
403 if (iter_expr
->op
== SPECIAL_INCREMENT
)
404 state
= alloc_estate_range(estate_min(sm
->state
), limit
);
406 state
= alloc_estate_range(limit
, estate_max(sm
->state
));
408 state
= alloc_estate_sval(limit
);
410 if (!estate_has_hard_max(sm
->state
)) {
411 estate_clear_hard_max(state
);
413 if (estate_has_fuzzy_max(sm
->state
)) {
414 sval_t hmax
= estate_get_fuzzy_max(sm
->state
);
415 sval_t max
= estate_max(sm
->state
);
417 if (sval_cmp(hmax
, max
) != 0)
418 estate_clear_fuzzy_max(state
);
419 } else if (!estate_has_fuzzy_max(sm
->state
)) {
420 estate_clear_fuzzy_max(state
);
423 set_extra_mod(sm
->name
, sm
->sym
, state
);
426 static struct stree
*unmatched_stree
;
427 static struct smatch_state
*unmatched_state(struct sm_state
*sm
)
429 struct smatch_state
*state
;
431 if (unmatched_stree
) {
432 state
= get_state_stree(unmatched_stree
, SMATCH_EXTRA
, sm
->name
, sm
->sym
);
436 return alloc_estate_whole(estate_type(sm
->state
));
439 static void clear_the_pointed_at(struct expression
*expr
, struct stree
*stree
)
443 struct sm_state
*tmp
;
445 name
= expr_to_var_sym(expr
, &sym
);
449 FOR_EACH_SM(stree
, tmp
) {
450 if (tmp
->name
[0] != '*')
454 if (strcmp(tmp
->name
+ 1, name
) != 0)
456 set_extra_mod(tmp
->name
, tmp
->sym
, alloc_estate_whole(estate_type(tmp
->state
)));
457 } END_FOR_EACH_SM(tmp
);
463 static void match_function_call(struct expression
*expr
)
465 struct expression
*arg
;
466 struct expression
*tmp
;
469 /* if we have the db this is handled in smatch_function_hooks.c */
472 if (inlinable(expr
->fn
))
475 stree
= get_all_states_stree(SMATCH_EXTRA
);
477 FOR_EACH_PTR(expr
->args
, arg
) {
478 tmp
= strip_expr(arg
);
479 if (tmp
->type
== EXPR_PREOP
&& tmp
->op
== '&')
480 set_extra_expr_mod(tmp
->unop
, alloc_estate_whole(get_type(tmp
->unop
)));
482 clear_the_pointed_at(tmp
, stree
);
483 } END_FOR_EACH_PTR(arg
);
488 static int types_equiv_or_pointer(struct symbol
*one
, struct symbol
*two
)
492 if (one
->type
== SYM_PTR
&& two
->type
== SYM_PTR
)
494 return types_equiv(one
, two
);
497 static void match_vanilla_assign(struct expression
*left
, struct expression
*right
)
499 struct range_list
*rl
= NULL
;
500 struct symbol
*right_sym
;
501 struct symbol
*left_type
;
502 struct symbol
*right_type
;
503 char *right_name
= NULL
;
507 struct smatch_state
*state
;
509 name
= expr_to_var_sym(left
, &sym
);
513 left_type
= get_type(left
);
514 right_type
= get_type(right
);
516 right_name
= expr_to_var_sym(right
, &right_sym
);
517 if (right_name
&& right_sym
&&
518 types_equiv_or_pointer(left_type
, right_type
)) {
519 set_equiv(left
, right
);
523 if (get_implied_rl(right
, &rl
)) {
524 rl
= cast_rl(left_type
, rl
);
525 state
= alloc_estate_rl(rl
);
526 if (get_hard_max(right
, &max
)) {
527 estate_set_hard_max(state
);
528 estate_set_fuzzy_max(state
, max
);
531 rl
= alloc_whole_rl(right_type
);
532 rl
= cast_rl(left_type
, rl
);
533 state
= alloc_estate_rl(rl
);
535 set_extra_mod(name
, sym
, state
);
537 free_string(right_name
);
540 static int op_remove_assign(int op
)
543 case SPECIAL_ADD_ASSIGN
:
545 case SPECIAL_SUB_ASSIGN
:
547 case SPECIAL_MUL_ASSIGN
:
549 case SPECIAL_DIV_ASSIGN
:
551 case SPECIAL_MOD_ASSIGN
:
553 case SPECIAL_AND_ASSIGN
:
555 case SPECIAL_OR_ASSIGN
:
557 case SPECIAL_XOR_ASSIGN
:
559 case SPECIAL_SHL_ASSIGN
:
560 return SPECIAL_LEFTSHIFT
;
561 case SPECIAL_SHR_ASSIGN
:
562 return SPECIAL_RIGHTSHIFT
;
568 static void match_assign(struct expression
*expr
)
570 struct range_list
*rl
= NULL
;
571 struct expression
*left
;
572 struct expression
*right
;
573 struct expression
*binop_expr
;
574 struct symbol
*left_type
;
575 struct symbol
*right_type
;
578 sval_t left_min
, left_max
;
579 sval_t right_min
, right_max
;
580 sval_t res_min
, res_max
;
582 left
= strip_expr(expr
->left
);
584 right
= strip_expr(expr
->right
);
585 while (right
->type
== EXPR_ASSIGNMENT
&& right
->op
== '=')
586 right
= strip_expr(right
->left
);
588 if (is_condition(expr
->right
))
589 return; /* handled in smatch_condition.c */
590 if (expr
->op
== '=' && right
->type
== EXPR_CALL
)
591 return; /* handled in smatch_function_hooks.c */
592 if (expr
->op
== '=') {
593 match_vanilla_assign(left
, right
);
597 name
= expr_to_var_sym(left
, &sym
);
601 left_type
= get_type(left
);
602 right_type
= get_type(right
);
604 res_min
= sval_type_min(left_type
);
605 res_max
= sval_type_max(left_type
);
608 case SPECIAL_ADD_ASSIGN
:
609 get_absolute_max(left
, &left_max
);
610 get_absolute_max(right
, &right_max
);
611 if (sval_binop_overflows(left_max
, '+', right_max
))
613 if (get_implied_min(left
, &left_min
) &&
614 !sval_is_negative_min(left_min
) &&
615 get_implied_min(right
, &right_min
) &&
616 !sval_is_negative_min(right_min
)) {
617 res_min
= sval_binop(left_min
, '+', right_min
);
618 res_min
= sval_cast(right_type
, res_min
);
620 if (inside_loop()) /* we are assuming loops don't lead to wrapping */
622 res_max
= sval_binop(left_max
, '+', right_max
);
623 res_max
= sval_cast(right_type
, res_max
);
625 case SPECIAL_SUB_ASSIGN
:
626 if (get_implied_max(left
, &left_max
) &&
627 !sval_is_max(left_max
) &&
628 get_implied_min(right
, &right_min
) &&
629 !sval_is_min(right_min
)) {
630 res_max
= sval_binop(left_max
, '-', right_min
);
631 res_max
= sval_cast(right_type
, res_max
);
635 if (get_implied_min(left
, &left_min
) &&
636 !sval_is_min(left_min
) &&
637 get_implied_max(right
, &right_max
) &&
638 !sval_is_max(right_max
)) {
639 res_min
= sval_binop(left_min
, '-', right_max
);
640 res_min
= sval_cast(right_type
, res_min
);
643 case SPECIAL_AND_ASSIGN
:
644 case SPECIAL_MOD_ASSIGN
:
645 case SPECIAL_SHL_ASSIGN
:
646 case SPECIAL_SHR_ASSIGN
:
647 case SPECIAL_OR_ASSIGN
:
648 case SPECIAL_XOR_ASSIGN
:
649 case SPECIAL_MUL_ASSIGN
:
650 case SPECIAL_DIV_ASSIGN
:
651 binop_expr
= binop_expression(expr
->left
,
652 op_remove_assign(expr
->op
),
654 if (get_absolute_rl(binop_expr
, &rl
)) {
655 rl
= cast_rl(left_type
, rl
);
656 set_extra_mod(name
, sym
, alloc_estate_rl(rl
));
661 rl
= cast_rl(left_type
, alloc_rl(res_min
, res_max
));
662 set_extra_mod(name
, sym
, alloc_estate_rl(rl
));
667 static struct smatch_state
*increment_state(struct smatch_state
*state
)
669 sval_t min
= estate_min(state
);
670 sval_t max
= estate_max(state
);
672 if (!estate_rl(state
))
676 max
= sval_type_max(max
.type
);
678 if (!sval_is_min(min
) && !sval_is_max(min
))
680 if (!sval_is_min(max
) && !sval_is_max(max
))
682 return alloc_estate_range(min
, max
);
685 static struct smatch_state
*decrement_state(struct smatch_state
*state
)
687 sval_t min
= estate_min(state
);
688 sval_t max
= estate_max(state
);
690 if (!estate_rl(state
))
694 min
= sval_type_min(min
.type
);
696 if (!sval_is_min(min
) && !sval_is_max(min
))
698 if (!sval_is_min(max
) && !sval_is_max(max
))
700 return alloc_estate_range(min
, max
);
703 static void unop_expr(struct expression
*expr
)
705 struct smatch_state
*state
;
707 if (expr
->smatch_flags
& Handled
)
711 case SPECIAL_INCREMENT
:
712 state
= get_state_expr(SMATCH_EXTRA
, expr
->unop
);
713 state
= increment_state(state
);
715 state
= alloc_estate_whole(get_type(expr
));
716 set_extra_expr_mod(expr
->unop
, state
);
718 case SPECIAL_DECREMENT
:
719 state
= get_state_expr(SMATCH_EXTRA
, expr
->unop
);
720 state
= decrement_state(state
);
722 state
= alloc_estate_whole(get_type(expr
));
723 set_extra_expr_mod(expr
->unop
, state
);
730 static void asm_expr(struct statement
*stmt
)
733 struct expression
*expr
;
737 FOR_EACH_PTR(stmt
->asm_outputs
, expr
) {
739 case 0: /* identifier */
740 case 1: /* constraint */
743 case 2: /* expression */
745 type
= get_type(strip_expr(expr
));
746 set_extra_expr_mod(expr
, alloc_estate_whole(type
));
749 } END_FOR_EACH_PTR(expr
);
752 static void delete_state_tracker(struct tracker
*t
)
754 remove_from_equiv(t
->name
, t
->sym
);
755 delete_state(t
->owner
, t
->name
, t
->sym
);
758 static void scoped_state_extra(const char *name
, struct symbol
*sym
)
762 t
= alloc_tracker(SMATCH_EXTRA
, name
, sym
);
763 add_scope_hook((scope_hook
*)&delete_state_tracker
, t
);
766 static void match_declarations(struct symbol
*sym
)
771 name
= sym
->ident
->name
;
772 if (!sym
->initializer
) {
773 set_state(SMATCH_EXTRA
, name
, sym
, alloc_estate_whole(get_real_base_type(sym
)));
774 scoped_state_extra(name
, sym
);
779 static void check_dereference(struct expression
*expr
)
781 if (outside_of_function())
783 set_extra_expr_nomod(expr
, alloc_estate_range(valid_ptr_min_sval
, valid_ptr_max_sval
));
786 static void match_dereferences(struct expression
*expr
)
788 if (expr
->type
!= EXPR_PREOP
)
790 check_dereference(expr
->unop
);
793 static void match_pointer_as_array(struct expression
*expr
)
797 check_dereference(expr
->unop
->left
);
800 static void set_param_dereferenced(struct expression
*arg
, char *unused
)
802 check_dereference(arg
);
805 static void match_function_def(struct symbol
*sym
)
809 FOR_EACH_PTR(sym
->ctype
.base_type
->arguments
, arg
) {
812 set_state(my_id
, arg
->ident
->name
, arg
, alloc_estate_whole(get_real_base_type(arg
)));
813 } END_FOR_EACH_PTR(arg
);
816 static sval_t
add_one(sval_t sval
)
822 static sval_t
sub_one(sval_t sval
)
828 static void handle_comparison(struct symbol
*type
, struct expression
*left
, int op
, struct expression
*right
)
830 struct range_list
*left_orig
;
831 struct range_list
*left_true
;
832 struct range_list
*left_false
;
833 struct range_list
*right_orig
;
834 struct range_list
*right_true
;
835 struct range_list
*right_false
;
836 struct smatch_state
*left_true_state
;
837 struct smatch_state
*left_false_state
;
838 struct smatch_state
*right_true_state
;
839 struct smatch_state
*right_false_state
;
840 sval_t min
, max
, dummy
, hard_max
;
842 int right_postop
= 0;
844 if (left
->op
== SPECIAL_INCREMENT
|| left
->op
== SPECIAL_DECREMENT
) {
845 if (left
->type
== EXPR_POSTOP
) {
846 left
->smatch_flags
|= Handled
;
847 left_postop
= left
->op
;
849 left
= strip_expr(left
->unop
);
851 while (left
->type
== EXPR_ASSIGNMENT
)
852 left
= strip_expr(left
->left
);
854 if (right
->op
== SPECIAL_INCREMENT
|| right
->op
== SPECIAL_DECREMENT
) {
855 if (right
->type
== EXPR_POSTOP
) {
856 right
->smatch_flags
|= Handled
;
857 right_postop
= right
->op
;
859 right
= strip_expr(right
->unop
);
862 if (get_implied_rl(left
, &left_orig
)) {
863 left_orig
= cast_rl(type
, left_orig
);
865 min
= sval_type_min(get_type(left
));
866 max
= sval_type_max(get_type(left
));
867 left_orig
= cast_rl(type
, alloc_rl(min
, max
));
870 if (get_implied_rl(right
, &right_orig
)) {
871 right_orig
= cast_rl(type
, right_orig
);
873 min
= sval_type_min(get_type(right
));
874 max
= sval_type_max(get_type(right
));
875 right_orig
= cast_rl(type
, alloc_rl(min
, max
));
877 min
= sval_type_min(type
);
878 max
= sval_type_max(type
);
880 left_true
= clone_rl(left_orig
);
881 left_false
= clone_rl(left_orig
);
882 right_true
= clone_rl(right_orig
);
883 right_false
= clone_rl(right_orig
);
887 case SPECIAL_UNSIGNED_LT
:
888 left_true
= remove_range(left_orig
, rl_max(right_orig
), max
);
889 if (!sval_is_min(rl_min(right_orig
))) {
890 left_false
= remove_range(left_orig
, min
, sub_one(rl_min(right_orig
)));
893 right_true
= remove_range(right_orig
, min
, rl_min(left_orig
));
894 if (!sval_is_max(rl_max(left_orig
)))
895 right_false
= remove_range(right_orig
, add_one(rl_max(left_orig
)), max
);
897 case SPECIAL_UNSIGNED_LTE
:
899 if (!sval_is_max(rl_max(right_orig
)))
900 left_true
= remove_range(left_orig
, add_one(rl_max(right_orig
)), max
);
901 left_false
= remove_range(left_orig
, min
, rl_min(right_orig
));
903 if (!sval_is_min(rl_min(left_orig
)))
904 right_true
= remove_range(right_orig
, min
, sub_one(rl_min(left_orig
)));
905 right_false
= remove_range(right_orig
, rl_max(left_orig
), max
);
907 if (sval_cmp(rl_min(left_orig
), rl_min(right_orig
)) == 0)
908 left_false
= remove_range(left_false
, rl_min(left_orig
), rl_min(left_orig
));
909 if (sval_cmp(rl_max(left_orig
), rl_max(right_orig
)) == 0)
910 right_false
= remove_range(right_false
, rl_max(left_orig
), rl_max(left_orig
));
913 if (!sval_is_max(rl_max(right_orig
))) {
914 left_true
= remove_range(left_true
, add_one(rl_max(right_orig
)), max
);
916 if (!sval_is_min(rl_min(right_orig
))) {
917 left_true
= remove_range(left_true
, min
, sub_one(rl_min(right_orig
)));
919 if (sval_cmp(rl_min(right_orig
), rl_max(right_orig
)) == 0)
920 left_false
= remove_range(left_orig
, rl_min(right_orig
), rl_min(right_orig
));
922 if (!sval_is_max(rl_max(left_orig
)))
923 right_true
= remove_range(right_true
, add_one(rl_max(left_orig
)), max
);
924 if (!sval_is_min(rl_min(left_orig
)))
925 right_true
= remove_range(right_true
, min
, sub_one(rl_min(left_orig
)));
926 if (sval_cmp(rl_min(left_orig
), rl_max(left_orig
)) == 0)
927 right_false
= remove_range(right_orig
, rl_min(left_orig
), rl_min(left_orig
));
929 case SPECIAL_UNSIGNED_GTE
:
931 if (!sval_is_min(rl_min(right_orig
)))
932 left_true
= remove_range(left_orig
, min
, sub_one(rl_min(right_orig
)));
933 left_false
= remove_range(left_orig
, rl_max(right_orig
), max
);
935 if (!sval_is_max(rl_max(left_orig
)))
936 right_true
= remove_range(right_orig
, add_one(rl_max(left_orig
)), max
);
937 right_false
= remove_range(right_orig
, min
, rl_min(left_orig
));
939 if (sval_cmp(rl_min(left_orig
), rl_min(right_orig
)) == 0)
940 right_false
= remove_range(right_false
, rl_min(left_orig
), rl_min(left_orig
));
941 if (sval_cmp(rl_max(left_orig
), rl_max(right_orig
)) == 0)
942 left_false
= remove_range(left_false
, rl_max(left_orig
), rl_max(left_orig
));
945 case SPECIAL_UNSIGNED_GT
:
946 left_true
= remove_range(left_orig
, min
, rl_min(right_orig
));
947 if (!sval_is_max(rl_max(right_orig
)))
948 left_false
= remove_range(left_orig
, add_one(rl_max(right_orig
)), max
);
950 right_true
= remove_range(right_orig
, rl_max(left_orig
), max
);
951 if (!sval_is_min(rl_min(left_orig
)))
952 right_false
= remove_range(right_orig
, min
, sub_one(rl_min(left_orig
)));
954 case SPECIAL_NOTEQUAL
:
955 if (!sval_is_max(rl_max(right_orig
)))
956 left_false
= remove_range(left_false
, add_one(rl_max(right_orig
)), max
);
957 if (!sval_is_min(rl_min(right_orig
)))
958 left_false
= remove_range(left_false
, min
, sub_one(rl_min(right_orig
)));
959 if (sval_cmp(rl_min(right_orig
), rl_max(right_orig
)) == 0)
960 left_true
= remove_range(left_orig
, rl_min(right_orig
), rl_min(right_orig
));
962 if (!sval_is_max(rl_max(left_orig
)))
963 right_false
= remove_range(right_false
, add_one(rl_max(left_orig
)), max
);
964 if (!sval_is_min(rl_min(left_orig
)))
965 right_false
= remove_range(right_false
, min
, sub_one(rl_min(left_orig
)));
966 if (sval_cmp(rl_min(left_orig
), rl_max(left_orig
)) == 0)
967 right_true
= remove_range(right_orig
, rl_min(left_orig
), rl_min(left_orig
));
973 left_true
= rl_truncate_cast(get_type(left
), left_true
);
974 left_false
= rl_truncate_cast(get_type(left
), left_false
);
975 right_true
= rl_truncate_cast(get_type(right
), right_true
);
976 right_false
= rl_truncate_cast(get_type(right
), right_false
);
978 left_true_state
= alloc_estate_rl(left_true
);
979 left_false_state
= alloc_estate_rl(left_false
);
980 right_true_state
= alloc_estate_rl(right_true
);
981 right_false_state
= alloc_estate_rl(right_false
);
985 case SPECIAL_UNSIGNED_LT
:
986 case SPECIAL_UNSIGNED_LTE
:
988 if (get_hard_max(right
, &dummy
))
989 estate_set_hard_max(left_true_state
);
990 if (get_hard_max(left
, &dummy
))
991 estate_set_hard_max(right_false_state
);
994 case SPECIAL_UNSIGNED_GT
:
995 case SPECIAL_UNSIGNED_GTE
:
997 if (get_hard_max(left
, &dummy
))
998 estate_set_hard_max(right_true_state
);
999 if (get_hard_max(right
, &dummy
))
1000 estate_set_hard_max(left_false_state
);
1006 case SPECIAL_UNSIGNED_LT
:
1007 case SPECIAL_UNSIGNED_LTE
:
1009 if (get_hard_max(right
, &hard_max
)) {
1010 if (op
== '<' || op
== SPECIAL_UNSIGNED_LT
)
1012 estate_set_fuzzy_max(left_true_state
, hard_max
);
1014 if (get_implied_value(right
, &hard_max
)) {
1015 if (op
== SPECIAL_UNSIGNED_LTE
||
1018 estate_set_fuzzy_max(left_false_state
, hard_max
);
1020 if (get_hard_max(left
, &hard_max
)) {
1021 if (op
== SPECIAL_UNSIGNED_LTE
||
1024 estate_set_fuzzy_max(right_false_state
, hard_max
);
1026 if (get_implied_value(left
, &hard_max
)) {
1027 if (op
== '<' || op
== SPECIAL_UNSIGNED_LT
)
1029 estate_set_fuzzy_max(right_true_state
, hard_max
);
1033 case SPECIAL_UNSIGNED_GT
:
1034 case SPECIAL_UNSIGNED_GTE
:
1036 if (get_hard_max(left
, &hard_max
)) {
1037 if (op
== '>' || op
== SPECIAL_UNSIGNED_GT
)
1039 estate_set_fuzzy_max(right_true_state
, hard_max
);
1041 if (get_implied_value(left
, &hard_max
)) {
1042 if (op
== SPECIAL_UNSIGNED_GTE
||
1045 estate_set_fuzzy_max(right_false_state
, hard_max
);
1047 if (get_hard_max(right
, &hard_max
)) {
1048 if (op
== SPECIAL_UNSIGNED_LTE
||
1051 estate_set_fuzzy_max(left_false_state
, hard_max
);
1053 if (get_implied_value(right
, &hard_max
)) {
1055 op
== SPECIAL_UNSIGNED_GT
)
1057 estate_set_fuzzy_max(left_true_state
, hard_max
);
1061 if (get_hard_max(left
, &hard_max
))
1062 estate_set_fuzzy_max(right_true_state
, hard_max
);
1063 if (get_hard_max(right
, &hard_max
))
1064 estate_set_fuzzy_max(left_true_state
, hard_max
);
1068 if (get_hard_max(left
, &hard_max
)) {
1069 estate_set_hard_max(left_true_state
);
1070 estate_set_hard_max(left_false_state
);
1072 if (get_hard_max(right
, &hard_max
)) {
1073 estate_set_hard_max(right_true_state
);
1074 estate_set_hard_max(right_false_state
);
1077 if (left_postop
== SPECIAL_INCREMENT
) {
1078 left_true_state
= increment_state(left_true_state
);
1079 left_false_state
= increment_state(left_false_state
);
1081 if (left_postop
== SPECIAL_DECREMENT
) {
1082 left_true_state
= decrement_state(left_true_state
);
1083 left_false_state
= decrement_state(left_false_state
);
1085 if (right_postop
== SPECIAL_INCREMENT
) {
1086 right_true_state
= increment_state(right_true_state
);
1087 right_false_state
= increment_state(right_false_state
);
1089 if (right_postop
== SPECIAL_DECREMENT
) {
1090 right_true_state
= decrement_state(right_true_state
);
1091 right_false_state
= decrement_state(right_false_state
);
1094 set_extra_expr_true_false(left
, left_true_state
, left_false_state
);
1095 set_extra_expr_true_false(right
, right_true_state
, right_false_state
);
1098 static int opposite_op(int op
)
1109 static int is_simple_math(struct expression
*expr
)
1113 if (expr
->type
!= EXPR_BINOP
)
1115 if (!opposite_op(expr
->op
))
1120 static void move_known_values(struct expression
**left_p
, struct expression
**right_p
)
1122 struct expression
*left
= *left_p
;
1123 struct expression
*right
= *right_p
;
1126 if (get_implied_value(left
, &sval
)) {
1127 if (!is_simple_math(right
))
1129 if (right
->op
== '+' && get_value(right
->left
, &sval
)) {
1130 *left_p
= binop_expression(left
, opposite_op(right
->op
), right
->left
);
1131 *right_p
= right
->right
;
1134 if (get_value(right
->right
, &sval
)) {
1135 *left_p
= binop_expression(left
, opposite_op(right
->op
), right
->right
);
1136 *right_p
= right
->left
;
1141 if (get_implied_value(right
, &sval
)) {
1142 if (!is_simple_math(left
))
1144 if (left
->op
== '+' && get_value(left
->left
, &sval
)) {
1145 *right_p
= binop_expression(right
, opposite_op(left
->op
), left
->left
);
1146 *left_p
= left
->right
;
1150 if (get_value(left
->right
, &sval
)) {
1151 *right_p
= binop_expression(right
, opposite_op(left
->op
), left
->right
);
1152 *left_p
= left
->left
;
1159 static int match_func_comparison(struct expression
*expr
)
1161 struct expression
*left
= strip_expr(expr
->left
);
1162 struct expression
*right
= strip_expr(expr
->right
);
1166 * fixme: think about this harder. We should always be trying to limit
1167 * the non-call side as well. If we can't determine the limitter does
1168 * that mean we aren't querying the database and are missing important
1172 if (left
->type
== EXPR_CALL
) {
1173 if (get_implied_value(left
, &sval
)) {
1174 handle_comparison(get_type(expr
), left
, expr
->op
, right
);
1177 if (!get_implied_value(right
, &sval
))
1179 function_comparison(expr
->op
, left
, sval
, 1);
1183 if (right
->type
== EXPR_CALL
) {
1184 if (get_implied_value(right
, &sval
)) {
1185 handle_comparison(get_type(expr
), left
, expr
->op
, right
);
1188 if (!get_implied_value(left
, &sval
))
1190 function_comparison(expr
->op
, right
, sval
, 0);
1197 static void match_comparison(struct expression
*expr
)
1199 struct expression
*left_orig
= strip_expr(expr
->left
);
1200 struct expression
*right_orig
= strip_expr(expr
->right
);
1201 struct expression
*left
, *right
;
1202 struct expression
*prev
;
1203 struct symbol
*type
;
1205 if (match_func_comparison(expr
))
1208 type
= get_type(expr
);
1210 type
= &llong_ctype
;
1214 move_known_values(&left
, &right
);
1215 handle_comparison(type
, left
, expr
->op
, right
);
1217 prev
= get_assigned_expr(left_orig
);
1218 if (is_simple_math(prev
) && has_variable(prev
, left_orig
) == 0) {
1221 move_known_values(&left
, &right
);
1222 handle_comparison(type
, left
, expr
->op
, right
);
1225 prev
= get_assigned_expr(right_orig
);
1226 if (is_simple_math(prev
) && has_variable(prev
, right_orig
) == 0) {
1229 move_known_values(&left
, &right
);
1230 handle_comparison(type
, left
, expr
->op
, right
);
1234 static void handle_AND_condition(struct expression
*expr
)
1236 struct range_list
*rl
= NULL
;
1239 if (get_implied_value(expr
->left
, &known
) && known
.value
> 0) {
1241 get_absolute_rl(expr
->right
, &rl
);
1242 rl
= remove_range(rl
, sval_type_val(known
.type
, 0), known
);
1243 set_extra_expr_true_false(expr
->right
, alloc_estate_rl(rl
), NULL
);
1247 if (get_implied_value(expr
->right
, &known
) && known
.value
> 0) {
1249 get_absolute_rl(expr
->left
, &rl
);
1250 rl
= remove_range(rl
, sval_type_val(known
.type
, 0), known
);
1251 set_extra_expr_true_false(expr
->left
, alloc_estate_rl(rl
), NULL
);
1256 /* this is actually hooked from smatch_implied.c... it's hacky, yes */
1257 void __extra_match_condition(struct expression
*expr
)
1261 struct smatch_state
*pre_state
;
1262 struct smatch_state
*true_state
;
1263 struct smatch_state
*false_state
;
1265 expr
= strip_expr(expr
);
1266 switch (expr
->type
) {
1268 function_comparison(SPECIAL_NOTEQUAL
, expr
, ll_to_sval(0), 1);
1275 zero
= sval_blank(expr
);
1278 name
= expr_to_var_sym(expr
, &sym
);
1281 pre_state
= get_state(my_id
, name
, sym
);
1282 true_state
= estate_filter_sval(pre_state
, zero
);
1283 if (possibly_true(expr
, SPECIAL_EQUAL
, zero_expr()))
1284 false_state
= alloc_estate_sval(zero
);
1286 false_state
= alloc_estate_empty();
1287 set_extra_true_false(name
, sym
, true_state
, false_state
);
1292 match_comparison(expr
);
1294 case EXPR_ASSIGNMENT
:
1295 __extra_match_condition(expr
->left
);
1298 if (expr
->op
== '&')
1299 handle_AND_condition(expr
);
1304 static void assume_indexes_are_valid(struct expression
*expr
)
1306 struct expression
*array_expr
;
1308 struct expression
*offset
;
1309 struct symbol
*offset_type
;
1310 struct range_list
*rl_before
;
1311 struct range_list
*rl_after
;
1312 struct range_list
*filter
= NULL
;
1315 expr
= strip_expr(expr
);
1316 if (!is_array(expr
))
1319 offset
= get_array_offset(expr
);
1320 offset_type
= get_type(offset
);
1321 if (offset_type
&& type_signed(offset_type
)) {
1322 filter
= alloc_rl(sval_type_min(offset_type
),
1323 sval_type_val(offset_type
, -1));
1326 array_expr
= strip_parens(expr
->unop
->left
);
1327 array_size
= get_real_array_size(array_expr
);
1328 if (array_size
> 1) {
1329 size
= sval_type_val(offset_type
, array_size
);
1330 add_range(&filter
, size
, sval_type_max(offset_type
));
1335 get_absolute_rl(offset
, &rl_before
);
1336 rl_after
= rl_filter(rl_before
, filter
);
1337 if (rl_equiv(rl_before
, rl_after
))
1339 set_extra_expr_nomod(offset
, alloc_estate_rl(rl_after
));
1342 /* returns 1 if it is not possible for expr to be value, otherwise returns 0 */
1343 int implied_not_equal(struct expression
*expr
, long long val
)
1345 return !possibly_false(expr
, SPECIAL_NOTEQUAL
, value_expr(val
));
1348 static void struct_member_callback(struct expression
*call
, int param
, char *printed_name
, struct smatch_state
*state
)
1350 if (estate_is_whole(state
))
1352 sql_insert_caller_info(call
, PARAM_VALUE
, param
, printed_name
, state
->name
);
1353 if (estate_has_fuzzy_max(state
))
1354 sql_insert_caller_info(call
, FUZZY_MAX
, param
, printed_name
,
1355 sval_to_str(estate_get_fuzzy_max(state
)));
1358 static void db_limited_before(void)
1360 unmatched_stree
= clone_stree(__get_cur_stree());
1363 static void db_limited_after(void)
1365 free_stree(&unmatched_stree
);
1368 static void db_param_limit_filter(struct expression
*expr
, int param
, char *key
, char *value
, int mod
)
1370 struct expression
*arg
;
1373 struct sm_state
*sm
;
1374 struct symbol
*type
;
1375 struct range_list
*rl
;
1376 struct range_list
*limit
;
1377 struct range_list
*new;
1379 while (expr
->type
== EXPR_ASSIGNMENT
)
1380 expr
= strip_expr(expr
->right
);
1381 if (expr
->type
!= EXPR_CALL
)
1384 arg
= get_argument_from_call_expr(expr
->args
, param
);
1388 name
= get_variable_from_key(arg
, key
, &sym
);
1392 sm
= get_sm_state(SMATCH_EXTRA
, name
, sym
);
1393 type
= get_member_type_from_key(arg
, key
);
1395 rl
= estate_rl(sm
->state
);
1397 rl
= alloc_whole_rl(type
);
1399 call_results_to_rl(expr
, type
, value
, &limit
);
1400 new = rl_intersection(rl
, limit
);
1402 /* We want to preserve the implications here */
1403 if (sm
&& rl_equiv(estate_rl(sm
->state
), new)) {
1407 set_extra_mod(name
, sym
, alloc_estate_rl(new));
1409 set_extra_nomod(name
, sym
, alloc_estate_rl(new));
1416 static void db_param_limit(struct expression
*expr
, int param
, char *key
, char *value
)
1418 db_param_limit_filter(expr
, param
, key
, value
, 0);
1421 static void db_param_filter(struct expression
*expr
, int param
, char *key
, char *value
)
1423 db_param_limit_filter(expr
, param
, key
, value
, 1);
1426 static void db_param_add(struct expression
*expr
, int param
, char *key
, char *value
)
1428 struct expression
*arg
;
1431 struct symbol
*type
;
1432 struct smatch_state
*state
;
1433 struct range_list
*added
= NULL
;
1434 struct range_list
*new;
1436 while (expr
->type
== EXPR_ASSIGNMENT
)
1437 expr
= strip_expr(expr
->right
);
1438 if (expr
->type
!= EXPR_CALL
)
1441 arg
= get_argument_from_call_expr(expr
->args
, param
);
1444 name
= get_variable_from_key(arg
, key
, &sym
);
1448 type
= get_member_type_from_key(arg
, key
);
1449 state
= get_state(SMATCH_EXTRA
, name
, sym
);
1451 call_results_to_rl(expr
, type
, value
, &added
);
1452 new = rl_union(estate_rl(state
), added
);
1454 new = alloc_whole_rl(type
);
1457 set_extra_mod(name
, sym
, alloc_estate_rl(new));
1462 static void db_returned_member_info(struct expression
*expr
, int param
, char *key
, char *value
)
1464 struct symbol
*type
;
1467 struct range_list
*rl
;
1469 if (expr
->type
!= EXPR_ASSIGNMENT
)
1472 name
= return_state_to_var_sym(expr
, param
, key
, &sym
);
1475 type
= get_member_type_from_key(expr
->left
, key
);
1478 call_results_to_rl(expr
->right
, type
, value
, &rl
);
1479 set_extra_mod(name
, sym
, alloc_estate_rl(rl
));
1485 static void returned_member_callback(int return_id
, char *return_ranges
, char *printed_name
, struct smatch_state
*state
)
1487 if (estate_is_whole(state
))
1490 /* these are handled in smatch_param_filter/set/limit.c */
1491 if (printed_name
[0] != '*' &&
1492 !strchr(printed_name
, '.') && !strchr(printed_name
, '-'))
1495 sql_insert_return_states(return_id
, return_ranges
, RETURN_VALUE
, -1,
1496 printed_name
, state
->name
);
1499 static void match_call_info(struct expression
*expr
)
1501 struct smatch_state
*state
;
1502 struct range_list
*rl
= NULL
;
1503 struct expression
*arg
;
1504 struct symbol
*type
;
1507 FOR_EACH_PTR(expr
->args
, arg
) {
1508 type
= get_arg_type(expr
->fn
, i
);
1510 if (get_implied_rl(arg
, &rl
))
1511 rl
= cast_rl(type
, rl
);
1513 rl
= cast_rl(type
, alloc_whole_rl(get_type(arg
)));
1515 if (!is_whole_rl(rl
))
1516 sql_insert_caller_info(expr
, PARAM_VALUE
, i
, "$$", show_rl(rl
));
1517 state
= get_state_expr(SMATCH_EXTRA
, arg
);
1518 if (estate_has_fuzzy_max(state
)) {
1519 sql_insert_caller_info(expr
, FUZZY_MAX
, i
, "$$",
1520 sval_to_str(estate_get_fuzzy_max(state
)));
1523 } END_FOR_EACH_PTR(arg
);
1526 static void set_param_value(const char *name
, struct symbol
*sym
, char *key
, char *value
)
1528 struct range_list
*rl
= NULL
;
1529 struct smatch_state
*state
;
1530 struct symbol
*type
;
1533 if (strcmp(key
, "*$$") == 0)
1534 snprintf(fullname
, sizeof(fullname
), "*%s", name
);
1535 else if (strncmp(key
, "$$", 2) == 0)
1536 snprintf(fullname
, 256, "%s%s", name
, key
+ 2);
1540 type
= get_member_type_from_key(symbol_expression(sym
), key
);
1541 str_to_rl(type
, value
, &rl
);
1542 state
= alloc_estate_rl(rl
);
1543 set_state(SMATCH_EXTRA
, fullname
, sym
, state
);
1546 static void set_param_hard_max(const char *name
, struct symbol
*sym
, char *key
, char *value
)
1548 struct range_list
*rl
= NULL
;
1549 struct smatch_state
*state
;
1550 struct symbol
*type
;
1554 if (strcmp(key
, "*$$") == 0)
1555 snprintf(fullname
, sizeof(fullname
), "*%s", name
);
1556 else if (strncmp(key
, "$$", 2) == 0)
1557 snprintf(fullname
, 256, "%s%s", name
, key
+ 2);
1561 state
= get_state(SMATCH_EXTRA
, fullname
, sym
);
1564 type
= get_member_type_from_key(symbol_expression(sym
), key
);
1565 str_to_rl(type
, value
, &rl
);
1566 if (!rl_to_sval(rl
, &max
))
1568 estate_set_fuzzy_max(state
, max
);
1571 void register_smatch_extra(int id
)
1575 add_merge_hook(my_id
, &merge_estates
);
1576 add_unmatched_state_hook(my_id
, &unmatched_state
);
1577 add_hook(&match_function_def
, FUNC_DEF_HOOK
);
1578 add_hook(&match_declarations
, DECLARATION_HOOK
);
1579 select_caller_info_hook(set_param_value
, PARAM_VALUE
);
1580 select_caller_info_hook(set_param_hard_max
, FUZZY_MAX
);
1581 select_return_states_hook(RETURN_VALUE
, &db_returned_member_info
);
1582 select_return_states_before(&db_limited_before
);
1583 select_return_states_hook(LIMITED_VALUE
, &db_param_limit
);
1584 select_return_states_hook(FILTER_VALUE
, &db_param_filter
);
1585 select_return_states_hook(ADDED_VALUE
, &db_param_add
);
1586 select_return_states_after(&db_limited_after
);
1589 void register_smatch_extra_late(int id
)
1591 add_hook(&match_dereferences
, DEREF_HOOK
);
1592 add_hook(&match_pointer_as_array
, OP_HOOK
);
1593 select_call_implies_hook(DEREFERENCE
, &set_param_dereferenced
);
1594 add_hook(&match_function_call
, FUNCTION_CALL_HOOK
);
1595 add_hook(&match_assign
, ASSIGNMENT_HOOK
);
1596 add_hook(&unop_expr
, OP_HOOK
);
1597 add_hook(&asm_expr
, ASM_HOOK
);
1599 add_hook(&match_call_info
, FUNCTION_CALL_HOOK
);
1600 add_member_info_callback(my_id
, struct_member_callback
);
1601 add_returned_member_callback(my_id
, returned_member_callback
);
1603 add_hook(&assume_indexes_are_valid
, OP_HOOK
);