[llvm-bugs] [Bug 45375] New: Missing function parameter names messes with AlwaysBreakAfterReturnType and BreakBeforeBraces

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 31 09:17:45 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45375

            Bug ID: 45375
           Summary: Missing function parameter names messes with
                    AlwaysBreakAfterReturnType and BreakBeforeBraces
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rbock at eudoxos.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Consider these two functions:

```
template <typename T, typename U>
XY<T, U>
xy1(X, Y y)
{
  return XY<T, U>{};
}

template <typename T, typename U> 
XY<T, U> 
xy2(X, Y)
{
  return XY<T, U>{};
}
```

Note the absence of parameter names in the second function template.

Using this config

```
BasedOnStyle:  LLVM
AlwaysBreakAfterReturnType: All
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Allman
```

the formatter ignores the `AlwaysBreakAfterReturnType`:

```
template <typename T, typename U>
XY<T, U>
xy1(X, Y y)
{
  return XY<T, U>{};
}

template <typename T, typename U>
XY<T, U> xy2(X, Y)
{
  return XY<T, U>{};
}
```

It gets more extreme when dropping the `AlwaysBreakTemplateDeclarations` rule.

```
BasedOnStyle:  LLVM
AlwaysBreakAfterReturnType: All
BreakBeforeBraces: Allman
```

The formatter now yields completely different results for the two functions:

```
template <typename T, typename U>
XY<T, U>
xy1(X, Y y)
{
  return XY<T, U>{};
}

template <typename T, typename U> XY<T, U> xy2(X, Y) { return XY<T, U>{}; }
```

See also: https://stackoverflow.com/q/60903794/2173029

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200331/ffcda743/attachment-0001.html>


More information about the llvm-bugs mailing list