@@ -184,52 +184,37 @@ array_string_exprt array_poolt::make_char_array_for_char_pointer(
184
184
PRECONDITION (
185
185
char_array_type.subtype ().id () == ID_unsignedbv ||
186
186
char_array_type.subtype ().id () == ID_signedbv);
187
- std::string symbol_name;
188
- if (
189
- char_pointer.id () == ID_address_of &&
190
- (to_address_of_expr (char_pointer).object ().id () == ID_index) &&
191
- char_pointer.op0 ().op0 ().id () == ID_array)
192
- {
193
- // Do not replace constant arrays
194
- return to_array_string_expr (
195
- to_index_expr (to_address_of_expr (char_pointer).object ()).array ());
196
- }
197
- else if (char_pointer.id () == ID_address_of)
198
- {
199
- symbol_name = " char_array_of_address" ;
200
- }
201
- else if (char_pointer.id () == ID_if)
187
+
188
+ if (char_pointer.id () == ID_if)
202
189
{
203
190
const if_exprt &if_expr = to_if_expr (char_pointer);
204
191
const array_string_exprt t =
205
192
make_char_array_for_char_pointer (if_expr.true_case (), char_array_type);
206
193
const array_string_exprt f =
207
194
make_char_array_for_char_pointer (if_expr.false_case (), char_array_type);
208
- array_typet array_type (
195
+ const array_typet array_type (
209
196
char_array_type.subtype (),
210
197
if_exprt (
211
198
if_expr.cond (),
212
199
to_array_type (t.type ()).size (),
213
200
to_array_type (f.type ()).size ()));
214
201
return to_array_string_expr (if_exprt (if_expr.cond (), t, f, array_type));
215
202
}
216
- else if (char_pointer.id () == ID_symbol)
217
- symbol_name = " char_array_symbol" ;
218
- else if (char_pointer.id () == ID_member)
219
- symbol_name = " char_array_member" ;
220
- else if (
221
- char_pointer.id () == ID_constant &&
222
- to_constant_expr (char_pointer).get_value () == ID_NULL)
223
- symbol_name = " char_array_null" ;
224
- else
225
- symbol_name = " unknown_char_array" ;
226
-
227
- array_string_exprt array_sym =
203
+ const bool is_constant_array =
204
+ char_pointer.id () == ID_address_of &&
205
+ (to_address_of_expr (char_pointer).object ().id () == ID_index) &&
206
+ char_pointer.op0 ().op0 ().id () == ID_array;
207
+ if (is_constant_array)
208
+ {
209
+ return to_array_string_expr (
210
+ to_index_expr (to_address_of_expr (char_pointer).object ()).array ());
211
+ }
212
+ const std::string symbol_name = " char_array_" + id2string (char_pointer.id ());
213
+ const auto array_sym =
228
214
to_array_string_expr (fresh_symbol (symbol_name, char_array_type));
229
- auto insert_result =
215
+ const auto insert_result =
230
216
arrays_of_pointers.insert (std::make_pair (char_pointer, array_sym));
231
- array_string_exprt result = to_array_string_expr (insert_result.first ->second );
232
- return result;
217
+ return to_array_string_expr (insert_result.first ->second );
233
218
}
234
219
235
220
void array_poolt::insert (
0 commit comments