[clang] [clang-format] Support fine-grained alignment of variable declarations (PR #160270)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 23 03:32:08 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp clang/lib/Format/FormatToken.h clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/WhitespaceManager.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index 2c4ad3d1d..e9b79ae08 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1017,11 +1017,13 @@ void WhitespaceManager::alignConsecutiveDeclarations() {
if (C.Tok->is(TT_FunctionDeclarationName))
return Style.AlignConsecutiveDeclarations.AlignFunctionDeclarations;
if (C.Tok->IsInClassScope && !Style.AlignConsecutiveDeclarations
- .AlignMemberVariableDeclarations)
+ .AlignMemberVariableDeclarations) {
return false;
+ }
if (!C.Tok->IsInClassScope &&
- !Style.AlignConsecutiveDeclarations.AlignFreeVariableDeclarations)
+ !Style.AlignConsecutiveDeclarations.AlignFreeVariableDeclarations) {
return false;
+ }
if (C.Tok->isNot(TT_StartOfName))
return false;
if (C.Tok->Previous &&
``````````
</details>
https://github.com/llvm/llvm-project/pull/160270
More information about the cfe-commits
mailing list