Date: Tue, 16 Apr 2019 16:26:02 -0400 From: Alexander Richardson <arichardson@freebsd.org> To: freebsd-hackers@freebsd.org Subject: Clang-format config for FreeBSD style Message-ID: <CA%2BZ_v8qfbwabbTM4qWd=NYmF0oCmCOg0oMSWxXiHhYbxpyO-nA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello all, For CheriBSD I have added a .clang-format file[1] that (at least based on some simple checking) gets reasonably close to existing style. Is there any interest in adding this to the main repository so that future patches can easily be formatted using git-clang-format or clang-format-diff. I find that clang-format increases my productivity when I submit patches for LLVM since I can write my code, run git-clang-format and then upload the patch to phabricator and know that I won't have to fix lots of coding style errors before the patch can be submitted. Would there be interest in adding this config file to the src repository? I am not proposing mandatory clang-format before commit in a phabricator hook, but I do wonder if this would be possible in the future once clang-format produces correctly formatted code. The attached config file gets close for some files that I tested but there are definitely some line-wrapping changes that could cause unncessary code churn if it was applied in bulk to existing code. However, I do think that it could be useful for new patches (and makes it easier for people like me who can't remember all the coding style requirements for the different projects they contribute to). Alex [1] # Basic .clang-format --- BasedOnStyle: WebKit AlignAfterOpenBracket: DontAlign AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: false AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: InlineOnly AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: TopLevel AlwaysBreakAfterReturnType: TopLevelDefinitions BinPackArguments: true BinPackParameters: true BreakBeforeBinaryOperators: None BreakBeforeBraces: WebKit BreakBeforeTernaryOperators: false # TODO: BreakStringLiterals can cause very strange formatting so turn it off? # BreakStringLiterals: false # Avoid breaking function calls before the first argument: PenaltyBreakBeforeFirstCallParameter: 100000 CommentPragmas: '^ CHERI CHANGES START' CompactNamespaces: true DerivePointerAlignment: false DisableFormat: false ForEachMacros: - SLIST_FOREACH - SLIST_FOREACH_SAFE - LIST_FOREACH - LIST_FOREACH_SAFE - STAILQ_FOREACH - STAILQ_FOREACH_SAFE - TAILQ_FOREACH - TAILQ_FOREACH_SAFE IndentCaseLabels: false IndentPPDirectives: None Language: Cpp NamespaceIndentation: None PointerAlignment: Right ContinuationIndentWidth: 4 IndentWidth: 8 TabWidth: 8 ColumnLimit: 80 UseTab: Always SortIncludes: false ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BZ_v8qfbwabbTM4qWd=NYmF0oCmCOg0oMSWxXiHhYbxpyO-nA>