From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kXvNN34ehWmXXioAWB0awg (envelope-from ) for ; Thu, 05 Feb 2026 17:49:34 -0500 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=DpnCfZMp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D2CBB1E0BA; Thu, 05 Feb 2026 17:49:34 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.3 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,RDNS_NONE autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (unknown [38.145.34.32]) (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 B044A1E08D for ; Thu, 05 Feb 2026 17:49:33 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 2A9DF4C900DC for ; Thu, 5 Feb 2026 22:49:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A9DF4C900DC 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=DpnCfZMp Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 3BFB54B1A357 for ; Thu, 5 Feb 2026 22:49:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BFB54B1A357 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 3BFB54B1A357 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=1770331743; cv=none; b=Tn0PqLBODpdIeHY4R33bANmcSXmBo+53RvUdI5/rFxHRKRhaje/QV/CafsRTF6mILYZqGuteB3SJb99E2eqv6VMaTUIDQQMdLsvODY3ZssC7U9CgAXxXQxiqMCAv62tCt8pKUEVxHYXX7wiQihvYnSAjPhyME/Yetex8l05NpOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770331743; c=relaxed/simple; bh=PwhmbGz0DSuXsCl5IJIy5/R6Nnb3SnKmdkuZc0B18GI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CDS+lF2TiD4vzqgCLcL9btq1ntRRarsezVXXPQbO9MJWAlC3r3DEsupOevdtlsyU3v50FzCa+gotQY4BSCx4Uatj1rwDTZIlIF3VFrWJSpRAosDQOD6qlkd8CGIB7ZXbi72H3PwGQhaLk1yywEom5RGX5xho6oohgJ3SYkVwT14= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BFB54B1A357 Received: from eig-obgw-5004b.ext.cloudfilter.net ([10.0.29.208]) by cmsmtp with ESMTPS id o7jbvzCjRSkcfo89nvB85J; Thu, 05 Feb 2026 22:49:03 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id o89mva4X6qfpWo89mvsuS9; Thu, 05 Feb 2026 22:49:02 +0000 X-Authority-Analysis: v=2.4 cv=A55sP7WG c=1 sm=1 tr=0 ts=69851e5e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=mDV3o1hIAAAA:8 a=jsQJmMRyLB-_L9V9xEIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 a=DCx65vhANUyCzuf5D8fC: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=CidnkuVYeUHH4+jZ27hGJ8l2IeBouYKzHPtevoEiBpw=; b=DpnCfZMpnZeyNExYAN+lBRJ1T3 EC+ROKrlyYUytyjScin4N/ECl31xAsvObxE2sW2IHLLpqB2wWoorkvYhccA9eC3z2AUCWedqZUNmj /mI6r8h2wu00fGuT8pqD5xx8q; Received: from 97-118-49-200.hlrn.qwest.net ([97.118.49.200]:41090 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vo89m-000000028wA-0LtG; Thu, 05 Feb 2026 15:49:02 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v6] Add .clang-format Date: Thu, 5 Feb 2026 15:48:49 -0700 Message-ID: <20260205224851.1629635-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.118.49.200 X-Source-L: No X-Exim-ID: 1vo89m-000000028wA-0LtG X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-49-200.hlrn.qwest.net (localhost.localdomain) [97.118.49.200]:41090 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGjyooXa2Ok4DfgnS9KDslkuqtcmVRdBKtOynd1KSLZ8Hn5H3IFkLY7ihtpz3JCp1WQU1ECwfmXQngvJEixKDNubpkCjNvwKsqpV7QWmMCWzyzNc8t6I 4bh70qdN93lstUja55Ze3tSOk6gJW5fk+4rHLj41lfmmleRSwDLBc1A+E/oESOB5dQuk6Jx8LtHNRQ4Fm9cOwjuoRP2ooqDWzMI= 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, though Kevin Buettner reported trying 19-21 as well. 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: * Comment fixes * Remove ForEachMacros - no longer correct * Remove IncludeCategories - no longer correct New in v5: * More fixes to the comments New in v6: * Removed 'StatementMacros' setting, we're no longer using PyObject_HEAD Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30098 --- .clang-format | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 - 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..fd4f2d951e2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,167 @@ +# -*- yaml -*- + +# Copyright (C) 2021-2026 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# 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. + +# There is currently not a blessed version of clang-format. This was +# tried with versions 18-21 with various results. + +# There's a gdb bug open for discussion of the format. +# +# https://sourceware.org/bugzilla/show_bug.cgi?id=30098 +# +# It also has links to relevant upstream clang-format bugs. + +# 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 +IndentCaseLabels: false +# This next setting is incorrect but it'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 +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