From: Michael Riesch via B4 Relay <devnull+michael.riesch.collabora.com@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Collabora Kernel Team <kernel@collabora.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Michael Riesch <michael.riesch@wolfvision.net>,
Michael Riesch <michael.riesch@collabora.com>
Subject: [PATCH v2 2/2] clang-format: align consecutive macros
Date: Thu, 10 Apr 2025 22:58:54 +0200 [thread overview]
Message-ID: <20250210-clang-format-fixes-v2-2-37894413bbee@collabora.com> (raw)
In-Reply-To: <20250210-clang-format-fixes-v2-0-37894413bbee@collabora.com>
From: Michael Riesch <michael.riesch@wolfvision.net>
clang-format 9 introduced the option "AlignConsecutiveMacros".
Set it to "AcrossEmptyLinesAndComments" in order to avoid macro
definitions of the form:
#define MAGIC_REGISTER_1 0x42
#define MAGIC_REGISTER_BIT_FLIP BIT(2)
/* important comment */
#define MAGIC_REGISTER_BIT_ENABLE BIT(12)
#define MAGIC_REGISTER_2 0x43
With the option set to "AcrossEmptyLinesAndComments", they will
be converted to
#define MAGIC_REGISTER_1 0x42
#define MAGIC_REGISTER_BIT_FLIP BIT(2)
/* important comment */
#define MAGIC_REGISTER_BIT_ENABLE BIT(12)
#define MAGIC_REGISTER_2 0x43
which seems to be the convention in the kernel code base.
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
---
.clang-format | 1 +
1 file changed, 1 insertion(+)
diff --git a/.clang-format b/.clang-format
index 8040b516185b..30d09cb88170 100644
--- a/.clang-format
+++ b/.clang-format
@@ -13,6 +13,7 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
+AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
--
2.39.5
next prev parent reply other threads:[~2025-04-10 21:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 20:58 [PATCH v2 0/2] clang-format: format short enums and macro definitions correctly Michael Riesch via B4 Relay
2025-04-10 20:58 ` [PATCH v2 1/2] clang-format: do not allow short enums on a single line Michael Riesch via B4 Relay
2025-04-10 20:58 ` Michael Riesch via B4 Relay [this message]
2025-05-02 9:34 ` [PATCH v2 0/2] clang-format: format short enums and macro definitions correctly Michael Riesch
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250210-clang-format-fixes-v2-2-37894413bbee@collabora.com \
--to=devnull+michael.riesch.collabora.com@kernel.org \
--cc=justinstitt@google.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=michael.riesch@collabora.com \
--cc=michael.riesch@wolfvision.net \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=ojeda@kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®