[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
================
@@ -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({}));
----------------
owenca wrote:
I don't think we need to remap true/false.
https://github.com/llvm/llvm-project/pull/134337
More information about the cfe-commits
mailing list