[Development] clang-format

Ivan Donchevskii ivan.donchevskii at qt.io
Wed Jun 20 14:09:20 CEST 2018


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++).


BR,
Ivan


________________________________
From: Development <development-bounces+ivan.donchevskii=qt.io at qt-project.org> on behalf of Sérgio Martins via Development <development at qt-project.org>
Sent: Wednesday, June 20, 2018 1:56 PM
To: Frederik Gladhorn
Cc: Development; development at qt-project.org
Subject: Re: [Development] clang-format

On 2018-06-18 10:04, Frederik Gladhorn wrote:
> Hi all,
>
> as part of the closing ceremony of this year's Qt Contributors' Summit
> we
> agreed to start using clang-format, to have fewer discussions around
> coding
> style and rather focus on the actual code.
>
> I have not yet thought about all angles, how to best implement this,
> here are
> some notes:
>
> We have a clang-format file in qtrepotools. You can use it today,
> simply make
> sure it's in any parent directory of the files you are editing. I'd
> actually
> propose simply moving this into the root directory of qt5.git.
> https://code.qt.io/cgit/qt/qtrepotools.git/tree/config/_clang-format
>
> If you want to clean one file:
> clang-format -i myfile.cpp/h
>
> To clean a commit (only modifies the working tree):
> git clang-format
>
>
> Getting clang-format seems easy enough:
> On macOS: brew install clang-format
> Linux: install clang-format
> Windows: it comes with normal clang
>
> Then there is the tooling/workflow perspective. Creator and other IDEs
> have
> support (you may need to enable the beautifier plugin in about
> plugins).
> I imagine we add this to the sanity bot ("git clang-format --diff -q"
> should
> return empty, otherwise post a message).
>
> Local hooks are basically the same, any ideas how to best set up the
> git hooks
> appreciated :)
>
> And then there is the big question when we run it once over the entire
> codebase.

I find clang-format a bit limited and always need to manually format
some things that clang-format doesn't allow to tune.

It's quite useful when integrated with gerrit so it can automatically -1
the most common mistakes, but I wouldn't run it on the entire codebase.

So YES to all you said, except the massive cleanup.




Regards,
--
Sérgio Martins | sergio.martins at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - The Qt, C++ and OpenGL Experts
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20180620/a7c4adf2/attachment.html>


More information about the Development mailing list