View Issue Details

IDProjectCategoryView StatusLast Update
0001105OpenMPT[All Projects] Generalpublic2018-11-13 07:42
ReportermanxAssigned Tomanx 
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionopen 
Product VersionOpenMPT 1.28.00.* (current testing) 
Target VersionOpenMPT 1.?? (long term goals)Fixed in Version 
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)

Activities

manx

manx

2018-05-12 13:36

administrator   ~0003526

Last edited: 2018-05-12 13:41

View 2 revisions

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

View 2 revisions

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

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 View Revisions
2018-05-12 13:51 manx Note Added: 0003528
2018-05-12 14:07 manx Note Edited: 0003528 View Revisions
2018-11-13 07:42 manx Target Version OpenMPT 1.28.01.00 (goals) => OpenMPT 1.?? (long term goals)