86 }
87
88 static void match_assign(struct expression *expr)
89 {
90 struct range_list *rl;
91 struct symbol *type;
92 sval_t sval;
93
94 if (expr->op != '=')
95 return;
96 if (is_fake_call(expr->right))
97 return;
98 if (in_iterator_pre_statement())
99 return;
100
101 get_real_absolute_rl(expr->right, &rl);
102
103 type = get_type(expr->left);
104 if (!type)
105 return;
106
107 rl = cast_rl(type, rl);
108 if (is_whole_rl(rl) && !get_state_expr(my_id, expr->left))
109 return;
110 /* These are handled by smatch_extra.c */
111 if (rl_to_sval(rl, &sval) && !get_state_expr(my_id, expr->left))
112 return;
113
114 set_state_expr(my_id, expr->left, alloc_estate_rl(clone_rl(rl)));
115 }
116
117 struct smatch_state *get_real_absolute_state(struct expression *expr)
118 {
119 return get_state_expr(my_id, expr);
120 }
121
122 struct smatch_state *get_real_absolute_state_var_sym(const char *name, struct symbol *sym)
123 {
124 return get_state(my_id, name, sym);
125 }
126
127 void register_real_absolute(int id)
128 {
129 my_id = id;
130
131 add_pre_merge_hook(my_id, &pre_merge_hook);
132 add_unmatched_state_hook(my_id, &empty_state);
133 add_merge_hook(my_id, &merge_estates);
134 add_modification_hook(my_id, &reset);
135
136 add_hook(&match_assign, ASSIGNMENT_HOOK);
137 }
138
|
86 }
87
88 static void match_assign(struct expression *expr)
89 {
90 struct range_list *rl;
91 struct symbol *type;
92 sval_t sval;
93
94 if (expr->op != '=')
95 return;
96 if (is_fake_call(expr->right))
97 return;
98 if (in_iterator_pre_statement())
99 return;
100
101 get_real_absolute_rl(expr->right, &rl);
102
103 type = get_type(expr->left);
104 if (!type)
105 return;
106 if (type->type != SYM_PTR && type->type != SYM_BASETYPE &&
107 type->type != SYM_ENUM)
108 return;
109
110 rl = cast_rl(type, rl);
111 if (is_whole_rl(rl) && !get_state_expr(my_id, expr->left))
112 return;
113 /* These are handled by smatch_extra.c */
114 if (rl_to_sval(rl, &sval) && !get_state_expr(my_id, expr->left))
115 return;
116
117 set_state_expr(my_id, expr->left, alloc_estate_rl(clone_rl(rl)));
118 }
119
120 struct smatch_state *get_real_absolute_state(struct expression *expr)
121 {
122 return get_state_expr(my_id, expr);
123 }
124
125 struct smatch_state *get_real_absolute_state_var_sym(const char *name, struct symbol *sym)
126 {
127 return get_state(my_id, name, sym);
128 }
129
130 void register_real_absolute(int id)
131 {
132 my_id = id;
133
134 set_dynamic_states(my_id);
135 add_pre_merge_hook(my_id, &pre_merge_hook);
136 add_unmatched_state_hook(my_id, &empty_state);
137 add_merge_hook(my_id, &merge_estates);
138 add_modification_hook(my_id, &reset);
139
140 add_hook(&match_assign, ASSIGNMENT_HOOK);
141 }
142
|