Print this page
12166 resync smatch to 0.6.1-rc1-il-3
@@ -192,10 +192,15 @@
static char *get_pointed_at(const char *name, struct symbol *sym, struct symbol **new_sym)
{
struct expression *assigned;
+ /*
+ * Imagine we have an assignment: "foo = &addr;" then the other name
+ * of "*foo" is addr.
+ */
+
if (name[0] != '*')
return NULL;
if (strcmp(name + 1, sym->ident->name) != 0)
return NULL;
@@ -252,13 +257,14 @@
struct sm_state *sm;
char buf[256];
/*
* Just prepend the name with a different name/sym and return that.
- * For example, if we set "foo->bar = bar;" then we clamp "bar->baz",
- * that also clamps "foo->bar->baz".
- *
+ * For example, if we set "foo->bar = bar;" then the other name
+ * for "bar->baz" is "foo->bar->baz". Or if we have "foo = bar;" then
+ * the other name for "bar" is "foo". A third option is if we have
+ * "foo = bar;" then another name for "*bar" is "*foo".
*/
FOR_EACH_MY_SM(check_assigned_expr_id, __get_cur_stree(), sm) {
tmp = sm->state->data;
if (!tmp || tmp->type != EXPR_SYMBOL)
@@ -270,11 +276,21 @@
return NULL;
found:
if (!use_stack && name[tmp->symbol->ident->len] != '-')
return NULL;
+
+ if (name[0] == '*' && strcmp(name + 1, tmp->symbol_name->name) == 0)
+ snprintf(buf, sizeof(buf), "*%s", sm->name);
+ else if (name[tmp->symbol->ident->len] == '-' ||
+ name[tmp->symbol->ident->len] == '.')
snprintf(buf, sizeof(buf), "%s%s", sm->name, name + tmp->symbol->ident->len);
+ else if (strcmp(name, tmp->symbol_name->name) == 0)
+ snprintf(buf, sizeof(buf), "%s", sm->name);
+ else
+ return NULL;
+
*new_sym = sm->sym;
return alloc_string(buf);
}
char *get_other_name_sym_helper(const char *name, struct symbol *sym, struct symbol **new_sym, bool use_stack)
@@ -1084,15 +1100,10 @@
!has_symbol(right, sym)) {
set_equiv(left, right);
goto free;
}
- if (is_pointer(right) && get_address_rl(right, &rl)) {
- state = alloc_estate_rl(rl);
- goto done;
- }
-
if (get_implied_value(right, &sval)) {
state = alloc_estate_sval(sval_cast(left_type, sval));
goto done;
}