Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Marco Barisione <mbarisione@undo.io>
Cc: Tom Tromey <tom@tromey.com>,
	GDB patches mailing list <gdb-patches@sourceware.org>
Subject: Re: Using clang-format
Date: Tue, 11 May 2021 09:44:33 -0400	[thread overview]
Message-ID: <3cb2d631-0bd0-bd9e-8e55-4d572a259018@polymtl.ca> (raw)
In-Reply-To: <B7FB0F5F-B8B0-41E7-99CF-2ACBEC7433ED@undo.io>

> As an occasional contributor I’d love this.
> Getting the correct style right is complicated if you spend most of your
> time developing other projects with other coding styles.
> It’s even worse for cases that are not trivial as GDB’s codebase is
> occasionally inconsistent so there’s nowhere where to take inspiration
> from.

Thanks for that feedback.

> 
>>> I noticed this:
>>>
>>>  btrace_block (CORE_ADDR begin, CORE_ADDR end) : begin (begin), end (end)
>>>  {
>>>    /* Nothing.  */
>>>  }
>>>
>>> The initializer list is put on the same line as the constructor's
>>> prototype.  If there's a way to tell it that we don't want that, it
>>> would be closer to our style.
> 
> You can use BreakConstructorInitializers.

Tom's config has

  BreakConstructorInitializers: BeforeColon

But it still does it.

> Personally, I’d be a bit worried about dealing with difficult conflicts
> manually, but there are solutions for that:
> 
> 1. Rebase your branch to the point just before reformatting:
>      $ git rebase <commit before clang-format commit ID>
> 
> 2. Rebase on top of the format changes but preferring your local
>    changes:
> 
>      $ git rebase --strategy=recursive \
>            --strategy-option=theirs <clang-format commit ID>
> 
> 3. Finally reformat all of your code you just committed and amend
>    your previous commits.

I think that's a good option.  It's a bit of manual steps, but:

1. It's O(1), it's as quick to do this with a small patch and a big
   patch.
2. It's temporary, eventually all patches that were in the pipeline at
   the time of the re-format will be submitted or dropped.

> 
> 
> At work we decided not to reformat the whole C/C++ code base (while
> we did for Python).  Instead, we use some git hooks I wrote which
> reformat only what you are committing.  See
> https://github.com/barisione/clang-format-hooks.
> 
> While I wrote these scripts and would be happy for others to use
> them, I think that (in GDB’s case) it would be easier to just
> reformat everything and deal with the short-term pain. 

Agreed.

Simon

  reply	other threads:[~2021-05-11 13:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 15:55 Proposal: format GDB Python files with black Simon Marchi via Gdb-patches
2021-04-26 16:21 ` Andrew Burgess
2021-04-26 17:25   ` Simon Marchi via Gdb-patches
2021-04-26 17:50     ` Andrew Burgess
2021-04-26 18:08       ` Simon Marchi via Gdb-patches
2021-04-27  7:54         ` Andrew Burgess
2021-04-27 13:21           ` Simon Marchi via Gdb-patches
2021-04-26 17:42   ` Tom Tromey
2021-04-26 17:34 ` Paul Koning via Gdb-patches
2021-04-26 17:44   ` Simon Marchi via Gdb-patches
2021-04-26 17:48     ` Simon Marchi via Gdb-patches
2021-04-26 17:39 ` Tom Tromey
2021-04-30 16:26   ` Joel Brobecker
2021-04-26 22:40 ` Lancelot SIX via Gdb-patches
2021-04-30 17:04   ` Tom Tromey
2021-04-30 17:14     ` Simon Marchi via Gdb-patches
2021-05-01  6:42       ` Joel Brobecker
2021-04-30 17:21 ` Luis Machado via Gdb-patches
2021-05-08 16:00 ` Tom Tromey
2021-05-11  2:55   ` Simon Marchi via Gdb-patches
2021-05-11  2:57     ` Using clang-format Simon Marchi via Gdb-patches
2021-05-11 13:31       ` Marco Barisione via Gdb-patches
2021-05-11 13:44         ` Simon Marchi via Gdb-patches [this message]
2021-05-11 20:40       ` Tom Tromey
2021-05-13 17:13         ` Simon Marchi via Gdb-patches
2021-05-11 11:38     ` Proposal: format GDB Python files with black Luis Machado via Gdb-patches
2021-05-11 13:49       ` Simon Marchi via Gdb-patches
2021-05-11 14:23         ` Luis Machado via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3cb2d631-0bd0-bd9e-8e55-4d572a259018@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=mbarisione@undo.io \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox