diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2022-10-28 12:47:26 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:44:56 -0500 |
commit | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (patch) | |
tree | 05d01bcbf40e65ac9bf422a4d029b1c6e8ae2291 | |
parent | dcee6fb39812ace0df59b8d0dd43cd41d2f02e54 (diff) | |
download | binutils-gdb-ca7f92c2f15b86b09c4a8ad14806bef666308d31.tar.gz |
Add .clang-format and clang-format.sh
Add .clang-format from [1] and script to easily make a mass reformat.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=30098
Change-Id: Ibc8dc7f33fa1226dc67c59e4ccd0d624685e0316
-rw-r--r-- | .clang-format | 143 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | clang-format.sh | 12 | ||||
-rw-r--r-- | gdbserver/.clang-format | 127 | ||||
-rw-r--r-- | gdbsupport/.clang-format | 127 |
5 files changed, 409 insertions, 1 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..70831805977 --- /dev/null +++ b/.clang-format @@ -0,0 +1,143 @@ +# -*- yaml -*- + +# Notes for gdb. +# * 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 +# * gettext calls like "_()" are reformatted to "_ ()" +# I don't think there's an upstream bug for this yet + +# Last update from clang-format version 14. + +# FIXME: AttributeMacros? + +Language: Cpp +# BasedOnStyle: GNU +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: false +# FIXME probably needs a decision +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +# This isn't truly needed because +# ConstructorInitializerAllOnOneLineOrOnePerLine is false. +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +# Deprecated, so we don't set it. +# AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +# 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 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Always +EmptyLineBeforeAccessModifier: Always +# The docs say not to use this. +# ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - ALL_BLOCK_SYMBOLS + - ALL_BLOCK_SYMBOLS_WITH_NAME + - ALL_BREAKPOINTS_SAFE + - ALL_OBJFILE_OSECTIONS + - ALL_DICT_SYMBOLS + # FIXME may be more here +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(common-defs.h|defs.h|server.h)/' + Priority: -1 +# IncludeIsMainRegex: FIXME +IndentCaseLabels: false +IndentExternBlock: NoIndent +# FIXME This is not quite right, there should be a single preceding +# space. +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +# FIXME this doesn't seem quite right +LambdaBodyIndentation: OuterScope +# MacroBlockBegin: '' +# MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +# NamespaceMacros +PackConstructorInitializers: Never +# PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 200 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 100 +# PenaltyBreakString: 100 +# PenaltyBreakTemplateDeclaration: 1000 +# PenaltyExcessCharacter: 10 +# PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +# Too dangerous to turn on. +QualifierAlignment: Leave +# RawStringFormats: ??? +ReferenceAlignment: Pointer +# FIXME - enable +ReflowComments: false +# FIXME Leave? +SeparateDefinitionBlocks: Always +# FIXME - enable +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: Always +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +# StatementMacros: do we have any? +TabWidth: 8 +# TypenameMacros: do we have any? +UseCRLF: false +UseTab: Always diff --git a/.gitignore b/.gitignore index d44f60295d0..11e858408c4 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,6 @@ TAGS.sub .local.vimrc .lvimrc -.clang-format .clang-tidy .clangd .cache diff --git a/clang-format.sh b/clang-format.sh new file mode 100644 index 00000000000..8de3efeb4ef --- /dev/null +++ b/clang-format.sh @@ -0,0 +1,12 @@ +#/usr/bin/env bash + +set -x +set -e + +CLANG_FORMAT=${CLANG_FORMAT:-clang-format} + +$CLANG_FORMAT -i \ + gdb/*.h gdb/*.c \ + gdb/*/*.h gdb/*/*.c \ + gdbserver/*.h gdbserver/*.cc \ + gdbsupport/*.h gdbsupport/*.cc diff --git a/gdbserver/.clang-format b/gdbserver/.clang-format new file mode 100644 index 00000000000..2fcbb67fec8 --- /dev/null +++ b/gdbserver/.clang-format @@ -0,0 +1,127 @@ +# -*- yaml -*- + +# Notes for gdb. +# * 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 +# * gettext calls like "_()" are reformatted to "_ ()" +# I don't think there's an upstream bug for this yet + +Language: Cpp +# BasedOnStyle: GNU +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: false +# FIXME probably needs a decision +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +# This isn't truly needed because +# ConstructorInitializerAllOnOneLineOrOnePerLine is false. +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +# Deprecated, so we don't set it. +# AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +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 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +# The docs say not to use this. +# ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - ALL_BLOCK_SYMBOLS + - ALL_BLOCK_SYMBOLS_WITH_NAME + - ALL_BREAKPOINTS + - ALL_BREAKPOINTS_SAFE + - ALL_BP_LOCATIONS + - ALL_BP_LOCATIONS_AT_ADDR + # FIXME many more here +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(common-defs.h|defs.h|server.h)/' + Priority: -1 +# IncludeIsMainRegex: FIXME +IndentCaseLabels: false +# FIXME I think this is not quite right, +# they should be outdented slightly. +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +# MacroBlockBegin: '' +# MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +# NamespaceMacros +# PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 200 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakString: 100 +# PenaltyBreakTemplateDeclaration: 1000 +# PenaltyExcessCharacter: 10 +# PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +# RawStringFormats: ??? +# FIXME - enable +ReflowComments: false +# FIXME - enable +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: Always +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +# StatementMacros: do we have any? +TabWidth: 8 +# TypenameMacros: do we have any? +UseCRLF: false +UseTab: Never diff --git a/gdbsupport/.clang-format b/gdbsupport/.clang-format new file mode 100644 index 00000000000..2fcbb67fec8 --- /dev/null +++ b/gdbsupport/.clang-format @@ -0,0 +1,127 @@ +# -*- yaml -*- + +# Notes for gdb. +# * 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 +# * gettext calls like "_()" are reformatted to "_ ()" +# I don't think there's an upstream bug for this yet + +Language: Cpp +# BasedOnStyle: GNU +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: false +# FIXME probably needs a decision +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +# This isn't truly needed because +# ConstructorInitializerAllOnOneLineOrOnePerLine is false. +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +# Deprecated, so we don't set it. +# AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +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 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +# The docs say not to use this. +# ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - ALL_BLOCK_SYMBOLS + - ALL_BLOCK_SYMBOLS_WITH_NAME + - ALL_BREAKPOINTS + - ALL_BREAKPOINTS_SAFE + - ALL_BP_LOCATIONS + - ALL_BP_LOCATIONS_AT_ADDR + # FIXME many more here +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(common-defs.h|defs.h|server.h)/' + Priority: -1 +# IncludeIsMainRegex: FIXME +IndentCaseLabels: false +# FIXME I think this is not quite right, +# they should be outdented slightly. +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +# MacroBlockBegin: '' +# MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +# NamespaceMacros +# PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 200 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakString: 100 +# PenaltyBreakTemplateDeclaration: 1000 +# PenaltyExcessCharacter: 10 +# PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +# RawStringFormats: ??? +# FIXME - enable +ReflowComments: false +# FIXME - enable +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: Always +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +# StatementMacros: do we have any? +TabWidth: 8 +# TypenameMacros: do we have any? +UseCRLF: false +UseTab: Never |