{"thread":{"id":"61742","subject":"[PATCH] clang-format: include kh_foreach* macros in ForEachMacros","startedAt":"2024-07-05T19:25:45Z","lastAt":"2024-07-05T19:25:45Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"498118","messageId":"4e7893f5-2dd9-46cf-8a64-cf780f4e1730@web.de","threadId":"61742","inReplyTo":null,"subject":"[PATCH] clang-format: include kh_foreach* macros in ForEachMacros","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2024-07-05T19:25:43Z","receivedAt":"2024-07-05T19:25:45Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The command for generating the list of ForEachMacros searches for\nmacros whose name contains the string \"for_each\".  Include those whose\nname contains \"foreach\" as well.  That brings in kh_foreach and\nkh_foreach_value from khash.h.\n\nRegenerating the list also brings in hashmap-based macros added by\n87571c3f71 (hashmap: use *_entry APIs for iteration, 2019-10-06),\nf0e63c4113 (hashmap: use *_entry APIs to wrap container_of, 2019-10-06),\n4fa1d501f7 (strmap: add functions facilitating use as a string->int map,\n2020-11-05), b70c82e6ed (strmap: add more utility functions,\n2020-11-05), and 1201eb628a (strmap: add a strset sub-type, 2020-11-06).\n\nfor_each_abbrev is no longer found because its definition was removed by\nd850b7a545 (cocci: apply the \"cache.h\" part of \"the_repository.pending\",\n2023-03-28).  Note that it had been a false positive, though, as it had\nbeen a function wrapper, not a for-like macro.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n .clang-format | 13 +++++++++----\n 1 file changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 3ed4fac753..6408251577 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -149,20 +149,25 @@ Cpp11BracedListStyle: false\n\n # A list of macros that should be interpreted as foreach loops instead of as\n # function calls. Taken from:\n-#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \\\n-#   | sed \"s,^#define \\([^[:space:]]*for_each[^[:space:]]*\\)(.*$,  - '\\1',\" \\\n-#   | sort | uniq\n+#   git grep -h '^#define [^[:space:]]*for_\\?each[^[:space:]]*(' |\n+#   sed \"s/^#define /  - '/; s/(.*$/'/\" | sort | uniq\n ForEachMacros:\n-  - 'for_each_abbrev'\n   - 'for_each_builtin'\n   - 'for_each_string_list_item'\n   - 'for_each_ut'\n   - 'for_each_wanted_builtin'\n+  - 'hashmap_for_each_entry'\n+  - 'hashmap_for_each_entry_from'\n+  - 'kh_foreach'\n+  - 'kh_foreach_value'\n   - 'list_for_each'\n   - 'list_for_each_dir'\n   - 'list_for_each_prev'\n   - 'list_for_each_prev_safe'\n   - 'list_for_each_safe'\n+  - 'strintmap_for_each_entry'\n+  - 'strmap_for_each_entry'\n+  - 'strset_for_each_entry'\n\n # The maximum number of consecutive empty lines to keep.\n MaxEmptyLinesToKeep: 1\n--\n2.45.2\n"}]}