public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug build/30098] Keep trying clang-format Date: Wed, 08 Feb 2023 20:32:06 +0000 [thread overview] Message-ID: <bug-30098-4717-WoUOefzugY@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30098-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30098 Simon Marchi <simark at simark dot ca> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simark at simark dot ca --- Comment #6 from Simon Marchi <simark at simark dot ca> --- Thanks for filing this. Can we make some branch on sourceware with the latest attempt at doing this, that we could update over time? I would suggest to have just two commits over master, one commit to add .clang-format (and maybe a script to run clang-format correctly to do a mass reformat) and another commit that is the actual mass reformat. Using clang-format-15, I see some changes that are not stable in hppa-netbsd-tdep.c, clang-format changes the code every time I run it: diff --git a/gdb/hppa-netbsd-tdep.c b/gdb/hppa-netbsd-tdep.c index 5468a135caf7..7b4c8c71fe2f 100644 --- a/gdb/hppa-netbsd-tdep.c +++ b/gdb/hppa-netbsd-tdep.c @@ -63,30 +63,29 @@ static void hppanbsd_sigtramp_cache_init (const struct tramp_frame *, struct trad_frame_cache *, CORE_ADDR); -static const struct tramp_frame hppanbsd_sigtramp_si4 = { - SIGTRAMP_FRAME, - 4, - { { 0xc7d7c012, ULONGEST_MAX }, /* bb,>=,n %arg3, 30, 1f */ - { 0xd6e01c1e, ULONGEST_MAX }, /* depwi 0,31,2,%arg3 */ - { 0x0ee81093, ULONGEST_MAX }, /* ldw 4(%arg3), %r19 */ - { 0x0ee01097, ULONGEST_MAX }, /* ldw 0(%arg3), %arg3 */ - /* 1: */ - { 0xe8404000, ULONGEST_MAX }, /* blr %r0, %rp */ - { 0xeae0c002, ULONGEST_MAX }, /* bv,n %r0(%arg3) */ - { 0x08000240, ULONGEST_MAX }, /* nop */ - - { 0x0803025a, ULONGEST_MAX }, /* copy %r3, %arg0 */ - { 0x20200801, ULONGEST_MAX }, /* ldil -40000000, %r1 */ - { 0xe420e008, ULONGEST_MAX }, /* be,l 4(%sr7, %r1), %sr0, %r31 */ - { 0x34160268, ULONGEST_MAX }, /* ldi 134, %t1 ; SYS_setcontext */ - - { 0x081c025a, ULONGEST_MAX }, /* copy ret0, %arg0 */ - { 0x20200801, ULONGEST_MAX }, /* ldil -40000000, %r1 */ - { 0xe420e008, ULONGEST_MAX }, /* be,l 4(%sr7, %r1), %sr0, %r31 */ - { 0x34160002, ULONGEST_MAX }, /* ldi 1, %t1 ; SYS_exit */ - { TRAMP_SENTINEL_INSN, ULONGEST_MAX } }, - hppanbsd_sigtramp_cache_init -}; +static const struct tramp_frame hppanbsd_sigtramp_si4 + = { SIGTRAMP_FRAME, + 4, + { { 0xc7d7c012, ULONGEST_MAX }, /* bb,>=,n %arg3, 30, 1f */ + { 0xd6e01c1e, ULONGEST_MAX }, /* depwi 0,31,2,%arg3 */ + { 0x0ee81093, ULONGEST_MAX }, /* ldw 4(%arg3), %r19 */ + { 0x0ee01097, ULONGEST_MAX }, /* ldw 0(%arg3), %arg3 */ + /* 1: */ + { 0xe8404000, ULONGEST_MAX }, /* blr %r0, %rp */ + { 0xeae0c002, ULONGEST_MAX }, /* bv,n %r0(%arg3) */ + { 0x08000240, ULONGEST_MAX }, /* nop */ + + { 0x0803025a, ULONGEST_MAX }, /* copy %r3, %arg0 */ + { 0x20200801, ULONGEST_MAX }, /* ldil -40000000, %r1 */ + { 0xe420e008, ULONGEST_MAX }, /* be,l 4(%sr7, %r1), %sr0, %r31 */ + { 0x34160268, ULONGEST_MAX }, /* ldi 134, %t1 ; SYS_setcontext */ + + { 0x081c025a, ULONGEST_MAX }, /* copy ret0, %arg0 */ + { 0x20200801, ULONGEST_MAX }, /* ldil -40000000, %r1 */ + { 0xe420e008, ULONGEST_MAX }, /* be,l 4(%sr7, %r1), %sr0, %r31 */ + { 0x34160002, ULONGEST_MAX }, /* ldi 1, %t1 ; SYS_exit */ + { TRAMP_SENTINEL_INSN, ULONGEST_MAX } }, + hppanbsd_sigtramp_cache_init }; Probably a bug in clang-format? I guess that could be worked around by placing markers around that code to prevent clang-format from touching it. In my .clang-format, I had `UseTab: Always`, but it doesn't seem to make a difference compared to what you have. > Sometimes clang-format makes bad decisions. One example > I'm looking at is if you have an 'if' that is a series of > clauses joined by '&&', sometimes it is clearest to put > each such clause on its own line. However clang-format does this: > > @@ -194,10 +193,8 @@ eq_bfd (const void *a, const void *b) > = (const struct gdb_bfd_cache_search *) b; > struct gdb_bfd_data *gdata = (struct gdb_bfd_data *) bfd_usrdata (abfd); > > - return (gdata->mtime == s->mtime > - && gdata->size == s->size > - && gdata->inode == s->inode > - && gdata->device_id == s->device_id > + return (gdata->mtime == s->mtime && gdata->size == s->size > + && gdata->inode == s->inode && gdata->device_id == s->device_id > && strcmp (bfd_get_filename (abfd), s->filename) == 0); > } I agree that the old one is more readable. I suppose that could be a clang-format rule, similar to BinPackParameters. If an expression fits on one line, leave it on one line. Otherwise, break at binary operators. It could happen with other operators too, like: something = (aaaaaaaa + bbbbbbbb + cccccccc + dddddddd); vs something = (aaaaaaaa + bbbbbbbb + cccccccc + dddddddd); Of course, humans will pretty much always make better decisions for things like this. For instance, you might want to have it organized logically like this: path = (base + "/" + subdir1 + "/" + subdir2 + "/" + subdir3); But the tool will either choose: path = (base + "/" + subdir1 + "/" + subdir2 + "/" + subdir3); of path = (base + "/" + subdir1 + "/" + subdir2 + "/" + subdir3); If we want to use an automated tool, we have to accept the tradeoff that some cases will be less nice, in exchange for convenience. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-02-08 20:32 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-08 19:57 [Bug build/30098] New: " tromey at sourceware dot org 2023-02-08 20:00 ` [Bug build/30098] " tromey at sourceware dot org 2023-02-08 20:05 ` tromey at sourceware dot org 2023-02-08 20:07 ` tromey at sourceware dot org 2023-02-08 20:09 ` tromey at sourceware dot org 2023-02-08 20:10 ` tromey at sourceware dot org 2023-02-08 20:32 ` simark at simark dot ca [this message] 2023-02-08 21:31 ` jan at vrany dot io 2023-02-08 22:27 ` sam at gentoo dot org 2023-02-08 23:57 ` tromey at sourceware dot org 2023-08-03 16:53 ` tromey at sourceware dot org
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=bug-30098-4717-WoUOefzugY@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /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: linkBe 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).