public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Tom Tromey <tom@tromey.com>,
	 Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: Using clang-format
Date: Tue, 11 May 2021 14:40:25 -0600	[thread overview]
Message-ID: <8735ut6m2u.fsf@tromey.com> (raw)
In-Reply-To: <9e485731-875c-98e2-1894-6b1a45efa5c5@polymtl.ca> (Simon Marchi's message of "Mon, 10 May 2021 22:57:12 -0400")

>> gcc_type
>> compile_cplus_instance::convert_reference_base (
>> gcc_type base, enum gcc_cp_ref_qualifiers rquals)
>> 
>> But really, I don't think these should be blockers.  It would take
>> someone some really bad faith to say that the above changes how they
>> read the code.

I don't agree, mainly because I dislike that style, and I feel like I'm
generally above-board.

This weird dangling paren was an issue for calls, previously, though,
and I fixed it by tweaking one of the penalty settings.  So maybe that
can be salvaged.

>> I have only seen this when we make clang-format's life difficult by
>> using long names or long string literals.  If we don't like how it
>> formats some piece of code, we always have the choice of tweaking it to
>> make its like easier.

Yeah.  Also it's not like the current code is pristine.

>> I'm surprised you didn't use "UseTab: Always"

I routinely forget whether gdb uses tabs or not and rely on Emacs to
DTRT.

>> I would use "IndentPPDirectives: AfterHash".  Unlike what we use
>> currently, it will indent with $IndentWidth columns, whereas we
>> typically we indent these with a single column when we do it manually.
>> But, I think I prefer 2 columns actually.  You can try formatting
>> gdbsupport/gdb_locale.h for a good example.

My impression was that normally gdb didn't do this kind of indentation,
but in this particular case, I don't really have any opinion and I'm
happy with whatever setting everyone else enjoys.

>> Speaking of which, in order to be usable from gdbsupport and gdbserver,
>> .clang-format would need to be in the top-level directory.  Or maybe it
>> could be in gdbsupport, and gdb/gdbserver symlink to it.

Yeah, I was wondering about this as well.

I don't think we should put it at top-level, though, as people may think
it applies to the whole tree, which it wouldn't.

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

I think clang-format doesn't offer this level of control here.

>> For AlignEscapedNewlines, I'd probably choose Right or DontAlign.  The
>> reason being that if you modify the longest line of a macro (make that
>> line longer or shorter), all the macros line will change as a result.
>> So it will be harder to spot what changed when reading the hunk in the
>> diff.  I have a slight preference for Right,

Sounds good.

>>> 1. It removes all the Control-L page breaks from the source.
>>> I know these often confuse newcomers, so maybe it's fine.
>>> I feel that Someone out there will cheer this :)
>> 
>> Who dat?

I thought Pedro was in the anti-control-L camp?
Anyway, no biggie, I like them but I probably won't notice their
absence.

>>> Another possible problem is that, unlike with 'black', ensuring that
>>> everyone has the same version is a pain.

>> With the Python code, we did a massive re-format.  I don't think it did
>> / will cause a big inconvenience, because there aren't many patches to
>> the Python code.  But for the C++ code, it might be different, as there
>> are more patches in everyone's pipeline that touch that code.

If our reformatting commit is purely automated, we can write a short
script using git filter-branch so that anybody with a patch to rebase
can first rebase to the commit just before the reformat, then run the
script to rebase-and-reformat.  This would ease the pain somewhat.

>> Another question is: would we re-format the C/C++ code in the testsuite?
>> It might require a few adjustments to test cases (like there was one for
>> black), but I would be fine with that.  My concern is more if there are
>> some tests where the formatting of the code was specifically important.
>> We could disable formatting for them, but the difficulty is to find
>> them.

Personally I would say that we shouldn't touch the tests at all, and
just not worry about the formatting there.  That's been my usual review
policy, as I think it's fine, and maybe even mildly beneficial in some
theoretical way, for the tests to have a variety of styles.  Also
normally they are just throwaway code anyway.

Tom

  parent reply	other threads:[~2021-05-11 20:40 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
2021-04-26 16:21 ` Andrew Burgess
2021-04-26 17:25   ` Simon Marchi
2021-04-26 17:50     ` Andrew Burgess
2021-04-26 18:08       ` Simon Marchi
2021-04-27  7:54         ` Andrew Burgess
2021-04-27 13:21           ` Simon Marchi
2021-04-26 17:42   ` Tom Tromey
2021-04-26 17:34 ` Paul Koning
2021-04-26 17:44   ` Simon Marchi
2021-04-26 17:48     ` Simon Marchi
2021-04-26 17:39 ` Tom Tromey
2021-04-30 16:26   ` Joel Brobecker
2021-04-26 22:40 ` Lancelot SIX
2021-04-30 17:04   ` Tom Tromey
2021-04-30 17:14     ` Simon Marchi
2021-05-01  6:42       ` Joel Brobecker
2021-04-30 17:21 ` Luis Machado
2021-05-08 16:00 ` Tom Tromey
2021-05-11  2:55   ` Simon Marchi
2021-05-11  2:57     ` Using clang-format Simon Marchi
2021-05-11 13:31       ` Marco Barisione
2021-05-11 13:44         ` Simon Marchi
2021-05-11 20:40       ` Tom Tromey [this message]
2021-05-13 17:13         ` Simon Marchi
2021-05-11 11:38     ` Proposal: format GDB Python files with black Luis Machado
2021-05-11 13:49       ` Simon Marchi
2021-05-11 14:23         ` Luis Machado

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=8735ut6m2u.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).