[clang] [llvm] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 17 14:21:57 PDT 2025
================
@@ -622,15 +622,38 @@ template <> struct ScalarEnumerationTraits<FormatStyle::ShortBlockStyle> {
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
- static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::SFS_None);
- IO.enumCase(Value, "false", FormatStyle::SFS_None);
- IO.enumCase(Value, "All", FormatStyle::SFS_All);
- IO.enumCase(Value, "true", FormatStyle::SFS_All);
- IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
- IO.enumCase(Value, "InlineOnly", FormatStyle::SFS_InlineOnly);
- IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty);
+template <> struct MappingTraits<FormatStyle::ShortFunctionStyle> {
+ static void enumInput(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::ShortFunctionStyle({}));
+ IO.enumCase(Value, "Empty",
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/false,
+ /*Other=*/false}));
+ IO.enumCase(Value, "Inline",
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/false}));
+ IO.enumCase(Value, "InlineOnly",
+ FormatStyle::ShortFunctionStyle({/*Empty=*/false,
+ /*Inline=*/true,
+ /*Other=*/false}));
+ IO.enumCase(Value, "All",
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/true}));
+
+ // For backward compatibility.
+ IO.enumCase(Value, "true",
+ FormatStyle::ShortFunctionStyle({/*Empty=*/true,
+ /*Inline=*/true,
+ /*Other=*/true}));
+ IO.enumCase(Value, "false", FormatStyle::ShortFunctionStyle({}));
----------------
irymarchyk wrote:
They were mapped before, and there is a unit test which cover these old cases... So I think we still need them.
https://github.com/llvm/llvm-project/pull/134337
More information about the cfe-commits
mailing list