From c57207c15c4fa980263e6849d0e6472c33e647fc Mon Sep 17 00:00:00 2001 From: Lancelot SIX Date: Wed, 23 Mar 2022 15:29:53 +0000 Subject: gdbsupport/selftest: Replace for_each_selftest with an iterator_range Remove the callback-based selftests::for_each_selftest function and use an iterator_range instead. Also use this iterator range in run_tests so all iterations over the selftests are done in a consistent way. This will become useful in a later commit. Change-Id: I0b3a5349a7987fbcb0071f11c394e353df986583 --- gdb/maint.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'gdb') diff --git a/gdb/maint.c b/gdb/maint.c index 60e183e..7b726c2 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1181,11 +1181,11 @@ maintenance_selftest_completer (cmd_list_element *cmd, return; #if GDB_SELF_TEST - selftests::for_each_selftest ([&tracker, text] (const std::string &name) + for (const auto &test : selftests::all_selftests ()) { - if (startswith (name.c_str (), text)) - tracker.add_completion (make_unique_xstrdup (name.c_str ())); - }); + if (startswith (test.name.c_str (), text)) + tracker.add_completion (make_unique_xstrdup (test.name.c_str ())); + } #endif } @@ -1194,9 +1194,8 @@ maintenance_info_selftests (const char *arg, int from_tty) { #if GDB_SELF_TEST gdb_printf ("Registered selftests:\n"); - selftests::for_each_selftest ([] (const std::string &name) { - gdb_printf (" - %s\n", name.c_str ()); - }); + for (const auto &test : selftests::all_selftests ()) + gdb_printf (" - %s\n", test.name.c_str ()); #else gdb_printf (_("\ Selftests have been disabled for this build.\n")); -- cgit v1.1