Skip to content

Commit 1cad7bb

Browse files
committed
Require version 13 of clang-format and clean its setup file
The .clang-format file was plenty with commented out options that were not used and hence the value of Google style was used unchanged. Since such a code was cluttering the file content, I removed it. Only for those options that are changed w.r.t. to Google default, I left some explanation, which is taken from clang-format documentation.
1 parent 3d77495 commit 1cad7bb

File tree

3 files changed

+57
-125
lines changed

3 files changed

+57
-125
lines changed

.clang-format

+51-118
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,63 @@
11
BasedOnStyle: Google
22

3-
## The extra indent or outdent of access modifiers, e.g. public:.
4-
#AccessModifierOffset: -1
5-
#
6-
## If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column.
7-
#AlignEscapedNewlinesLeft: false
8-
#
9-
## If true, aligns trailing comments.
10-
#AlignTrailingComments: true
11-
#
12-
## Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false.
13-
#AllowAllParametersOfDeclarationOnNextLine: false
14-
15-
# If true, if (a) return; can be put on a single line.
3+
# If true, if (a) return; can be put on a single line.
164
AllowShortIfStatementsOnASingleLine: false
175

18-
# If true, while (true) continue; can be put on a single line.
6+
# If true, while (true) continue; can be put on a single line.
197
AllowShortLoopsOnASingleLine: false
208

9+
# Dependent on the value, int f() { return 0; } can be put on a single line.
2110
AllowShortFunctionsOnASingleLine: true
2211

23-
## If true, always break before multiline string literals.
24-
#AlwaysBreakBeforeMultilineStrings: false
25-
#
26-
## If true, always break after the template<...> of a template declaration.
27-
#AlwaysBreakTemplateDeclarations: false
28-
#
29-
## If false, a function call’s or function definition’s parameters will either all be on the same line or will have one line each.
30-
#BinPackParameters: false
31-
#
32-
## If true, binary operators will be placed after line breaks.
33-
#BreakBeforeBinaryOperators: false
34-
#
35-
## The brace breaking style to use.
36-
## Possible values:
37-
## BS_Attach (in configuration: Attach) Always attach braces to surrounding context.
38-
## BS_Linux (in configuration: Linux) Like Attach, but break before braces on function, namespace and class definitions.
39-
## BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before function definitions.
40-
## BS_Allman (in configuration: Allman) Always break before braces.
41-
#BreakBeforeBraces: Linux
42-
#
43-
## Always break constructor initializers before commas and align the commas with the colon.
44-
#BreakConstructorInitializersBeforeComma: true
45-
#
46-
## The column limit.
47-
## A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements.
12+
# The column limit.
13+
# A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements.
4814
ColumnLimit: 80
49-
#
50-
## If the constructor initializers don’t fit on a line, put each initializer on its own line.
51-
##ConstructorInitializerAllOnOneLineOrOnePerLine (bool)
52-
#
53-
## The number of characters to use for indentation of constructor initializer lists.
54-
##ConstructorInitializerIndentWidth (unsigned)
55-
#
56-
## If true, format braced lists as best suited for C++11 braced lists.
57-
## Important differences: - No spaces inside the braced list. - No line break before the closing brace. - Indentation with the continuation indent, not with the block indent.
58-
## Fundamentally, C++11 braced lists are formatted exactly like function calls would be formatted in their place. If the braced list follows a name (e.g. a type or variable name), clang-format formats as if the {} were the parentheses of a function call with that name. If there is no name, a zero-length name is assumed.
15+
16+
# If true, format braced lists as best suited for C++11 braced lists.
5917
Cpp11BracedListStyle: true
60-
#
61-
## If true, analyze the formatted file for the most common binding.
62-
##DerivePointerBinding (bool)
63-
#
64-
## If true, clang-format detects whether function calls and definitions are formatted with one parameter per line.
65-
## Each call can be bin-packed, one-per-line or inconclusive. If it is inconclusive, e.g. completely on one line, but a decision needs to be made, clang-format analyzes whether there are other bin-packed cases in the input file and act accordingly.
66-
## NOTE: This is an experimental flag, that might go away or be renamed. Do not use this in config files, etc. Use at your own risk.
67-
##ExperimentalAutoDetectBinPacking (bool)
68-
#
69-
## Indent case labels one level from the switch statement.
70-
## When false, use the same indentation level as for the switch statement. Switch statement body is always indented one level more than case labels.
71-
#IndentCaseLabels: false
72-
#
73-
## If true, indent when breaking function declarations which are not also definitions after the type.
74-
##IndentFunctionDeclarationAfterType (bool)
75-
#
76-
## The number of characters to use for indentation.
77-
#IndentWidth: 2
78-
#
79-
## The maximum number of consecutive empty lines to keep.
80-
#MaxEmptyLinesToKeep: 1
81-
#
82-
## The indentation used for namespaces.
83-
## Possible values:
84-
## NI_None (in configuration: None) Don’t indent in namespaces.
85-
## NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in other namespaces).
86-
## NI_All (in configuration: All) Indent in all namespaces.
87-
#NamespaceIndentation: None
88-
#
89-
## Add a space in front of an Objective-C protocol list, i.e. use Foo <Protocol> instead of Foo<Protocol>.
90-
##ObjCSpaceBeforeProtocolList (bool)
91-
#
92-
## The penalty for each line break introduced inside a comment.
93-
##PenaltyBreakComment (unsigned)
94-
#
95-
## The penalty for breaking before the first <<.
96-
##PenaltyBreakFirstLessLess (unsigned)
97-
#
98-
## The penalty for each line break introduced inside a string literal.
99-
##PenaltyBreakString (unsigned)
100-
## The penalty for each character outside of the column limit.
101-
##PenaltyExcessCharacter (unsigned)
102-
## Penalty for putting the return type of a function onto its own line.
103-
##PenaltyReturnTypeOnItsOwnLine (unsigned)
104-
## Set whether & and * bind to the type as opposed to the variable.
105-
##PointerBindsToType: false
106-
## If true, spaces will be inserted between ‘for’/’if’/’while’/... and ‘(‘.
107-
##SpaceAfterControlStatementKeyword: true
108-
## If false, spaces will be removed before ‘=’, ‘+=’, etc.
109-
##SpaceBeforeAssignmentOperators: true
110-
## If false, spaces may be inserted into ‘()’.
111-
##SpaceInEmptyParentheses: false
112-
## The number of spaces to before trailing line comments.
113-
##SpacesBeforeTrailingComments (unsigned)
114-
## If false, spaces may be inserted into C style casts.
115-
##SpacesInCStyleCastParentheses (bool)
116-
#
117-
## If true, spaces will be inserted after every ‘(‘ and before every ‘)’.
118-
#SpacesInParentheses: false
119-
#
120-
## Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03.
121-
## Possible values:
122-
## LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax.
123-
## LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A<A<int>> instead of A<A<int> >).
124-
## LS_Auto (in configuration: Auto) Automatic detection based on the input.
18+
19+
# Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03.
20+
# Possible values:
21+
# LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax.
22+
# LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A<A<int>> instead of A<A<int> >).
23+
# LS_Auto (in configuration: Auto) Automatic detection based on the input.
12524
Standard: Cpp11
126-
#
127-
## If true, IndentWidth consecutive spaces will be replaced with tab characters.
128-
#UseTab: false
12925

130-
# vim: ft=yaml
26+
# Regular expressions denoting the different #include categories used for ordering #includes.
27+
# - POSIX extended regular expressions are supported.
28+
# - These regular expressions are matched against the filename of an include (including the <> or "") in order.
29+
# - The value belonging to the first matching regular expression is assigned and #includes are sorted
30+
# first according to increasing category number and then alphabetically within each category.
31+
# - If none of the regular expressions match, INT_MAX is assigned as category.
32+
# - The main header for a source file automatically gets category 0 so that it is generally kept at
33+
# the beginning of the #includes (https://llvm.org/docs/CodingStandards.html#include-style).
34+
# However, you can also assign negative priorities if you have certain headers that always need to be first.
35+
#
36+
# NOTE: Include here all regex to fulfill Google style guide -> https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
37+
IncludeCategories:
38+
- Regex: '^(<|")vir/test\.h(>|")' # This has always to be included first => Negative priority
39+
Priority: -1
40+
CaseSensitive: true
41+
- Regex: '^<(sys/)?[^/]*\.h>'
42+
Priority: 1
43+
SortPriority: 0
44+
CaseSensitive: false
45+
- Regex: '^<[[:alnum:]._]+>'
46+
Priority: 2
47+
SortPriority: 0
48+
CaseSensitive: false
49+
- Regex: '^(<|"(Eigen|gsl|HepMC3|Pythia8|Rivet|vir|yaml-cpp)/)[^/]*'
50+
Priority: 3
51+
SortPriority: 0
52+
CaseSensitive: false
53+
- Regex: '^"einhard\.hpp"'
54+
Priority: 3
55+
SortPriority: 0
56+
CaseSensitive: false
57+
- Regex: '^(<|")smash/.*\.h(>|")' # SMASH include should be left in the last block
58+
Priority: 4
59+
CaseSensitive: false
60+
- Regex: '.*'
61+
Priority: 4
62+
SortPriority: 0
63+
CaseSensitive: false

CONTRIBUTING.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ warnings are however still reported.
111111
## Development Tools
112112

113113
The following tools can be helpful for development:
114-
- clang-format = 6.0
114+
- clang-format = 13.0.0
115115
- doxygen >= 1.8.4
116116
- valgrind
117117
- cpplint
@@ -123,9 +123,8 @@ Note: The above mentioned clang-format version is enforced at each merge to mast
123123

124124
### Installing clang-format
125125

126-
clang-format is a part of the clang compiler. The usage of version 6.0.0 is
127-
enforced. You can download the binaries here
128-
http://releases.llvm.org/download.html.
126+
clang-format is a part of the clang compiler. The usage of version 13.0.0 is
127+
enforced. You can download the binaries [here](http://releases.llvm.org/download.html).
129128

130129
Make sure to pick a pre-built binary for your system. For example, for Ubuntu
131130
you could run:
@@ -461,7 +460,7 @@ following way:
461460
### Code Formatting with `clang-format` and `cmake-format`
462461
463462
All C++ code has to be formatted by running [`clang-format`](https://releases.llvm.org/download.html),
464-
(version `6.0.0`) while CMake code requires [`cmake-format`](https://github.com/cheshirekow/cmake_format)
463+
(version `13.0.0`) while CMake code requires [`cmake-format`](https://github.com/cheshirekow/cmake_format)
465464
(version `0.6.13`) to be run. These two programs automatically format the code in SMASH correctly.
466465
Use the helper script in SMASH's **_/bin_** directory to format the source code via
467466

bin/codebase-format-helper.bash

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function check_formatter_version()
6868
language="$1"
6969
found=$(${FORMATTER_COMMAND[${language}]} --version)
7070
if [[ ${language} = 'C++' ]]; then
71-
required='6.0.0'
72-
found="${found:21:5}"
71+
required='13.0.0'
72+
found="${found:21:6}"
7373
elif [[ ${language} = 'CMake' ]]; then
7474
required='0.6.13'
7575
fi

0 commit comments

Comments
 (0)