[cfe-dev] Clang-Format, tok::string_literal around tok::lessless introduces a newline

Jeffrey van de Glind via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 24 11:50:41 PST 2020


Hey,

At my current project we are working to integrate clang format into our daily routine and would like to apply it to our legacy code. We noticed in a trial run that the following piece of code, formats in a rather weird way (anonymized):

QStringList << "something" << "something" << variable;

It adds a '\n' after the first "something", which apparently is intented, according to the code in TokenAnnotator.cpp (line 3073, introduced in commit df28f7b8dd6a032515109de4ff5b4067be95da8e, git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225444 91177308-0d34-0410-b5e6-96231b3b80d8).

The question is, is this a bug, introduced by splitting off std::endl; into mutiple lines, or is this intended? I didn't want to create a bug for it, as the code seems to be very clear about it.

Of course we can rewrite the given code to an initializer list, and are likely going to do this for all new code anyway.

Kind regards,
Jeffrey van de Glind


More information about the cfe-dev mailing list