@@ -15,6 +15,7 @@ Author: Daniel Kroening, Peter Schrammel
15
15
16
16
#include < util/json.h>
17
17
#include < util/json_irep.h>
18
+ #include < util/string2int.h>
18
19
#include < util/ui_message.h>
19
20
#include < util/xml.h>
20
21
#include < util/xml_irep.h>
@@ -188,8 +189,10 @@ get_sorted_properties(const propertiest &properties)
188
189
sorted_properties.push_back (p_it);
189
190
// now determine an ordering for those goals:
190
191
// 1. alphabetical ordering of file name
191
- // 2. numerical ordering of line number
192
- // 3. alphabetical ordering of goal ID
192
+ // 2. alphabetical ordering of function name
193
+ // 3. numerical ordering of line number
194
+ // 4. alphabetical ordering of goal ID
195
+ // 5. number ordering of the goal ID number
193
196
std::sort (
194
197
sorted_properties.begin (),
195
198
sorted_properties.end (),
@@ -198,11 +201,49 @@ get_sorted_properties(const propertiest &properties)
198
201
const auto &p2 = pit2->second .pc ->source_location ;
199
202
if (p1.get_file () != p2.get_file ())
200
203
return id2string (p1.get_file ()) < id2string (p2.get_file ());
201
- else if (!p1.get_line ().empty () && !p2.get_line ().empty ())
204
+ if (p1.get_function () != p2.get_function ())
205
+ return id2string (p1.get_function ()) < id2string (p2.get_function ());
206
+ else if (
207
+ !p1.get_line ().empty () && !p2.get_line ().empty () &&
208
+ p1.get_line () != p2.get_line ())
202
209
return std::stoul (id2string (p1.get_line ())) <
203
210
std::stoul (id2string (p2.get_line ()));
211
+
212
+ const auto split_property_id =
213
+ [](const irep_idt &property_id) -> std::pair<std::string, std::size_t > {
214
+ const auto property_string = id2string (property_id);
215
+ const auto last_dot = property_string.rfind (' .' );
216
+ std::string property_name;
217
+ std::string property_number;
218
+ if (last_dot == std::string::npos)
219
+ {
220
+ property_name = " " ;
221
+ property_number = property_string;
222
+ }
223
+ else
224
+ {
225
+ property_name = property_string.substr (0 , last_dot);
226
+ property_number = property_string.substr (last_dot + 1 );
227
+ }
228
+ const auto maybe_number = string2optional_size_t (property_number);
229
+ if (maybe_number.has_value ())
230
+ return std::make_pair (property_name, *maybe_number);
231
+ else
232
+ return std::make_pair (property_name, 0 );
233
+ };
234
+
235
+ const auto left_split = split_property_id (pit1->first );
236
+ const auto left_id_name = left_split.first ;
237
+ const auto left_id_number = left_split.second ;
238
+
239
+ const auto right_split = split_property_id (pit2->first );
240
+ const auto right_id_name = left_split.first ;
241
+ const auto right_id_number = left_split.second ;
242
+
243
+ if (left_id_name != right_id_name)
244
+ return left_id_name < right_id_name;
204
245
else
205
- return id2string (pit1-> first ) < id2string (pit2-> first ) ;
246
+ return left_id_number < right_id_number ;
206
247
});
207
248
return sorted_properties;
208
249
}
0 commit comments