[clang] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 20:21:21 PST 2024


================
@@ -9872,9 +9872,30 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   verifyFormat("class A {\n"
                "  int f() { return 1; }\n"
                "  int g();\n"
+               "  long fooooooooooooooooooooooooooooooooooooooooooooooo::\n"
+               "      baaaaaaaaaaaaaaaaaaaar();\n"
                "};\n"
                "int f() { return 1; }\n"
-               "int g();",
+               "int g();\n"
+               "int foooooooooooooooooooooooooooooooooooooooooooooooo::\n"
+               "    baaaaaaaaaaaaaaaaaaaaar();",
+               Style);
+
+  // It is now allowed to break after a short return type if necessary.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllowShortType;
+  verifyFormat("class A {\n"
+               "  int f() { return 1; }\n"
+               "  int g();\n"
+               "  long\n"
+               "  "
+               "fooooooooooooooooooooooooooooooooooooooooooooooo::"
----------------
rmarker wrote:

Using `ColumnLimit` is a good idea.

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


More information about the cfe-commits mailing list