From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BC8DC3858D1E for ; Mon, 4 Apr 2022 14:13:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC8DC3858D1E Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-157-eR4wQmvEPzeUGzx5ir5xmw-1; Mon, 04 Apr 2022 10:13:07 -0400 X-MC-Unique: eR4wQmvEPzeUGzx5ir5xmw-1 Received: by mail-qv1-f72.google.com with SMTP id g1-20020a0562140ac100b00443ca5e8059so4492367qvi.17 for ; Mon, 04 Apr 2022 07:13:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=okCt/YHxcAS+iamNqxbNp+EXBJygoDCk2zkBV+C/nVM=; b=xG6WyKo3hhMaRyMWz1FqBui5KMPlBfsA5FDLTxA60z94ZlAREwyr/D22FGVDgjnUgH wcL008K08nMRshMcvdAhwYdXo2hzXpDTAmazfSVI1SpOlm610Du3F9Y8rgrzOpBllkHA nM5ZLoZUw3ElkrOfzzOV+tkmCRtLhUiDO03dgvYt+WAAhoY1j9bFxpdBWbvJKPVf77ZF /WPUz+2A/NxGnT3kvy89CCpVncuk2brPcVeasQ/s0fw3cL6jf6xkqHI6/WtdSiGFjiR/ luGc478K9r420Tkk6Q5rqB8OonqsLGOqJiA63TAv9zQHiv5JaHQQNWd7wNw8HSmw4AfD UGcg== X-Gm-Message-State: AOAM533GD4e4suoq8qH8shuCWgrLl9SGFp+KAmpWpYaEnG/TDg0Je/pF 26zkYbYrO2sBB/mT+4QVx4Ngq6XpkHz6XCiKQikJ6lSEEsSx9CvMbBXCW9QIgq+xN9zdpG9u2au xxnJgUxPF2oKsFYj3IjJl X-Received: by 2002:a05:620a:2946:b0:699:c582:f319 with SMTP id n6-20020a05620a294600b00699c582f319mr2924778qkp.118.1649081586304; Mon, 04 Apr 2022 07:13:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmLfI572DpBu7GqwTRrzaUe0G6cg6qFlbdclTFBY7fwzbpcwBdUXhJj77VlV6dnMvpJiOHgQ== X-Received: by 2002:a05:620a:2946:b0:699:c582:f319 with SMTP id n6-20020a05620a294600b00699c582f319mr2924743qkp.118.1649081585825; Mon, 04 Apr 2022 07:13:05 -0700 (PDT) Received: from [192.168.0.241] (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id m6-20020a05622a118600b002ebb68c31d5sm1893686qtk.45.2022.04.04.07.13.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 07:13:05 -0700 (PDT) Message-ID: <9c8afd2f-9bcb-d97a-67f5-01eee60d069c@redhat.com> Date: Mon, 4 Apr 2022 10:13:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v5] Add .clang-format style file To: Noah Goldstein , libc-alpha@sourceware.org References: <20220328191254.913833-1-goldstein.w.n@gmail.com> <20220330202432.3185472-1-goldstein.w.n@gmail.com> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20220330202432.3185472-1-goldstein.w.n@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2022 14:13:10 -0000 On 3/30/22 16:24, Noah Goldstein via Libc-alpha wrote: > Went with version >= 11.0 since it covers most of the major features > and should be pretty universally accessibly. Almost there. I think with v6 we'll have a version we can commit. Thanks for iterating. > 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 | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 156 insertions(+) > create mode 100644 .clang-format > > diff --git a/.clang-format b/.clang-format > new file mode 100644 > index 0000000000..c0d993fd03 > --- /dev/null > +++ b/.clang-format > @@ -0,0 +1,156 @@ > +# 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 > +# . > +# > +# Requires clang-format version >= 11.0 > +# > +# For more information, see: > +# > +# Documentation/process/clang-format.rst This is not a valid path in the glibc source tree. > +# https://clang.llvm.org/docs/ClangFormat.html > +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html > +# > +# There are some known cases that this doesn't produce the desired > +# style (i.e Preprocessor Directives are over-indented and not > +# auto-commented). As a result, this is meant to be a utility to make > +# formatting easier, not a definitive standard. > +# > +# To format the current git diff inplace (-i) the follow command can > +# be used: > +# $> git diff -U0 --no-color HEAD^ | clang-format-diff -i -p1 > +# > +# To just view the diff clang-format would generate: > +# $> git diff -U0 --no-color HEAD^ | clang-format-diff -p1 > +# > +# NB: clang-format-diff, along with other clang-format related tools, > +# can be found at: /path/to/llvm-project/clang/tools/clang-format/ > +# > +# > +--- > +# BasedOnStyle: GNU Suggest: # This file is based on the existing GNU style e.g. BasedOnStyle: GNU. Otherwise developers will be confused why the directive is commented out. > +AccessModifierOffset: -2 > +AlignAfterOpenBracket: Align > +AlignConsecutiveMacros: false > +AlignConsecutiveAssignments: false > +AlignConsecutiveBitFields: false > +AlignConsecutiveDeclarations: false > +AlignEscapedNewlines: Right > +AlignOperands: true > +AlignTrailingComments: true > +AllowAllArgumentsOnNextLine: true > +AllowAllParametersOfDeclarationOnNextLine: true > +AllowShortEnumsOnASingleLine: true > +AllowShortBlocksOnASingleLine: false > +AllowShortCaseLabelsOnASingleLine: false > +AllowShortFunctionsOnASingleLine: All > +AllowShortLambdasOnASingleLine: All > +AllowShortIfStatementsOnASingleLine: Never > +AllowShortLoopsOnASingleLine: false > +AlwaysBreakAfterDefinitionReturnType: All > +AlwaysBreakAfterReturnType: AllDefinitions > +AlwaysBreakBeforeMultilineStrings: false > +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 > +BreakStringLiterals: true > +ColumnLimit: 79 > +CommentPragmas: '^ IWYU pragma:' > +CompactNamespaces: false > +ContinuationIndentWidth: 4 > +Cpp11BracedListStyle: false > +DeriveLineEnding: true > +DerivePointerAlignment: false > +DisableFormat: false > +ExperimentalAutoDetectBinPacking: false > +FixNamespaceComments: false > +IncludeBlocks: Preserve > +IncludeCategories: > + - Regex: '.*' > + Priority: 1 OK. Resolves Florian's comment regarding IncludeCategories. > +IncludeIsMainRegex: '(Test)?$' > +IndentCaseLabels: false > +IndentCaseBlocks: false > +IndentGotoLabels: true > +IndentWidth: 2 > +IndentPPDirectives: AfterHash > +IndentExternBlock: AfterExternBlock > +IndentWrappedFunctionNames: false > +InsertTrailingCommas: None > +KeepEmptyLinesAtTheStartOfBlocks: true > +MacroBlockBegin: '' > +MacroBlockEnd: '' > +MaxEmptyLinesToKeep: 1 > +NamespaceIndentation: None > +PenaltyBreakAssignment: 2 > +PenaltyBreakBeforeFirstCallParameter: 19 > +PenaltyBreakComment: 300 > +PenaltyBreakFirstLessLess: 120 > +PenaltyBreakString: 1000 > +PenaltyExcessCharacter: 1000000 > +PenaltyReturnTypeOnItsOwnLine: 60 > +PointerAlignment: Right > +ReflowComments: true > +SortIncludes: false > +SortUsingDeclarations: true > +SpaceAfterCStyleCast: true > +SpaceAfterLogicalNot: false > +SpaceBeforeAssignmentOperators: true > +SpaceBeforeCpp11BracedList: false > +SpaceBeforeCtorInitializerColon: true > +SpaceBeforeInheritanceColon: true > +SpaceBeforeParens: Always > +SpaceBeforeRangeBasedForLoopColon: true > +SpaceInEmptyBlock: false > +SpaceInEmptyParentheses: false > +SpacesBeforeTrailingComments: 1 > +SpacesInAngles: false > +SpacesInConditionalStatement: false > +SpacesInContainerLiterals: true > +SpacesInCStyleCastParentheses: false > +SpacesInParentheses: false > +SpacesInSquareBrackets: false > +SpaceBeforeSquareBrackets: false > +Standard: Cpp03 OK. Removed StatementMacro use for QT. Resolves Florian's comments in v3. > +TabWidth: 8 > +UseTab: Always OK. Resolved Florian's comments in v3. > +ForEachMacros: > + - 'FOR_EACH_IMPL' > + - 'list_for_each' > + - 'list_for_each_prev' > + - 'list_for_each_prev_safe' > +... OK. -- Cheers, Carlos.