[clang] [clang-format] allow short function body on a single line (PR #151428)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 11 07:10:12 PDT 2025
================
@@ -3829,6 +3829,23 @@ struct FormatStyle {
/// \version 13
int PPIndentWidth;
+ /// Dependent on the value, function body can be put on a single line.
+ /// Automatically enabled when
+ /// `AllowShortFunctionsOnASingleLine` is set to `None` and
+ /// `AllowShortBlocksOnASingleLine` is set to `Always`.
+ /// \code
+ /// true:
+ /// int f()
+ /// { return 0; }
+ ///
+ /// false:
+ /// int f() {
+ /// return 0;
+ /// }
+ /// \endcode
+ /// \version 20
+ bool PutShortFunctionBodiesOnASingleLine;
----------------
HazardyKnusperkeks wrote:
Can you make this as an enum `Always`, `Never`, and `Leave` (which allows on a single line, and on multiple)?
https://github.com/llvm/llvm-project/pull/151428
More information about the cfe-commits
mailing list