View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0006230 | ardour | other | public | 2015-04-02 12:10 | 2016-11-23 00:21 |
| Reporter | timbyr | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | have not tried |
| Status | closed | Resolution | no change required | ||
| Fixed in Version | 5.X git (version in description) | ||||
| Summary | 0006230: clang-format configuration file for Ardour source code formatting | ||||
| Description | I've attached a clang-format configuration file that should closely match the Ardour source code formatting/style guidelines. It may need tweaking a bit, for instance I've set the ColumnLimit to 120(as I understand it some devs like to use 8 space tabs) but that might not be enough for some(although too much for my taste) etc. A clang version >= 3.6 would be required to get function return types on a separate line from the rest of the declarator. One small issues I can see are what to set for ConstructorInitializerIndentWidth I've set it to 4 spaces but perhaps it should be 8. clang-format can't be configured to insert a tab in that situation unfortunately that I'm aware of. The other issue is the inconsistent use of spaces before parentheses in ardour source. If there is some semantic difference as to when to use a space and when not to then I can't imagine automatic source formatting will be an option. I've set SpacesBeforeParens to Always which is more consistent with ardour style but you may want to set it to ControlStatements to compare. A list of options is at http://clang.llvm.org/docs/ClangFormatStyleOptions.html The .clang-format file would normally be placed in the top level directory of the repository. It can then be used when editing source to reformat files, typically via a keyboard shortcut, or automatically via a script for those contributors who can't setup their editor/IDE. An example/mandated client side pre-commit hook file could also be used to encourage/remind people etc. Anyway, I thought it might be useful to somebody. | ||||
| Tags | No tags attached. | ||||
|
2015-07-22 23:00
|
clang-format (1,816 bytes)
--- Language: Cpp # BasedOnStyle: LLVM AccessModifierOffset: -1 ConstructorInitializerIndentWidth: 4 AlignEscapedNewlinesLeft: false AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false AllowShortFunctionsOnASingleLine: Inline AlwaysBreakTemplateDeclarations: true AlwaysBreakBeforeMultilineStrings: false # not available until clang 3.6 #AlwaysBreakAfterDefinitionReturnType: true BreakBeforeBinaryOperators: false BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: true BinPackParameters: false ColumnLimit: 120 ConstructorInitializerAllOnOneLineOrOnePerLine: false DerivePointerAlignment: false ExperimentalAutoDetectBinPacking: false IndentCaseLabels: false IndentWrappedFunctionNames: false IndentFunctionDeclarationAfterType: false MaxEmptyLinesToKeep: 1 KeepEmptyLinesAtTheStartOfBlocks: true NamespaceIndentation: None ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakString: 1000 PenaltyBreakFirstLessLess: 120 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left SpacesBeforeTrailingComments: 1 Cpp11BracedListStyle: false Standard: Cpp03 IndentWidth: 1 TabWidth: 1 UseTab: ForIndentation BreakBeforeBraces: Stroustrup SpacesInParentheses: false SpacesInAngles: false SpaceInEmptyParentheses: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: true SpaceBeforeAssignmentOperators: true ContinuationIndentWidth: 4 CommentPragmas: '^ IWYU pragma:' ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] SpaceBeforeParens: Always DisableFormat: false ... |
|
|
I've updated the file with IndentCaseLabels: false instead of true Ardour has a mixed use of indented and non-indented case labels. I prefer non indented case labels as it reduces indentation. |
|
|
A clang-format file was added as tools/clang-format some time ago. It requires a clang version >= 3.6 |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2015-04-02 12:10 | timbyr | New Issue | |
| 2015-04-02 12:10 | timbyr | File Added: .clang-format | |
| 2015-07-22 22:59 | timbyr | File Deleted: .clang-format | |
| 2015-07-22 23:00 | timbyr | File Added: clang-format | |
| 2015-07-22 23:03 | timbyr | Note Added: 0016932 | |
| 2016-11-23 00:21 | timbyr | Note Added: 0019029 | |
| 2016-11-23 00:21 | timbyr | Status | new => closed |
| 2016-11-23 00:21 | timbyr | Resolution | open => no change required |
| 2016-11-23 00:21 | timbyr | Fixed in Version | => 5.X git (version in description) |