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: unassignedclangb...@nondot.org
          Reporter: rb...@eudoxos.de
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to