From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH v3] Add .clang-format style file
Date: Wed, 30 Mar 2022 15:09:07 -0500 [thread overview]
Message-ID: <CAFUsyf+=aM=c3nK4AC1NrF0oYz+ns9h+YX7iUHv1+8rhCexP2w@mail.gmail.com> (raw)
In-Reply-To: <87k0cbgqgk.fsf@mid.deneb.enyo.de>
On Wed, Mar 30, 2022 at 3:01 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Noah Goldstein via Libc-alpha:
>
> > Went with version >= 11.0 since it covers most of the major features
> > and should be pretty universally accessibly.
> >
> > There are some issues:
> >
> > 1. indention of preprocessor directives:
> > Unfortunately there doesn't appear to be a switch for a seperate
> > 'IndentWidth' for preprocessor directives vs. normal code so we
> > are stuck either not indenting the directives or over-indenting
> > them. i.e:
> > Desired:
> > ```
> > #ifndef A
> > # define B
> > #endif
> > ```
> > Options:
> > ```
> > #ifndef A
> > # define B /* Two spaces instead of one. */
> > #endif
> >
> > #ifndef C
> > #define D /* No spaces. */
> > #endif
> > ```
> > Chose to over-indent as it generally seems easier to script
> > halving all pre-processor indentations than counting the nested
> > depth and indenting from scratch.
> >
> > 2. concatenation of lines missing semi-colons:
> > Throughout glibc there are macros used to setup aliasing that are
> > outside of functions and don't end in semi-colons i.e:
> > ```
> > libc_hidden_def (__pthread_self)
> > weak_alias (__pthread_self, pthread_self)
> > ```
> >
> > clang-format reformats lines like these to:
> > ```
> > libc_hidden_def (__pthread_self) weak_alias (__pthread_self, pthread_self)
> > ```
> >
> > which is generally undesirable.
> >
> > Other than those two big concerns there are certainly some questions
> > diffs but for the most part it creates a easy to read and consistent
> > style.
> > ---
> > .clang-format | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 175 insertions(+)
> > create mode 100644 .clang-format
> >
> > diff --git a/.clang-format b/.clang-format
> > new file mode 100644
> > index 0000000000..fcb344ef70
> > --- /dev/null
> > +++ b/.clang-format
> > @@ -0,0 +1,175 @@
> > +# clang-format file for GLIBC
> > +# Copyright (C) 2022 Free Software Foundation, Inc.
> > +# This file is part of the GNU C Library.
> > +#
> > +# The GNU C Library is free software; you can redistribute it and/or
> > +# modify it under the terms of the GNU Lesser General Public
> > +# License as published by the Free Software Foundation; either
> > +# version 2.1 of the License, or (at your option) any later version.
> > +#
> > +# The GNU C Library is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > +# Lesser General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU Lesser General Public
> > +# License along with the GNU C Library; if not, see
> > +# <https://www.gnu.org/licenses/>.
> > +#
> > +# Requires clang-format version >= 11.0
> > +#
> > +# For more information, see:
> > +#
> > +# Documentation/process/clang-format.rst
>
> That's not a valid path in the glibc source tree.
>
> > +# BasedOnStyle: GNU
>
> Why is this commented out?
>
> > +AccessModifierOffset: -2
> > +AlignAfterOpenBracket: Align
> > +AlignConsecutiveMacros: false
> > +AlignConsecutiveAssignments: false
> > +AlignConsecutiveBitFields: false
> > +AlignConsecutiveDeclarations: false
> > +AlignEscapedNewlines: Right
> > +AlignOperands: true
> > +AlignTrailingComments: true
> > +AllowAllArgumentsOnNextLine: true
> > +AllowAllConstructorInitializersOnNextLine: true
> > +AllowAllParametersOfDeclarationOnNextLine: true
> > +AllowShortEnumsOnASingleLine: true
> > +AllowShortBlocksOnASingleLine: false
> > +AllowShortCaseLabelsOnASingleLine: false
> > +AllowShortFunctionsOnASingleLine: All
> > +AllowShortLambdasOnASingleLine: All
> > +AllowShortIfStatementsOnASingleLine: Never
> > +AllowShortLoopsOnASingleLine: false
> > +AlwaysBreakAfterDefinitionReturnType: All
> > +AlwaysBreakAfterReturnType: AllDefinitions
> > +AlwaysBreakBeforeMultilineStrings: false
> > +AlwaysBreakTemplateDeclarations: MultiLine
> > +BinPackArguments: true
> > +BinPackParameters: true
> > +BraceWrapping:
> > + AfterCaseLabel: true
> > + AfterClass: true
> > + AfterControlStatement: true
> > + AfterEnum: true
> > + AfterFunction: true
> > + AfterNamespace: true
> > + AfterStruct: true
> > + AfterUnion: true
> > + AfterExternBlock: true
> > + BeforeCatch: true
> > + BeforeElse: true
> > + BeforeWhile: true
> > + IndentBraces: true
> > + SplitEmptyFunction: true
> > + SplitEmptyRecord: true
> > + SplitEmptyNamespace: true
> > +BreakBeforeBinaryOperators: All
> > +BreakBeforeBraces: GNU
> > +BreakBeforeInheritanceComma: false
> > +BreakInheritanceList: BeforeColon
> > +BreakBeforeTernaryOperators: true
> > +BreakConstructorInitializersBeforeComma: false
> > +BreakConstructorInitializers: BeforeColon
> > +BreakStringLiterals: true
> > +ColumnLimit: 79
> > +CommentPragmas: '^ IWYU pragma:'
> > +CompactNamespaces: false
> > +ConstructorInitializerAllOnOneLineOrOnePerLine: false
> > +ConstructorInitializerIndentWidth: 4
> > +ContinuationIndentWidth: 4
> > +Cpp11BracedListStyle: false
> > +DeriveLineEnding: true
> > +DerivePointerAlignment: false
> > +DisableFormat: false
> > +ExperimentalAutoDetectBinPacking: false
> > +FixNamespaceComments: false
> > +ForEachMacros:
> > + - foreach
> > + - Q_FOREACH
> > + - BOOST_FOREACH
>
> > +IncludeBlocks: Preserve
> > +IncludeCategories:
> > + - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
> > + Priority: 2
> > + - Regex: '^(<|"(gtest|gmock|isl|json)/)'
> > + Priority: 3
> > + - Regex: '.*'
> > + Priority: 1
>
> These regular expression do not seem to be relevant to glibc.
Yeah. Will fix in v4.
>
> > +UseTab: Never
>
> I prefer not using tabs, but others disagree, and most of the source
> files use tabs instead of 8 spaces (and not just for indentation).
+1 but yeah the consistent style seems to be tabs so will update in v4.
>
> > +ForEachMacros:
> > + - 'FOR_EACH_IMPL'
> > + - 'list_for_each'
> > + - 'list_for_each_prev'
> > + - 'list_for_each_prev_safe'
>
> If this is a YAML file, do these duplicate FoEachMacros keys have any
> effect? Only the second one is relevant to glibc.
They all seem to have an effect.
What do you mean only the second is relevant? I see all but `list_for_each_prev`
used and `list_for_each_prev` appears to be defined so it could be used
to make a loop.
next prev parent reply other threads:[~2022-03-30 20:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 19:12 [PATCH v1] " Noah Goldstein
2022-03-30 0:26 ` Fangrui Song
2022-03-30 1:33 ` Noah Goldstein
2022-03-30 17:02 ` [PATCH v2] " Noah Goldstein
2022-03-30 18:17 ` Fangrui Song
2022-03-30 19:30 ` Noah Goldstein
2022-03-30 19:47 ` Joseph Myers
2022-03-30 20:11 ` Noah Goldstein
2022-03-30 20:16 ` Noah Goldstein
2022-03-30 20:21 ` Joseph Myers
2022-03-30 20:59 ` Andreas Schwab
2022-03-30 19:27 ` [PATCH v3] " Noah Goldstein
2022-03-30 19:59 ` Fangrui Song
2022-03-30 20:01 ` Florian Weimer
2022-03-30 20:09 ` Noah Goldstein [this message]
2022-03-30 20:14 ` Florian Weimer
2022-03-30 20:21 ` Noah Goldstein
2022-03-30 20:10 ` [PATCH v4] " Noah Goldstein
2022-03-30 20:24 ` [PATCH v5] " Noah Goldstein
2022-04-04 14:13 ` Carlos O'Donell
2022-04-04 16:57 ` Noah Goldstein
2022-04-04 16:56 ` [PATCH v6] " Noah Goldstein
2022-04-11 14:18 ` Carlos O'Donell
2022-04-11 15:52 ` Noah Goldstein
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='CAFUsyf+=aM=c3nK4AC1NrF0oYz+ns9h+YX7iUHv1+8rhCexP2w@mail.gmail.com' \
--to=goldstein.w.n@gmail.com \
--cc=fw@deneb.enyo.de \
--cc=libc-alpha@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: 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).