clang-format: use git grep to generate the ForEachMacros list
PATCH 1/1 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.
---
We wrote this for the Linux kernel a while ago, and it has been working fine there, so I thought it would be nice to use the same approach here. There are fancier ways of approaching this, of course.
.clang-format | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
.clang-format +15 -2
@@ -148,8 +148,21 @@ SpacesInSquareBrackets: false Cpp11BracedListStyle: false # A list of macros that should be interpreted as foreach loops instead of as -# function calls. -ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut'] +# function calls. Taken from: +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \ +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ +# | sort | uniq +ForEachMacros: + - 'for_each_abbrev' + - 'for_each_builtin' + - 'for_each_string_list_item' + - 'for_each_ut' + - 'for_each_wanted_builtin' + - 'list_for_each' + - 'list_for_each_dir' + - 'list_for_each_prev' + - 'list_for_each_prev_safe' + - 'list_for_each_safe' # The maximum number of consecutive empty lines to keep. MaxEmptyLinesToKeep: 1
Signature · 1 line
2.17.1
Hi Miguel,
Quoted 9 lines · Miguel Ojeda
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]>---
We wrote this for the Linux kernel a while ago, and it has been working fine there, so I thought it would be nice to use the same approach here.
Makes sense to me!
Thanks,
Johannes
Quoted 35 lines
.clang-format | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-).clang-format +15
-3@@ -148,8 +148,21 @@ SpacesInSquareBrackets: false Cpp11BracedListStyle: false # A list of macros that should be interpreted as foreach loops instead of as -# function calls. -ForEachMacros: ['for_each_string_list_item', 'for_each_wanted_builtin', 'for_each_builtin', 'for_each_ut'] +# function calls. Taken from: +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \ +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ +# | sort | uniq +ForEachMacros: + - 'for_each_abbrev' + - 'for_each_builtin' + - 'for_each_string_list_item' + - 'for_each_ut' + - 'for_each_wanted_builtin' + - 'list_for_each' + - 'list_for_each_dir' + - 'list_for_each_prev' + - 'list_for_each_prev_safe' + - 'list_for_each_safe' # The maximum number of consecutive empty lines to keep. MaxEmptyLinesToKeep: 1 --2.17.1
Hi Miguel,
Quoted 6 lines · Miguel Ojeda
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]>
Thanks for CC-ing me on this. I suspect that it was because I show up somewhere recently in the blame for 'git grep' (I believe I worked on adding -o about a year ago).
You 'git grep' usage of course looks correct, so this patch looks good to me, too.
Thanks,
Taylor
Quoted 7 lines · Taylor Blau
Hi Miguel,
Quoted 3 lines · Miguel Ojeda
The ForEachMacros list can reasonably be generated grepping the C source code for macros with '
for_each' in their name.
Quoted 7 lines
Quoted 3 lines
Taken almost verbatim from the .clang-format file in the Linux kernel.
Signed-off-by Miguel Ojeda <[email protected]>Thanks for CC-ing me on this. I suspect that it was because I show up somewhere recently in the blame for 'git grep' (I believe I worked on adding
-oabout a year ago).
Yeah, I just picked a few names that were related to the file form the log, since I was unable to locate a MAINTAINERS file or something like that. :-)
Thanks for taking a look -- also to Johannes!
Cheers,
Miguel