Print this page
11506 smatch resync
*** 100,135 ****
FINISH_PTR_LIST(one_rel);
return ret;
}
- static void debug_addition(struct related_list *rlist, const char *name)
- {
- struct relation *tmp;
-
- if (!option_debug_related)
- return;
-
- sm_prefix();
- sm_printf("(");
- FOR_EACH_PTR(rlist, tmp) {
- sm_printf("%s ", tmp->name);
- } END_FOR_EACH_PTR(tmp);
- sm_printf(") <-- %s\n", name);
- }
-
static void add_related(struct related_list **rlist, const char *name, struct symbol *sym)
{
struct relation *rel;
struct relation *new;
struct relation tmp = {
.name = (char *)name,
.sym = sym
};
- debug_addition(*rlist, name);
-
FOR_EACH_PTR(*rlist, rel) {
if (cmp_relation(rel, &tmp) < 0)
continue;
if (cmp_relation(rel, &tmp) == 0)
return;
--- 100,118 ----
*** 210,246 ****
* equal to the other. a = b;. It's not used for if conditions where
* a == b.
*/
void set_equiv(struct expression *left, struct expression *right)
{
! struct sm_state *right_sm, *left_sm;
struct relation *rel;
char *left_name;
struct symbol *left_sym;
struct related_list *rlist;
left_name = expr_to_var_sym(left, &left_sym);
if (!left_name || !left_sym)
goto free;
right_sm = get_sm_state_expr(SMATCH_EXTRA, right);
if (!right_sm)
- right_sm = set_state_expr(SMATCH_EXTRA, right, alloc_estate_whole(get_type(right)));
- if (!right_sm)
goto free;
/* This block is because we want to preserve the implications. */
left_sm = clone_sm(right_sm);
left_sm->name = alloc_string(left_name);
left_sm->sym = left_sym;
left_sm->state = clone_estate_cast(get_type(left), right_sm->state);
set_extra_mod_helper(left_name, left_sym, left, left_sm->state);
__set_sm(left_sm);
rlist = clone_related_list(estate_related(right_sm->state));
add_related(&rlist, right_sm->name, right_sm->sym);
add_related(&rlist, left_name, left_sym);
FOR_EACH_PTR(rlist, rel) {
struct sm_state *old_sm, *new_sm;
old_sm = get_sm_state(SMATCH_EXTRA, rel->name, rel->sym);
--- 193,250 ----
* equal to the other. a = b;. It's not used for if conditions where
* a == b.
*/
void set_equiv(struct expression *left, struct expression *right)
{
! struct sm_state *right_sm, *left_sm, *other_sm;
struct relation *rel;
char *left_name;
struct symbol *left_sym;
struct related_list *rlist;
+ char *other_name;
+ struct symbol *other_sym;
left_name = expr_to_var_sym(left, &left_sym);
if (!left_name || !left_sym)
goto free;
+ other_name = get_other_name_sym(left_name, left_sym, &other_sym);
+
right_sm = get_sm_state_expr(SMATCH_EXTRA, right);
+ if (!right_sm) {
+ struct range_list *rl;
+
+ if (!get_implied_rl(right, &rl))
+ rl = alloc_whole_rl(get_type(right));
+ right_sm = set_state_expr(SMATCH_EXTRA, right, alloc_estate_rl(rl));
+ }
if (!right_sm)
goto free;
/* This block is because we want to preserve the implications. */
left_sm = clone_sm(right_sm);
left_sm->name = alloc_string(left_name);
left_sm->sym = left_sym;
left_sm->state = clone_estate_cast(get_type(left), right_sm->state);
+ /* FIXME: The expression we're passing is wrong */
set_extra_mod_helper(left_name, left_sym, left, left_sm->state);
__set_sm(left_sm);
+ if (other_name && other_sym) {
+ other_sm = clone_sm(right_sm);
+ other_sm->name = alloc_string(other_name);
+ other_sm->sym = other_sym;
+ other_sm->state = clone_estate_cast(get_type(left), left_sm->state);
+ set_extra_mod_helper(other_name, other_sym, NULL, other_sm->state);
+ __set_sm(other_sm);
+ }
+
rlist = clone_related_list(estate_related(right_sm->state));
add_related(&rlist, right_sm->name, right_sm->sym);
add_related(&rlist, left_name, left_sym);
+ if (other_name && other_sym)
+ add_related(&rlist, other_name, other_sym);
FOR_EACH_PTR(rlist, rel) {
struct sm_state *old_sm, *new_sm;
old_sm = get_sm_state(SMATCH_EXTRA, rel->name, rel->sym);