From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 79DDC3888C40 for ; Wed, 30 Mar 2022 18:17:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 79DDC3888C40 Received: by mail-pg1-x52a.google.com with SMTP id t4so15121185pgc.1 for ; Wed, 30 Mar 2022 11:17:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ADpmCraXpwhaMGfGlUDje+8PjOnAkvkNHKvaAH1sTDU=; b=WmJKpm/5Qm2Zo9OufLDvZKC79qB1ANGSOEnRGTUg93RAylbDNkL2i5ItGofu4lwxm1 tBR/fi0WsKG7oRLLeWkf+FZCUQOY2enYOnfDdeNZjImkvP3t/WHxwpybOoj6/ZoT21dl S9nCUqI02Aj44hOVjJwPwTJsM6vvGOVzrjHjRhLk9z9iUN3rHZG/GfGmMNdd7DIt3Pm4 817HRTeuzvEI2oJV9eb4TtV+Qfr5emz3bmW5Zs/ditEWOptVnav8Vw9SRAUlA6wWpadm 1ywzU2SJPmN7l2QD6t89LEXNmRcM5qEMFQrGu/X2CF3ZSOzdFFIfDEA7RIWMNa7b2tH3 lkGg== X-Gm-Message-State: AOAM533fI9JT3cHkhxwBgEamjSCJeGJtTuua41COYoIzkzRfSPBvWIzh KFIHbQyV96L4hZRz16GzPX9uq8tQVTpf3w== X-Google-Smtp-Source: ABdhPJwvBa1Cm1EcKcw3ODTtg/jhX97FjKPaTjbXbnfem5/OdARHbb46P08VFJOMeUn5VQ+q+rWabA== X-Received: by 2002:a63:44f:0:b0:385:fa8a:1889 with SMTP id 76-20020a63044f000000b00385fa8a1889mr7087571pge.160.1648664235235; Wed, 30 Mar 2022 11:17:15 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:925f:e947:f685:7815]) by smtp.gmail.com with ESMTPSA id 3-20020a630003000000b003828fc1455esm19894030pga.60.2022.03.30.11.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 11:17:14 -0700 (PDT) Date: Wed, 30 Mar 2022 11:17:11 -0700 From: Fangrui Song To: Noah Goldstein Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] Add .clang-format style file Message-ID: <20220330181711.jeq2gvllahoz7or7@google.com> References: <20220330170200.2867894-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220330170200.2867894-1-goldstein.w.n@gmail.com> X-Spam-Status: No, score=-27.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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: Wed, 30 Mar 2022 18:17:19 -0000 Looks good but I don't know I have the permission to add a Reviewed-by: :) To justify this for others, it helps to attach some examples how clang-format formatted files match or differ from the existing ones. Showing some patches also helps as the patch formatter helps users the most: git diff -U0 --no-color 'HEAD^' -- | py3 path/to/llvm-project/clang/tools/clang-format/clang-format-diff.py -i -p1 On 2022-03-30, Noah Goldstein via Libc-alpha wrote: >Went with version >= 9.0 since it covers most of the major features >and should be pretty universally accessibly. 9.0 => 11.0 >There are some issues, particularly 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. 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. > >Other than the pre-processor directives most of the changes it makes >are cleaning up inconsistencies that already existed. >--- > .clang-format | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 163 insertions(+) > create mode 100644 .clang-format > >diff --git a/.clang-format b/.clang-format >new file mode 100644 >index 0000000000..0a8663a596 >--- /dev/null >+++ b/.clang-format >@@ -0,0 +1,163 @@ >+# clang-format file for GLIBC The first line seems unneeded. The filename self tells. >+# 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 >+# 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. >+--- >+# BasedOnStyle: GNU >+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 >+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 >+PenaltyBreakTemplateDeclaration: 10 >+PenaltyExcessCharacter: 1000000 >+PenaltyReturnTypeOnItsOwnLine: 60 >+PointerAlignment: Right >+ReflowComments: true >+SortIncludes: false >+SortUsingDeclarations: true >+SpaceAfterCStyleCast: true >+SpaceAfterLogicalNot: false >+SpaceAfterTemplateKeyword: true >+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 >+StatementMacros: >+ - Q_UNUSED >+ - QT_REQUIRE_VERSION >+TabWidth: 8 >+UseTab: Never >+ForEachMacros: >+ - 'FOR_EACH_IMPL' >+ - 'list_for_each' >+ - 'list_for_each_prev' >+ - 'list_for_each_prev_safe' >+... >-- >2.25.1 >