[cfe-users] [clang-format] List of issues

Oleksandr Bacherikov via cfe-users cfe-users at lists.llvm.org
Sat Oct 14 11:52:04 PDT 2017

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 <class T>
inline constexpr T sqr(const T& x) { return x * x; }

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

template <class T>
inline constexpr T sqr(const T& x) {
    return x * x;

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

point operator + (point lhs, point rhs);

I get

point operator+(point lhs, point rhs);

3. 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;

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

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

5. There's no support for the following (more readable to me) lambda

std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {

    return std::toupper(c);


6. Semicolon from the empty statement is carried to the next line:

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

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

8. +1 to the issue with breaking before the operator -> raised before.

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20171014/b41e3d97/attachment.html>

More information about the cfe-users mailing list