Skip to content

Commit fc7e03a

Browse files
ojedagitster
authored andcommitted
clang-format: use git grep to generate the ForEachMacros list
The ForEachMacros list can reasonably be generated grepping the C source code for macros with 'for_each' in their name. Taken almost verbatim from the .clang-format file in the Linux kernel. Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 74583d8 commit fc7e03a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.clang-format

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,21 @@ SpacesInSquareBrackets: false
148148
Cpp11BracedListStyle: false
149149

150150
# A list of macros that should be interpreted as foreach loops instead of as
151-
# function calls.
152-
ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut']
151+
# function calls. Taken from:
152+
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \
153+
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
154+
# | sort | uniq
155+
ForEachMacros:
156+
- 'for_each_abbrev'
157+
- 'for_each_builtin'
158+
- 'for_each_string_list_item'
159+
- 'for_each_ut'
160+
- 'for_each_wanted_builtin'
161+
- 'list_for_each'
162+
- 'list_for_each_dir'
163+
- 'list_for_each_prev'
164+
- 'list_for_each_prev_safe'
165+
- 'list_for_each_safe'
153166

154167
# The maximum number of consecutive empty lines to keep.
155168
MaxEmptyLinesToKeep: 1

0 commit comments

Comments
 (0)