Print this page
11972 resync smatch

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_real_absolute.c
          +++ new/usr/src/tools/smatch/src/smatch_real_absolute.c
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29   * than nothing and that will help eliminate some false positives.
  30   30   *
  31   31   */
  32   32  
  33   33  #include "smatch.h"
  34   34  #include "smatch_slist.h"
  35   35  #include "smatch_extra.h"
  36   36  
  37   37  static int my_id;
  38   38  
  39      -static void pre_merge_hook(struct sm_state *sm)
       39 +static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state)
  40   40  {
  41   41          struct smatch_state *abs;
       42 +        struct range_list *rl;
       43 +
       44 +        abs = get_state(my_id, name, sym);
       45 +        if (!abs || !estate_rl(abs))
       46 +                return;
       47 +        rl = rl_intersection(estate_rl(abs), estate_rl(state));
       48 +        set_state(my_id, name, sym, alloc_estate_rl(clone_rl(rl)));
       49 +}
       50 +
       51 +static void pre_merge_hook(struct sm_state *cur, struct sm_state *other)
       52 +{
  42   53          struct smatch_state *extra;
  43   54          struct range_list *rl;
  44   55  
  45      -        extra = get_state(SMATCH_EXTRA, sm->name, sm->sym);
       56 +        extra = get_state(SMATCH_EXTRA, cur->name, cur->sym);
  46   57          if (!extra || !estate_rl(extra))
  47   58                  return;
  48      -        abs = get_state(my_id, sm->name, sm->sym);
  49      -        if (!abs || !estate_rl(abs)) {
  50      -                set_state(my_id, sm->name, sm->sym, clone_estate(extra));
       59 +        if (!estate_rl(cur->state)) {
       60 +                set_state(my_id, cur->name, cur->sym, clone_estate(extra));
  51   61                  return;
  52   62          }
  53      -        rl = rl_intersection(estate_rl(abs), estate_rl(extra));
  54      -        set_state(my_id, sm->name, sm->sym, alloc_estate_rl(clone_rl(rl)));
       63 +        rl = rl_intersection(estate_rl(cur->state), estate_rl(extra));
       64 +        set_state(my_id, cur->name, cur->sym, alloc_estate_rl(clone_rl(rl)));
  55   65  }
  56   66  
  57   67  static struct smatch_state *empty_state(struct sm_state *sm)
  58   68  {
  59   69          return alloc_estate_empty();
  60   70  }
  61   71  
  62      -static void reset(struct sm_state *sm, struct expression *mod_expr)
  63      -{
  64      -        set_state(my_id, sm->name, sm->sym, alloc_estate_whole(estate_type(sm->state)));
  65      -}
  66      -
  67   72  static int in_iterator_pre_statement(void)
  68   73  {
  69   74          struct statement *stmt;
  70   75  
  71   76          /*
  72   77           * we can't use __cur_stmt because that isn't set for
  73   78           * iterator_pre_statement.  Kind of a mess.
  74   79           *
  75   80           */
  76   81  
↓ open down ↓ 40 lines elided ↑ open up ↑
 117  122          set_state_expr(my_id, expr->left, alloc_estate_rl(clone_rl(rl)));
 118  123  }
 119  124  
 120  125  struct smatch_state *get_real_absolute_state(struct expression *expr)
 121  126  {
 122  127          return get_state_expr(my_id, expr);
 123  128  }
 124  129  
 125  130  struct smatch_state *get_real_absolute_state_var_sym(const char *name, struct symbol *sym)
 126  131  {
 127      -        return get_state(my_id, name, sym);
      132 +        return __get_state(my_id, name, sym);
 128  133  }
 129  134  
 130  135  void register_real_absolute(int id)
 131  136  {
 132  137          my_id = id;
 133  138  
 134  139          set_dynamic_states(my_id);
 135  140          add_pre_merge_hook(my_id, &pre_merge_hook);
 136  141          add_unmatched_state_hook(my_id, &empty_state);
 137  142          add_merge_hook(my_id, &merge_estates);
 138      -        add_modification_hook(my_id, &reset);
      143 +        add_extra_mod_hook(&extra_mod_hook);
 139  144  
 140  145          add_hook(&match_assign, ASSIGNMENT_HOOK);
 141  146  }
 142  147  
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX