git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Git mailing list <git@vger.kernel.org>
Cc: Brandon Williams <bmwill@google.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Stephan Beyer <s-beyer@gmx.net>, Taylor Blau <me@ttaylorr.com>,
	Patryk Obara <patryk.obara@gmail.com>
Subject: [PATCH] clang-format: use git grep to generate the ForEachMacros list
Date: Tue, 4 Jun 2019 00:48:14 +0200	[thread overview]
Message-ID: <20190603224814.GA15851@gmail.com> (raw)

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 <miguel.ojeda.sandonis@gmail.com>
---
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(-)

diff --git a/.clang-format b/.clang-format
index 41d4cd23fd..c592dda681 100644
--- a/.clang-format
+++ b/.clang-format
@@ -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


             reply	other threads:[~2019-06-03 22:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 22:48 Miguel Ojeda [this message]
2019-06-04 16:07 ` [PATCH] clang-format: use git grep to generate the ForEachMacros list Johannes Schindelin
2019-06-05 20:20 ` Taylor Blau
2019-06-06 18:29   ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190603224814.GA15851@gmail.com \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=jrnieder@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=patryk.obara@gmail.com \
    --cc=s-beyer@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).