From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id vd39KPcM5GhL7SEAWB0awg (envelope-from ) for ; Mon, 06 Oct 2025 14:39:51 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=mNu6JBoL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9B14E1E047; Mon, 06 Oct 2025 14:39:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AF9F11E047 for ; Mon, 06 Oct 2025 14:39:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54B323858D38 for ; Mon, 6 Oct 2025 18:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54B323858D38 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=mNu6JBoL Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 446CF3858D1E for ; Mon, 6 Oct 2025 18:39:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 446CF3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 446CF3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759775953; cv=none; b=VnpPSO//GvH0vL9bwk2cVjL99lncm+Sm+pCkiBUkAyrIqa0Y/e6laC688JUbvK11pB2lpaQFcmEtWg5bCcvCZ2kAxA3UbTFkjzFh1t2tZC5T/9D1lqBVAMPLOaL+X1AS32euK0rbLddMKpX83MbcRSNaBcwdAuLNVMEm15I69Po= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759775953; c=relaxed/simple; bh=N/5YX2xx9Z/hmV54O6Io3Lpc6d2lHyPJxalLIaPOTIA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mR+S1EwqVfTyWMJiQrq07Nb8K5hWgZoKPNyZkdX7wgOFo+XIDNhJ/s4gXyGGmXa9IKyxVvUULPUl1U9EldNXRMfFs7cTKF2d3otS8zFICJU+8IPGAC2mMyYPRJWnDu9Qa179RkVRAumuXXJJYuOzgiB/tTC92+1oXcQ6pwzycks= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 446CF3858D1E Received: from eig-obgw-6005b.ext.cloudfilter.net ([10.0.30.162]) by cmsmtp with ESMTPS id 5mh4vSK6fSkcf5q76vYDKy; Mon, 06 Oct 2025 18:39:12 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5q75vELdcLidY5q75vGOgR; Mon, 06 Oct 2025 18:39:12 +0000 X-Authority-Analysis: v=2.4 cv=bq1MBFai c=1 sm=1 tr=0 ts=68e40cd0 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=NEAV23lmAAAA:8 a=jsQJmMRyLB-_L9V9xEIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=piPGbOm6zHxrr7ny5wcwGpcEdacx9VUhPrGLqAwd/QI=; b=mNu6JBoLfpbFy0qU7u6RvKfRTt lcNXiUY6F/uTPrJk6jhAGsf3DkEoW0UwVHJZ0o3oxS3vPfQ2mBXRefpM8B1nLAKDGpJ/gOrzVC1Ea fiF7hTbLN1gn/ykypVCggvFsq; Received: from 97-122-110-68.hlrn.qwest.net ([97.122.110.68]:57676 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1v5q75-00000001xsf-14lJ; Mon, 06 Oct 2025 12:39:11 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v4] Add .clang-format Date: Mon, 6 Oct 2025 12:38:59 -0600 Message-ID: <20251006183901.1239002-1-tom@tromey.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.68 X-Source-L: No X-Exim-ID: 1v5q75-00000001xsf-14lJ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-68.hlrn.qwest.net (localhost.localdomain) [97.122.110.68]:57676 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLMgCSzsPoQ6mR5T6Cq//ymp559x4QN9IaoMOaaH8O8cHycstRNjJOzDSl5ZxdfdVnHW2gurnfZy9CmhSn2wxF4sISx2jDw4hiYPkgm9PJS0IusOnuQf /R5qTnG7hjALRD8o9Ahl1dgQTjrLHZ+5lYUu8vctdvs6DvVRz0flyHkZu6f30GymzmN37VahchPCWPJDJfZeyC98kFHWYahC8+o= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This patch adds a .clang-format file to the gdb repository. The resulting reformatting is what I'd describe as "ok but not great". There are a few variances from our normal style, some discussed in comments in the file, and some in the bug. I've somewhat come around to the idea that some ugliness is acceptable, particularly because I regularly see code that's already ugly anyway -- either in formatting or along some other dimension. I don't know of a way to enforce a particular version. I have only tried clang-format 18 with this particular file. I've documented this in the file. I used "AllowShortFunctionsOnASingleLine: InlineOnly" as previously discussed. I feel that the spirit of the GNU style is that vertical space is free, and we should use "None" here. (This goes against something we previously decided on the list, though.) The file is in the root directory for ease of use. For the time being you should not bulk reformat files. I think we should have a flag day for this, but at some later point. See the earlier discussion for details. New in v4: * Fix a comment * Remove ForEachMacros - no longer correct * Remove IncludeCategories - no longer correct Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30098 --- .clang-format | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 - 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..efaa21a4b9a --- /dev/null +++ b/.clang-format @@ -0,0 +1,174 @@ +# -*- yaml -*- + +# A clang format style for gdb. + +# ⚠️⚠️⚠️ DO NOT BULK REFORMAT FILES ⚠️⚠️⚠️ + +# This style is still in flux and still considered "alpha". Use "git +# clang-format" or the like to reformat just the parts your patch +# touches -- at most. At some point in the future we will bulk +# reformat and at that point we'll send out new instructions. + +# This has only been tried with clang-format 18. + +# A few known bugs: + +# * Labels are not handled GNU-style. +# https://github.com/llvm/llvm-project/issues/24492 +# https://github.com/llvm/llvm-project/issues/53717 + +# * Function call bin-packing is weird. +# https://github.com/llvm/llvm-project/issues/31255 +# https://github.com/llvm/llvm-project/issues/37051 +# In some spots this means an unavoidable line break just after a +# "(". + +# * gettext calls like "_()" are reformatted to "_ ()" +# I don't think there's an upstream bug for this yet + +# * '#if defined ()' removes the space before the paren: +# https://github.com/llvm/llvm-project/issues/55292 + +# * Open brace after a lambda should be on new line. +# https://github.com/llvm/llvm-project/issues/133135 + +# * Braced initializers don't put a newline before the "{". +# Historically gdb was inconsistent about this. + + +# Options here are generally in alphabetical order. + +Language: Cpp +# BasedOnStyle: GNU +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +# +# Run: +# git grep 'define ATTRIBUTE_' -- include gdb* | \ +# sed -e's/^.*\(ATTRIBUTE_[A-Z0-9_]*\).*$/\1/' | \ +# sort -u | \ +# sed -e "s/^\(.*\)$/ '\1',/" +AttributeMacros: [ + 'ATTRIBUTE_ALIGNED_ALIGNOF', + 'ATTRIBUTE_COLD', + 'ATTRIBUTE_FORMAT_PRINTF_STANDARD', + 'ATTRIBUTE_FPTR_PRINTF', + 'ATTRIBUTE_GCC_STRUCT', + 'ATTRIBUTE_HOT', + 'ATTRIBUTE_MALLOC', + 'ATTRIBUTE_NOCLONE', + 'ATTRIBUTE_NONNULL', + 'ATTRIBUTE_NONSTRING', + 'ATTRIBUTE_NORETURN', + 'ATTRIBUTE_NO_SANITIZE_UNDEFINED', + 'ATTRIBUTE_NULL_PRINTF', + 'ATTRIBUTE_PACKED', + 'ATTRIBUTE_PRINTF', + 'ATTRIBUTE_PURE', + 'ATTRIBUTE_RESULT_SIZE_1', + 'ATTRIBUTE_RESULT_SIZE_1_2', + 'ATTRIBUTE_RESULT_SIZE_2', + 'ATTRIBUTE_RETURNS_NONNULL', + 'ATTRIBUTE_SENTINEL', + 'ATTRIBUTE_UNUSED', + 'ATTRIBUTE_UNUSED_LABEL', + 'ATTRIBUTE_UNUSED_RESULT', + 'ATTRIBUTE_USED', + 'ATTRIBUTE_VISIBILITY', + 'ATTRIBUTE_WARN_UNUSED_RESULT', + ] +BinPackArguments: true +BinPackParameters: true +# Because BreakBeforeBraces = GNU, we don't need BraceWrapping. +BreakBeforeBinaryOperators: All +BreakBeforeBraces: GNU +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 79 +CommentPragmas: 'ARI:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +# The docs say not to use this. +# ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +IncludeBlocks: Preserve +# IncludeIsMainRegex: [ not needed ] +IndentCaseLabels: false +# See notes at the top of the file -- this is incorrect but that's a +# clang-format issue. +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +LineEnding: LF +# MacroBlockBegin: '' +# MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +# NamespaceMacros +PackConstructorInitializers: Never +PenaltyBreakAssignment: 50 +PenaltyBreakBeforeFirstCallParameter: 100 +# clang 20 setting: +# PenaltyBreakBeforeMemberAccess: 50 +# PenaltyBreakComment +# PenaltyBreakFirstLessLess +PenaltyBreakOpenParenthesis: 100 +# PenaltyBreakString +# PenaltyBreakTemplateDeclaration +# PenaltyExcessCharacter +# PenaltyReturnTypeOnItsOwnLine +PointerAlignment: Right +# RawStringFormats: [ I don't think we need this ] +# Should be IndentOnly but that requires clang 20. +ReflowComments: false +# FIXME - enable +SortIncludes: Never +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: Always +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInParens: Never +SpacesInSquareBrackets: false +Standard: c++17 +# Oh Python... +StatementMacros: [ 'PyObject_HEAD' ] +TabWidth: 8 +TypenameMacros: [ 'ENUM_BITFIELD' ] +UseTab: ForContinuationAndIndentation diff --git a/.gitignore b/.gitignore index 7f1c81e00c4..eb44ff7f255 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,6 @@ TAGS.sub .local.vimrc .lvimrc -.clang-format .clang-tidy .clangd .cache -- 2.49.0