[clang] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 15 21:47:42 PDT 2025


================
@@ -5687,11 +5687,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
     if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
         !Left.Children.empty()) {
       // Support AllowShortFunctionsOnASingleLine for JavaScript.
-      return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None ||
-             Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty ||
-             (Left.NestingLevel == 0 && Line.Level == 0 &&
-              Style.AllowShortFunctionsOnASingleLine &
-                  FormatStyle::SFS_InlineOnly);
+      return !(Left.NestingLevel == 0 && Line.Level == 0
+                   ? Style.AllowShortFunctionsOnASingleLine.Other
+                   : Style.AllowShortFunctionsOnASingleLine.Inline);
----------------
irymarchyk wrote:

Thanks for explanation! I think I finally understood what Other mean. 
I've added your example to unit test.

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


More information about the cfe-commits mailing list