[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
Thu Jul 31 01:51:40 PDT 2025


================
@@ -878,6 +878,12 @@ struct FormatStyle {
   /// \version 3.5
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
+  /// Dependent on the value, function body like ``{ return 0; }`` can be
+  /// put on a single line. Only when AllowShortFunctionsOnASingleLine = None
+  /// and AllowShortBlocksOnASingleLine != Never, the value of this option
+  /// is true.
+  bool AllowShortFunctionBodiesOnASingleLine;
----------------
HazardyKnusperkeks wrote:

That way you make this an global option to be set, is this what you want to do?

If yes you need to add a `\version` and update the docs, add parsing (including tests). If no then maybe move it to the private area?

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


More information about the cfe-commits mailing list