[clang] [clang-format][NFC] Improve KeepFormFeed option decription (PR #176654)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 18 08:19:57 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Baranov Victor (vbvictor)
<details>
<summary>Changes</summary>
It was not clear from the description what this option does.
Added small example to demostrate its behavior.
---
Full diff: https://github.com/llvm/llvm-project/pull/176654.diff
2 Files Affected:
- (modified) clang/docs/ClangFormatStyleOptions.rst (+12-4)
- (modified) clang/include/clang/Format/Format.h (+11-4)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/176654
More information about the cfe-commits
mailing list