[clang] [clang-format] allow short function body on a single line (PR #151428)

Lidong Yan via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 11 07:30:34 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;
----------------
brandb97 wrote:

Sounds like an interesting work to do. Of course.

https://github.com/llvm/llvm-project/pull/151428


More information about the cfe-commits mailing list