[PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

strager via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 14:47:35 PDT 2015


strager added inline comments.

================
Comment at: docs/ClangFormatStyleOptions.rst:221-235
@@ -220,3 +220,17 @@
 
-**AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``)
+**AlwaysBreakAfterDeclarationReturnType** (``ReturnTypeBreakingStyle``)
+  The function declaration return type breaking style to use.
+
+  Possible values:
+
+  * ``DRTBS_None`` (in configuration: ``None``)
+    Break after return type automatically.
+    ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
+  * ``DRTBS_All`` (in configuration: ``All``)
+    Always break after the return type.
+  * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
+    Always break after the return types of top level functions.
+
+
+**AlwaysBreakAfterDefinitionReturnType** (``ReturnTypeBreakingStyle``)
   The function definition return type breaking style to use.
----------------
djasper wrote:
> Same as I am arguing on some of your other patches. Fewer options are easier to maintain and easier to discover.
I think having separate options for separate cases is easier to maintain.

Current method (separate option):

```
      FormatStyle::ReturnTypeBreakingStyle BreakStyle =
          Line.mightBeFunctionDefinition()
              ? Style.AlwaysBreakAfterDefinitionReturnType
              : Style.AlwaysBreakAfterDeclarationReturnType;
      if ((BreakStyle == FormatStyle::DRTBS_All ||
           (BreakStyle == FormatStyle::DRTBS_TopLevel && Line.Level == 0)))
        Current->MustBreakBefore = true;
```

Proposed method:

```
      auto BreakStyle = Style.AlwaysBreakAfterReturnType;
      if (BreakStyle == FormatStyle::DRTBS_All ||
          (BreakStyle == FormatStyle::DRTBS_TopLevel && Line.Level == 0) ||
          (!Line->mightBeFunctionDefinition() &&
           (BreakStyle == FormatStyle::DRTBS_AllDeclarations) ||
           (BreakStyle == FormatStyle::DRTBS_TopLevelDeclarations &&
            Line.Level == 0)))
        Current->MustBreakBefore = true;
```


http://reviews.llvm.org/D10370





More information about the cfe-commits mailing list