[clang] [llvm] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue May 13 21:05:08 PDT 2025
================
@@ -619,20 +619,39 @@ TEST(ConfigParseTest, ParsesConfiguration) {
CHECK_PARSE("AllowShortBlocksOnASingleLine: true",
AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always);
- Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
CHECK_PARSE("AllowShortFunctionsOnASingleLine: None",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({}));
CHECK_PARSE("AllowShortFunctionsOnASingleLine: Inline",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Inline);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/false}));
CHECK_PARSE("AllowShortFunctionsOnASingleLine: Empty",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_Empty);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/false,
+ /*Other=*/false}));
CHECK_PARSE("AllowShortFunctionsOnASingleLine: All",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/true}));
+ CHECK_PARSE("AllowShortFunctionsOnASingleLine: InlineOnly",
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({/*Empty=*/false,
+ /*Inline=*/true,
+ /*Other=*/false}));
+
// For backward compatibility:
CHECK_PARSE("AllowShortFunctionsOnASingleLine: false",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({}));
CHECK_PARSE("AllowShortFunctionsOnASingleLine: true",
- AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);
+ AllowShortFunctionsOnASingleLine,
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/true}));
----------------
owenca wrote:
Do we need to change them?
https://github.com/llvm/llvm-project/pull/134337
More information about the cfe-commits
mailing list