[Development] clang-format

Philippe philwave at gmail.com
Wed Jun 20 17:03:26 CEST 2018


> When you line-break an expression, clang-format will indent it a 
>fixed amount from the beginning of the next line,
> where QtCreator will try to find places to line up with from the line above, including indenting from the 
> last paranthesis For instance:

I don't use QtCreator, but clang-format does it as you describe for QtCreator.
And this works very nicely (...most of the time).
Now, I don't remember which one of the many settings is responsible for this.

Philippe


On Wed, 20 Jun 2018 15:08:29 +0200
Allan Sandfeld Jensen <kde at carewolf.com> wrote:

> On Mittwoch, 20. Juni 2018 14:09:20 CEST Ivan Donchevskii wrote:
> > One more thing about clang-format.
> > 
> > It might be really nice if we use it as a default formatting tool in Qt
> > Creator. And I really want to experiment with it and see how clang-format
> > can replace the indenter that we currently use (which has a lot of bug
> > reports about broken formatting for example with modern C++).
> > 
> 
> I never seen anything QtCreator had trouble with. But on the subject, there is 
> one standard indentation features QtCreator has that clang-format can't 
> reproduce. When you line-break an expression, clang-format will indent it a 
> fixed amount from the beginning of the next line, where QtCreator will try to 
> find places to line up with from the line above, including indenting from the 
> last paranthesis For instance:
> 
> int a = foobar(x) + foo(looooooongfunctionname(
> 				         looongvariablename));
> 
> vs
> 
> int a = foobar(x) + foo(looooooongfunctionname(
>     looongvariablename));
> 
> 
> This semantic indentation is not something clang-format can do at the moment. 
> At least if someone knows how, I would love to know, I have search everywhere, 
> including the clang-format code. 
> 
> It is not so bad in this case, but once you have multiple line-break like that 
> in a long function call, clang-formated code is essentionally just 
> unformatted.
> 
> In any case if we want to enforce clang-format everywhere, perhaps we 
> shouldn't have QtCreator do smarter and more readable indentation that we do 
> not allow in our repository?
> 
> 'Allan
> 							
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development





More information about the Development mailing list