File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,34 @@ void expr2ct::get_shorthands(const exprt &expr)
176176 has_collision=!ns_collision[func].insert (sh).second ;
177177 }
178178
179+ if (!has_collision)
180+ {
181+ // We could also conflict with a function argument, the code below
182+ // finds the function we're in, and checks we don't conflict with
183+ // any argument to the function
184+ const std::string symbol_str = id2string (symbol_id);
185+ const std::string func = symbol_str.substr (0 , symbol_str.find (" ::" ));
186+ const symbolt *func_symbol;
187+ if (!ns.lookup (func, func_symbol))
188+ {
189+ if (can_cast_type<code_typet>(func_symbol->type ))
190+ {
191+ const auto func_type =
192+ type_checked_cast<code_typet>(func_symbol->type );
193+ const auto params = func_type.parameters ();
194+ for (const auto ¶m : params)
195+ {
196+ const auto param_id = param.get_identifier ();
197+ if (param_id != symbol_id && sh == id_shorthand (param_id))
198+ {
199+ has_collision = true ;
200+ break ;
201+ }
202+ }
203+ }
204+ }
205+ }
206+
179207 if (has_collision)
180208 sh = clean_identifier (symbol_id);
181209
You can’t perform that action at this time.
0 commit comments