[clang-format] List of issues

I’ve been using clang-format for quite some time and it’s a great tool. However, it has undesirable behavior in the situations listed below (or maybe I couldn’t find a way to configure it properly):

  1. AlwaysBreakTemplateDeclarations documentation states “If true, always break after the template<…> of a template declaration.”

So, I expect to see, for example, the following result:

template
inline constexpr T sqr(const T& x) { return x * x; }

However, clang-format produces this even with AllowShortFunctionsOnASingleLine and AllowShortBlocksOnASingleLine set to true:

template
inline constexpr T sqr(const T& x) {
return x * x;
}

  1. All spaces are removed in operator declarations, so instead of

point operator + (point lhs, point rhs);

I get

point operator+(point lhs, point rhs);

  1. AllowAllParametersOfDeclarationOnNextLine is great, but it doesn’t work with template parameters, so I can’t write, for example

template <
class Derived,
class Iterator,
class Category = use_default,
class Value = use_default,
class Reference = use_default,
class Pointer = use_default,
class Distance = use_default>
class iterator_adaptor;

  1. There’s no support for initialization list syntax with a comma on the left:

point::point(int x, int y)
: x(x)
, y(y)
{}

  1. There’s no support for the following (more readable to me) lambda formatting:
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
    return std::toupper(c); 
});
  1. Semicolon from the empty statement is carried to the next line:

for (int i = 0; i < n; ++i)
;

  1. When FixNamespaceComments is set to false, the empty line before the namespace closing bracket is removed.

  2. +1 to the issue with breaking before the operator → raised before.