View Issue Details

IDProjectCategoryView StatusLast Update
0001105OpenMPTGeneralpublic2021-02-14 13:09
Reportermanx Assigned Tomanx  
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionfixed 
Product VersionOpenMPT 1.28.00.* (old testing) 
Target VersionOpenMPT 1.?? (long term goals)Fixed in VersionOpenMPT 1.29.00.* (old testing) 
Summary0001105: clang-format support
Description

VS2017 15.7 will support clang-format natively. See https://blogs.msdn.microsoft.com/vcblog/2018/03/13/clangformat-support-in-visual-studio-2017-15-7-preview-1/.

Additional Information

There are multiple tools that can derive formatting style from existing source code:

TagsNo tags attached.
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Relationships

related to 0001413 assignedmanx run clang-format on examples/, libopenmpt/, openmpt123/ 
related to 0001416 resolvedmanx run clang-format on soundbase/, and sounddev/ 

Activities

manx

manx

2018-05-12 13:36

administrator   ~0003526

Last edited: 2018-05-12 13:41

running whatstyle no soundlib alone takes about 1h on my Debian 10 VM and results in

# whatstyle.py --formatter clang-format-5.0 soundlib/*.cpp soundlib/*.h
# whatstyle 0.1.5 (Debian 10 2018-05-12)
BasedOnStyle: Google
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
BraceWrapping:
 AfterClass: true
 AfterControlStatement: true
 AfterEnum: true
 AfterFunction: true
 AfterNamespace: true
 AfterStruct: true
 AfterUnion: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 1
IndentCaseLabels: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
SortIncludes: false
SpaceAfterTemplateKeyword: false
SpaceBeforeParens: Never
SpacesBeforeTrailingComments: 1
TabWidth: 2
UseTab: Always

which is obviously not ideal

manx

manx

2018-05-12 13:40

administrator   ~0003527

A hand-written clang-format file would look somewhat like

Language: Cpp
AccessModifierOffset: -4
AlignEscapedNewlines: DontAlign
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
 AfterClass: true
 AfterControlStatement: true
 AfterEnum: true
 AfterFunction: true
 AfterNamespace: true
 AfterStruct: true
 AfterUnion: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: false
ColumnLimit: 0
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
IndentWidth: 4
MaxEmptyLinesToKeep: 5
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceBeforeParens: Never
SpacesBeforeTrailingComments: 2
SpacesInContainerLiterals: false
Standard: Cpp11
TabWidth: 4
UseTab: ForIndentation

This is based on clang-format 5.0 because this version is shipped with VS2017 15.7.

manx

manx

2018-05-12 13:51

administrator   ~0003528

Last edited: 2018-05-12 14:07

Hand-written version for libopenmpt:

Language: Cpp
AccessModifierOffset: -2
AlignEscapedNewlines: DontAlign
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
 AfterClass: false
 AfterControlStatement: false
 AfterEnum: false
 AfterFunction: false
 AfterNamespace: false
 AfterObjCDeclaration: false
 AfterStruct: false
 AfterUnion: false
 BeforeCatch: false
 BeforeElse: false
 IndentBraces: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: false
ColumnLimit: 0
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
IndentCaseLabels: true
IndentWidth: 2
MaxEmptyLinesToKeep: 3
PointerAlignment: Middle
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: 2
SpacesInContainerLiterals: false
SpacesInParentheses: true
SpacesInSquareBrackets: true
Standard: Cpp11
TabWidth: 2
UseTab: ForIndentation
manx

manx

2019-07-03 11:56

administrator   ~0003970

Implemented in r11706.

Issue History

Date Modified Username Field Change
2018-03-19 10:05 manx New Issue
2018-03-19 10:05 manx Status new => assigned
2018-03-19 10:05 manx Assigned To => manx
2018-05-12 13:36 manx Note Added: 0003526
2018-05-12 13:40 manx Note Added: 0003527
2018-05-12 13:41 manx Note Edited: 0003526
2018-05-12 13:51 manx Note Added: 0003528
2018-05-12 14:07 manx Note Edited: 0003528
2018-11-13 07:42 manx Target Version OpenMPT 1.28.01.00 / libopenmpt 0.4.0 (upgrade first) => OpenMPT 1.?? (long term goals)
2019-07-03 11:56 manx Status assigned => resolved
2019-07-03 11:56 manx Resolution open => fixed
2019-07-03 11:56 manx Fixed in Version => OpenMPT 1.29.00.* (old testing)
2019-07-03 11:56 manx Note Added: 0003970
2021-01-30 09:38 manx Status resolved => assigned
2021-02-14 09:40 manx Relationship added related to 0001413
2021-02-14 13:09 manx Relationship added related to 0001416