From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9cJVHqYO5Giw7yEAWB0awg (envelope-from ) for ; Mon, 06 Oct 2025 14:47:02 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GY1kDa3H; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6B9711E0B6; Mon, 06 Oct 2025 14:47:02 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 3C3D71E047 for ; Mon, 06 Oct 2025 14:47:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC5E33858D38 for ; Mon, 6 Oct 2025 18:47:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC5E33858D38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GY1kDa3H Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id DF2CA3858D1E for ; Mon, 6 Oct 2025 18:46:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF2CA3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF2CA3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759776381; cv=none; b=uANpRUqDgsxgSJYyMdN9MPbpMPXI+19dqThtiYLEZlNnDJJXJdQoytZcVm/9FjtptFe3nVJdtBerqC2/DOMNBvgGRsT7tqv1CF5ZLbnyeg5zHAAJqw5wC3iIczfahiRUDmpdrQ5A+EarHYLyYQtJgY1/Jmdju+gmurqiMGnHzQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759776381; c=relaxed/simple; bh=lhF6Pd6yo90yHomkVmohp//V4Gen/8ePHA2gK/ADyNY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=rfdoIK2/EYkKXVqkPxWgY+Lzvudoxc88+txBbXGNtAPh58NHTkQvWNIKwD3lwYfeJGzIxRvmzyD6YcCwy765krZm6zS+5tdnK6p9A5BmUviWFD0ARbpql+iUGs5YDKBSrVGdKrFRpxbdVMx96iDzbSmeJO9kCBDdmjBl+RQ3Bak= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF2CA3858D1E Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b553412a19bso3825967a12.1 for ; Mon, 06 Oct 2025 11:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759776375; x=1760381175; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=p6yUTekq2bH4ixoQK9JToTazVCdVcFWMh/88A3OdQbQ=; b=GY1kDa3HwDTRSncn7mEo5tG5wSxwRRfMJQs0tYWgrhbqrax6EUqeqLNaaNkWEiXKLN 0DDmuSZ1r4bilKYBt+ApU/EgvuTuRla1ME/h8cucZTr4aEiAtXHDFCuMpo8+6Sh2AW5R vMIOFGt3VJpqmh92sSKqUwIb90WwxwROc2wuw1lUPA4qJ+ypbmEEy3Eif/WOTYXTEeXz AiGUW/vQfC3x06AY9J4HR5W61VU7nGULRgYvYyienxn1LXdZnubCdjYMINFg2X7/Bhu+ 3dXwLpS7jH8O+AW36MaaLCobp9c3QqLCANI/xk6Lhw1RpiRmWNFB0oZkolbCUPF2gRTO qqRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759776375; x=1760381175; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p6yUTekq2bH4ixoQK9JToTazVCdVcFWMh/88A3OdQbQ=; b=IYqXVvBfHSeTi2mR75t2XidPffqZ+rSEKxyCZUO09Sdi5t6LmxXntxXl0IYg921Tee YiAi6LGfHDcgwIeTx4Tp4yEVE8s9WRgxhIHdZrOZajOWlhr0E9K4XSJI2c1zQ7dRyLzi AgNo99Eny1FsFrEhPp5hYrMKVwiv67/MLMdESX0MGv8AvDPZxpSF602bmaA5vFbYYYDI vpYirE8d9Vu51j3gP0TQ7H59SVw6RfOM3+aHPzAHIiB9pgKJQ7qHFZ9D4g3Ne2sXD0oT 6id2TAW5fLYPVXl/A6lxUGkzOrXOF/CflU39/jdCB+HEEklXQB2SfUYxV6qLQnSCySSy ZaMA== X-Gm-Message-State: AOJu0YwNi6K/LyAkiLaKu2zXhcPqdw1BUzYr5U8aJhbFAfVIFyv85I8Z puRBv+CLAgCrHbQ90X/f7QXQshwCpMP2awy28lbhUEqgY8YGiFUv+/fvQaf+Wj6O72PgBxobOkW 3UwrAzfxUQXqlouYHInCUQTffhZcmFTE= X-Gm-Gg: ASbGncvg5KirS48Yo40XD0XB5uWtj1aV8yX/rRgxE6J6Zyat0ax+wssoMSIf/9Wu9vZ aUPHspjENVdXQV7DIzRzz+mHcVUR95+ICdhz/Ue0OucEGGoYHLQELAmqBMnNpSzjX0EhF1y0XvB 7evGGnv26oR6yZEvAEcJxioeJ4ZcQJUDQ8G6XM+JMpWhR/nTrylJnQweINm0yYEIq88o6Aew41j mVjRY/u6FP7ArnLOcA40Lbf3vo81g== X-Google-Smtp-Source: AGHT+IEovNGna88gSkB2OF4Q49kt4OOTvUxLx6SIpdq+g0M96a4Dcl7VVIeLE4TdKctFRhRHn/+/Y7/v6ENX4EQX28U= X-Received: by 2002:a17:903:4b48:b0:288:e46d:b318 with SMTP id d9443c01a7336-28e9a65634emr152548245ad.40.1759776374239; Mon, 06 Oct 2025 11:46:14 -0700 (PDT) MIME-Version: 1.0 References: <20251006183901.1239002-1-tom@tromey.com> In-Reply-To: <20251006183901.1239002-1-tom@tromey.com> From: Andrew Pinski Date: Mon, 6 Oct 2025 11:46:02 -0700 X-Gm-Features: AS18NWDnmq6sOMwS5JHpsQmSY-N01JjtYT0CH4e5Cf5RaVGLTuA8HYHof0-Uqqg Message-ID: Subject: Re: [PATCH v4] Add .clang-format To: Tom Tromey Cc: gdb-patches@sourceware.org, GCC Mailing List , binutils Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Mon, Oct 6, 2025 at 11:39=E2=80=AFAM Tom Tromey wrote: > > 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. We had a small discussion about this at the cauldron and I think it was agreed that we should include the same across at least GCC, gdb/binutils too. In a similar way to .editorconfig . Note I do think it is a good idea to have this even though I am not going to use clang-format to do my own formating. Thanks, Andrew > > 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=3D30098 > --- > .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. > + > +# =E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F DO NOT BULK REF= ORMAT FILES =E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F > + > +# 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 =3D 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 >