[clang] [clang-format][NFC] Improve KeepFormFeed option decription (PR #176654)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 19 06:45:29 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/2] [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/2] 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;
More information about the cfe-commits
mailing list