[clang] [clang-format][NFC] Improve KeepFormFeed option decription (PR #176654)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 6 23:16:09 PST 2026
https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/176654
>From a2286ac4e494cd80081761dff82351b49fd2d16a Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sun, 18 Jan 2026 18:44:04 +0300
Subject: [PATCH 1/6] [clang-format][NFC] Improve KeepFormFeed option
decription
---
clang/docs/ClangFormatStyleOptions.rst | 16 ++++++++++++----
clang/include/clang/Format/Format.h | 15 +++++++++++----
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 4f81a084dd65b..74cbc040659a9 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5012,10 +5012,18 @@ the configuration (without a prefix: ``Auto``).
.. _KeepFormFeed:
**KeepFormFeed** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <KeepFormFeed>`
- Keep the form feed character if it's immediately preceded and followed by
- a newline. Multiple form feeds and newlines within a whitespace range are
- replaced with a single newline and form feed followed by the remaining
- newlines.
+ Keep the form feed character (``\f``) if it's immediately preceded and
+ followed by a newline. Multiple form feeds and newlines within a
+ whitespace range are replaced with a single newline and form feed
+ followed by the remaining newlines.
+
+ .. code-block:: c++
+
+ false: true:
+
+ "int i;\n" "int i;\n"
+ "\n" "\f\n"
+ "void f();" "void f();"
.. _LambdaBodyIndentation:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index c7e57d47f9ed1..2c8b7b5c2c0be 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3517,10 +3517,17 @@ struct FormatStyle {
/// \version 3.7
// bool KeepEmptyLinesAtTheStartOfBlocks;
- /// Keep the form feed character if it's immediately preceded and followed by
- /// a newline. Multiple form feeds and newlines within a whitespace range are
- /// replaced with a single newline and form feed followed by the remaining
- /// newlines.
+ /// Keep the form feed character (``\f``) if it's immediately preceded and
+ /// followed by a newline. Multiple form feeds and newlines within a
+ /// whitespace range are replaced with a single newline and form feed
+ /// followed by the remaining newlines.
+ /// \code
+ /// false: true:
+ ///
+ /// "int i;\n" "int i;\n"
+ /// "\n" "\f\n"
+ /// "void f();" "void f();"
+ /// \endcode
/// \version 20
bool KeepFormFeed;
>From 5827219bd8d73432839e278fe45579855c42d4c8 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Mon, 19 Jan 2026 17:45:11 +0300
Subject: [PATCH 2/6] better
---
clang/docs/ClangFormatStyleOptions.rst | 12 +++---------
clang/include/clang/Format/Format.h | 13 ++++---------
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 74cbc040659a9..9283c5eb3885c 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5015,15 +5015,9 @@ the configuration (without a prefix: ``Auto``).
Keep the form feed character (``\f``) if it's immediately preceded and
followed by a newline. Multiple form feeds and newlines within a
whitespace range are replaced with a single newline and form feed
- followed by the remaining newlines.
-
- .. code-block:: c++
-
- false: true:
-
- "int i;\n" "int i;\n"
- "\n" "\f\n"
- "void f();" "void f();"
+ followed by the remaining newlines. See
+ `GNU coding standards <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
+ for more information.
.. _LambdaBodyIndentation:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 2c8b7b5c2c0be..f4671ff88867d 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3519,15 +3519,10 @@ struct FormatStyle {
/// Keep the form feed character (``\f``) if it's immediately preceded and
/// followed by a newline. Multiple form feeds and newlines within a
- /// whitespace range are replaced with a single newline and form feed
- /// followed by the remaining newlines.
- /// \code
- /// false: true:
- ///
- /// "int i;\n" "int i;\n"
- /// "\n" "\f\n"
- /// "void f();" "void f();"
- /// \endcode
+ /// whitespace range are replaced with a single newline and form feed followed
+ /// by the remaining newlines. (See
+ /// https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed
+ /// for more information.)
/// \version 20
bool KeepFormFeed;
>From 263dff91125504fcf3b860e22fc57ef15fedb55b Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Mon, 19 Jan 2026 17:56:22 +0300
Subject: [PATCH 3/6] fix build?
---
clang/docs/ClangFormatStyleOptions.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 9283c5eb3885c..5afd1b626286d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5016,7 +5016,7 @@ the configuration (without a prefix: ``Auto``).
followed by a newline. Multiple form feeds and newlines within a
whitespace range are replaced with a single newline and form feed
followed by the remaining newlines. See
- `GNU coding standards <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
+ `GNU formfeed coding standard <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
for more information.
.. _LambdaBodyIndentation:
>From 98ec64ed90e771cb4a79c752a58093cb896165bf Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Mon, 19 Jan 2026 22:00:24 +0300
Subject: [PATCH 4/6] fix build 2
---
clang/docs/ClangFormatStyleOptions.rst | 9 +++++----
clang/include/clang/Format/Format.h | 7 ++++---
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 5afd1b626286d..fbabb3a256b12 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5014,10 +5014,11 @@ the configuration (without a prefix: ``Auto``).
**KeepFormFeed** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <KeepFormFeed>`
Keep the form feed character (``\f``) if it's immediately preceded and
followed by a newline. Multiple form feeds and newlines within a
- whitespace range are replaced with a single newline and form feed
- followed by the remaining newlines. See
- `GNU formfeed coding standard <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
- for more information.
+ whitespace range are replaced with a single newline and form feed followed
+ by the remaining newlines. See
+ `GNU formfeed coding standard
+ <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
+ for more information.
.. _LambdaBodyIndentation:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index f4671ff88867d..a071c36571c19 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3520,9 +3520,10 @@ struct FormatStyle {
/// Keep the form feed character (``\f``) if it's immediately preceded and
/// followed by a newline. Multiple form feeds and newlines within a
/// whitespace range are replaced with a single newline and form feed followed
- /// by the remaining newlines. (See
- /// https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed
- /// for more information.)
+ /// by the remaining newlines. See
+ /// `GNU formfeed coding standard
+ /// <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
+ /// for more information.
/// \version 20
bool KeepFormFeed;
>From d5acb896c31e1f2d1bff860233ec280974a708a9 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Tue, 20 Jan 2026 16:05:58 +0300
Subject: [PATCH 5/6] fix build 3
---
clang/docs/ClangFormatStyleOptions.rst | 2 +-
clang/include/clang/Format/Format.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index fbabb3a256b12..2b6f771031873 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5018,7 +5018,7 @@ the configuration (without a prefix: ``Auto``).
by the remaining newlines. See
`GNU formfeed coding standard
<https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
- for more information.
+ for more information.
.. _LambdaBodyIndentation:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index a071c36571c19..03afbfa973520 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3523,7 +3523,7 @@ struct FormatStyle {
/// by the remaining newlines. See
/// `GNU formfeed coding standard
/// <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
- /// for more information.
+ /// for more information.
/// \version 20
bool KeepFormFeed;
>From 5fa35a89ec85003a8fcb1eb3b6bd359b6bef3d85 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sat, 7 Feb 2026 10:15:52 +0300
Subject: [PATCH 6/6] fixup
---
clang/docs/ClangFormatStyleOptions.rst | 12 +++++-------
clang/include/clang/Format/Format.h | 12 +++++-------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 2b6f771031873..715ea20a3b491 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5012,13 +5012,11 @@ the configuration (without a prefix: ``Auto``).
.. _KeepFormFeed:
**KeepFormFeed** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <KeepFormFeed>`
- Keep the form feed character (``\f``) if it's immediately preceded and
- followed by a newline. Multiple form feeds and newlines within a
- whitespace range are replaced with a single newline and form feed followed
- by the remaining newlines. See
- `GNU formfeed coding standard
- <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
- for more information.
+ Keep the form feed character if it's immediately preceded and followed by
+ a newline. Multiple form feeds and newlines within a whitespace range are
+ replaced with a single newline and form feed followed by the remaining
+ newlines. (See
+ www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed.)
.. _LambdaBodyIndentation:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 03afbfa973520..e61217b541c6c 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3517,13 +3517,11 @@ struct FormatStyle {
/// \version 3.7
// bool KeepEmptyLinesAtTheStartOfBlocks;
- /// Keep the form feed character (``\f``) if it's immediately preceded and
- /// followed by a newline. Multiple form feeds and newlines within a
- /// whitespace range are replaced with a single newline and form feed followed
- /// by the remaining newlines. See
- /// `GNU formfeed coding standard
- /// <https://www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed>`_
- /// for more information.
+ /// Keep the form feed character if it's immediately preceded and followed by
+ /// a newline. Multiple form feeds and newlines within a whitespace range are
+ /// replaced with a single newline and form feed followed by the remaining
+ /// newlines. (See
+ /// www.gnu.org/prep/standards/html_node/Formatting.html#:~:text=formfeed.)
/// \version 20
bool KeepFormFeed;
More information about the cfe-commits
mailing list