curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: clang-format, close but no cigarr

From: Tatsuhiro Tsujikawa <tatsuhiro.t_at_gmail.com>
Date: Fri, 17 Feb 2017 21:16:12 +0900

Hi,

On Fri, Feb 17, 2017 at 5:15 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> Hey
>
> tldr: clang-format can almost reformat our code for us.
>
> Longer:
>
> I'm quite fond of the idea of a tool that can reformat source code to
> follow our style. That way people could just run that and avoid picky
> reviewer comments, and we could use that to detect code style deviations
> etc.
>
> There's the old GNU indent tool for that, but it was never flexible enough
> for me. The new kid on the block for this purpose is clang-format. This
> tool is used for code reformatting in several projects these days.
>
> I grabbed it by the horns and made an attempt to create a clang-format
> config file that would format our source code the way we like it. (Which in
> most cases right now would leave the code unmodified.)
>
> It almost works.
>
> I mean, a complete success would be to be able to run it on all our code,
> then run checksrc without complaints *and* the code should be what us
> humans like and prefer. For me personally, I could even agree to adjusting
> our code style slightly to accomodate for a tool like this.
>
> The real show-stoppers right now I think is that A) it sometimes moves
> comments to column 0 instead of keeping them aligned with the code which is
> quite disruptive (possibly confused by #ifdefs?) and B) it actually indents
> code *wrongly* in url.c, which is easily spotted by humans and checksrc. I
> haven't found any config items to change those behaviors!
>
> If you want to experiment further and help me tweak the clang-format
> configs to perfection, here's what I have done this far:
>
> https://github.com/curl/curl/wiki/clang-format-style
>
> And here's the documentation for the config items:
>
> http://clang.llvm.org/docs/ClangFormatStyleOptions.html
>
> I'm considering taking these issues to the clang-format team to see what I
> can do to get this working - if they remain.
>
>
​I use clang-format for my projects as well. And I have the same feeling.
It does something strange in some cases, but not so dramatic, and I can
live with it at the moment.

The thing is, unsurprisingly, different version of clang-format ​formats
source code in slightly differently way. So if clang-format is adopted,
the version number should be shared between maintainers, or just do
reformat everything routinely by machine.

Best regards,
Tatsuhiro Tsujikawa

> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-17