Print this page
12724 update smatch to 0.6.1-rc1-il-5


  39         if (estates_equiv(s1, s2))
  40                 return s1;
  41 
  42         value_ranges = rl_union(estate_rl(s1), estate_rl(s2));
  43         tmp = alloc_estate_rl(value_ranges);
  44         rlist = get_shared_relations(estate_related(s1), estate_related(s2));
  45         set_related(tmp, rlist);
  46 
  47         if ((estate_has_hard_max(s1) && (!estate_rl(s2) || estate_has_hard_max(s2))) ||
  48             (estate_has_hard_max(s2) && (!estate_rl(s1) || estate_has_hard_max(s1))))
  49                 estate_set_hard_max(tmp);
  50 
  51         estate_set_fuzzy_max(tmp, sval_max(estate_get_fuzzy_max(s1), estate_get_fuzzy_max(s2)));
  52 
  53         if (estate_capped(s1) && estate_capped(s2))
  54                 estate_set_capped(tmp);
  55 
  56         if (estate_treat_untagged(s1) && estate_treat_untagged(s2))
  57                 estate_set_treat_untagged(tmp);
  58 



  59         return tmp;
  60 }
  61 
  62 struct data_info *get_dinfo(struct smatch_state *state)
  63 {
  64         if (!state)
  65                 return NULL;
  66         return (struct data_info *)state->data;
  67 }
  68 
  69 struct range_list *estate_rl(struct smatch_state *state)
  70 {
  71         if (!state)
  72                 return NULL;
  73         return get_dinfo(state)->value_ranges;
  74 }
  75 
  76 struct related_list *estate_related(struct smatch_state *state)
  77 {
  78         if (!state)


 109                 return;
 110         estate_set_fuzzy_max(new, estate_get_fuzzy_max(old));
 111 }
 112 
 113 void estate_clear_fuzzy_max(struct smatch_state *state)
 114 {
 115         sval_t empty = {};
 116 
 117         get_dinfo(state)->fuzzy_max = empty;
 118 }
 119 
 120 int estate_has_hard_max(struct smatch_state *state)
 121 {
 122         if (!state || !estate_rl(state))
 123                 return 0;
 124         return get_dinfo(state)->hard_max;
 125 }
 126 
 127 void estate_set_hard_max(struct smatch_state *state)
 128 {



 129         get_dinfo(state)->hard_max = 1;
 130 }
 131 
 132 void estate_clear_hard_max(struct smatch_state *state)
 133 {
 134         get_dinfo(state)->hard_max = 0;
 135 }
 136 
 137 int estate_get_hard_max(struct smatch_state *state, sval_t *sval)
 138 {
 139         if (!state || !get_dinfo(state)->hard_max || !estate_rl(state))
 140                 return 0;
 141         *sval = rl_max(estate_rl(state));
 142         return 1;
 143 }
 144 
 145 bool estate_capped(struct smatch_state *state)
 146 {
 147         if (!state)
 148                 return false;


 157         get_dinfo(state)->capped = true;
 158 }
 159 
 160 bool estate_treat_untagged(struct smatch_state *state)
 161 {
 162         if (!state)
 163                 return false;
 164 
 165         /* impossible states are capped */
 166         if (!estate_rl(state))
 167                 return true;
 168 
 169         return get_dinfo(state)->treat_untagged;
 170 }
 171 
 172 void estate_set_treat_untagged(struct smatch_state *state)
 173 {
 174         get_dinfo(state)->treat_untagged = true;
 175 }
 176 












 177 sval_t estate_min(struct smatch_state *state)
 178 {
 179         return rl_min(estate_rl(state));
 180 }
 181 
 182 sval_t estate_max(struct smatch_state *state)
 183 {
 184         return rl_max(estate_rl(state));
 185 }
 186 
 187 struct symbol *estate_type(struct smatch_state *state)
 188 {
 189         return rl_max(estate_rl(state)).type;
 190 }
 191 
 192 static int rlists_equiv(struct related_list *one, struct related_list *two)
 193 {
 194         struct relation *one_rel;
 195         struct relation *two_rel;
 196 


 209                 NEXT_PTR_LIST(two_rel);
 210         }
 211         FINISH_PTR_LIST(two_rel);
 212         FINISH_PTR_LIST(one_rel);
 213 
 214         return 1;
 215 }
 216 
 217 int estates_equiv(struct smatch_state *one, struct smatch_state *two)
 218 {
 219         if (!one || !two)
 220                 return 0;
 221         if (one == two)
 222                 return 1;
 223         if (!rlists_equiv(estate_related(one), estate_related(two)))
 224                 return 0;
 225         if (estate_capped(one) != estate_capped(two))
 226                 return 0;
 227         if (estate_treat_untagged(one) != estate_treat_untagged(two))
 228                 return 0;




 229         if (strcmp(one->name, two->name) == 0)
 230                 return 1;
 231         return 0;
 232 }
 233 
 234 int estate_is_whole(struct smatch_state *state)
 235 {
 236         return is_whole_rl(estate_rl(state));
 237 }
 238 
 239 int estate_is_empty(struct smatch_state *state)
 240 {
 241         return state && !estate_rl(state);
 242 }
 243 
 244 int estate_is_unknown(struct smatch_state *state)
 245 {
 246         if (!estate_is_whole(state))
 247                 return 0;
 248         if (estate_related(state))




  39         if (estates_equiv(s1, s2))
  40                 return s1;
  41 
  42         value_ranges = rl_union(estate_rl(s1), estate_rl(s2));
  43         tmp = alloc_estate_rl(value_ranges);
  44         rlist = get_shared_relations(estate_related(s1), estate_related(s2));
  45         set_related(tmp, rlist);
  46 
  47         if ((estate_has_hard_max(s1) && (!estate_rl(s2) || estate_has_hard_max(s2))) ||
  48             (estate_has_hard_max(s2) && (!estate_rl(s1) || estate_has_hard_max(s1))))
  49                 estate_set_hard_max(tmp);
  50 
  51         estate_set_fuzzy_max(tmp, sval_max(estate_get_fuzzy_max(s1), estate_get_fuzzy_max(s2)));
  52 
  53         if (estate_capped(s1) && estate_capped(s2))
  54                 estate_set_capped(tmp);
  55 
  56         if (estate_treat_untagged(s1) && estate_treat_untagged(s2))
  57                 estate_set_treat_untagged(tmp);
  58 
  59         if (estate_new(s1) || estate_new(s2))
  60                 estate_set_new(tmp);
  61 
  62         return tmp;
  63 }
  64 
  65 struct data_info *get_dinfo(struct smatch_state *state)
  66 {
  67         if (!state)
  68                 return NULL;
  69         return (struct data_info *)state->data;
  70 }
  71 
  72 struct range_list *estate_rl(struct smatch_state *state)
  73 {
  74         if (!state)
  75                 return NULL;
  76         return get_dinfo(state)->value_ranges;
  77 }
  78 
  79 struct related_list *estate_related(struct smatch_state *state)
  80 {
  81         if (!state)


 112                 return;
 113         estate_set_fuzzy_max(new, estate_get_fuzzy_max(old));
 114 }
 115 
 116 void estate_clear_fuzzy_max(struct smatch_state *state)
 117 {
 118         sval_t empty = {};
 119 
 120         get_dinfo(state)->fuzzy_max = empty;
 121 }
 122 
 123 int estate_has_hard_max(struct smatch_state *state)
 124 {
 125         if (!state || !estate_rl(state))
 126                 return 0;
 127         return get_dinfo(state)->hard_max;
 128 }
 129 
 130 void estate_set_hard_max(struct smatch_state *state)
 131 {
 132         /* pointers don't have a hard max */
 133         if (is_ptr_type(estate_type(state)))
 134                 return;
 135         get_dinfo(state)->hard_max = 1;
 136 }
 137 
 138 void estate_clear_hard_max(struct smatch_state *state)
 139 {
 140         get_dinfo(state)->hard_max = 0;
 141 }
 142 
 143 int estate_get_hard_max(struct smatch_state *state, sval_t *sval)
 144 {
 145         if (!state || !get_dinfo(state)->hard_max || !estate_rl(state))
 146                 return 0;
 147         *sval = rl_max(estate_rl(state));
 148         return 1;
 149 }
 150 
 151 bool estate_capped(struct smatch_state *state)
 152 {
 153         if (!state)
 154                 return false;


 163         get_dinfo(state)->capped = true;
 164 }
 165 
 166 bool estate_treat_untagged(struct smatch_state *state)
 167 {
 168         if (!state)
 169                 return false;
 170 
 171         /* impossible states are capped */
 172         if (!estate_rl(state))
 173                 return true;
 174 
 175         return get_dinfo(state)->treat_untagged;
 176 }
 177 
 178 void estate_set_treat_untagged(struct smatch_state *state)
 179 {
 180         get_dinfo(state)->treat_untagged = true;
 181 }
 182 
 183 bool estate_new(struct smatch_state *state)
 184 {
 185         if (!estate_rl(state))
 186                 return false;
 187         return get_dinfo(state)->set;
 188 }
 189 
 190 void estate_set_new(struct smatch_state *state)
 191 {
 192         get_dinfo(state)->set = true;
 193 }
 194 
 195 sval_t estate_min(struct smatch_state *state)
 196 {
 197         return rl_min(estate_rl(state));
 198 }
 199 
 200 sval_t estate_max(struct smatch_state *state)
 201 {
 202         return rl_max(estate_rl(state));
 203 }
 204 
 205 struct symbol *estate_type(struct smatch_state *state)
 206 {
 207         return rl_max(estate_rl(state)).type;
 208 }
 209 
 210 static int rlists_equiv(struct related_list *one, struct related_list *two)
 211 {
 212         struct relation *one_rel;
 213         struct relation *two_rel;
 214 


 227                 NEXT_PTR_LIST(two_rel);
 228         }
 229         FINISH_PTR_LIST(two_rel);
 230         FINISH_PTR_LIST(one_rel);
 231 
 232         return 1;
 233 }
 234 
 235 int estates_equiv(struct smatch_state *one, struct smatch_state *two)
 236 {
 237         if (!one || !two)
 238                 return 0;
 239         if (one == two)
 240                 return 1;
 241         if (!rlists_equiv(estate_related(one), estate_related(two)))
 242                 return 0;
 243         if (estate_capped(one) != estate_capped(two))
 244                 return 0;
 245         if (estate_treat_untagged(one) != estate_treat_untagged(two))
 246                 return 0;
 247         if (estate_has_hard_max(one) != estate_has_hard_max(two))
 248                 return 0;
 249         if (estate_new(one) != estate_new(two))
 250                 return 0;
 251         if (strcmp(one->name, two->name) == 0)
 252                 return 1;
 253         return 0;
 254 }
 255 
 256 int estate_is_whole(struct smatch_state *state)
 257 {
 258         return is_whole_rl(estate_rl(state));
 259 }
 260 
 261 int estate_is_empty(struct smatch_state *state)
 262 {
 263         return state && !estate_rl(state);
 264 }
 265 
 266 int estate_is_unknown(struct smatch_state *state)
 267 {
 268         if (!estate_is_whole(state))
 269                 return 0;
 270         if (estate_related(state))