Skip to content

Commit 86513ee

Browse files
author
Thomas Kiley
authored
Merge pull request #1324 from reuk/reuk/clang-format
Reformat sources with clang-format
2 parents ea4a777 + 2110cd1 commit 86513ee

File tree

7 files changed

+460
-277
lines changed

7 files changed

+460
-277
lines changed

.clang-format

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
AccessModifierOffset: '-2'
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: 'false'
5+
AlignConsecutiveDeclarations: 'false'
6+
AlignEscapedNewlinesLeft: 'false'
7+
AlignOperands: 'true'
8+
AlignTrailingComments: 'true'
9+
AllowAllParametersOfDeclarationOnNextLine: 'false'
10+
AllowShortBlocksOnASingleLine: 'false'
11+
AllowShortCaseLabelsOnASingleLine: 'false'
12+
AllowShortFunctionsOnASingleLine: None
13+
AllowShortIfStatementsOnASingleLine: 'false'
14+
AllowShortLoopsOnASingleLine: 'false'
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: 'true'
17+
AlwaysBreakTemplateDeclarations: 'true'
18+
BinPackArguments: 'false'
19+
BinPackParameters: 'false'
20+
BreakBeforeBinaryOperators: None
21+
BreakBeforeBraces: Allman
22+
BreakBeforeTernaryOperators: 'true'
23+
BreakConstructorInitializersBeforeComma: 'false'
24+
ColumnLimit: '80'
25+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
26+
ConstructorInitializerIndentWidth: '2'
27+
ContinuationIndentWidth: '2'
28+
Cpp11BracedListStyle: 'true'
29+
DerivePointerAlignment: 'false'
30+
DisableFormat: 'false'
31+
ExperimentalAutoDetectBinPacking: 'false'
32+
ForEachMacros: [
33+
'forall_rw_range_set_r_objects',
34+
'Forall_rw_range_set_r_objects',
35+
'forall_rw_range_set_w_objects',
36+
'Forall_rw_range_set_w_objects',
37+
'forall_rw_set_r_entries',
38+
'Forall_rw_set_r_entries',
39+
'forall_rw_set_w_entries',
40+
'Forall_rw_set_w_entries',
41+
'forall_goto_functions',
42+
'Forall_goto_functions',
43+
'forall_goto_program_instructions',
44+
'Forall_goto_program_instructions',
45+
'forall_objects',
46+
'Forall_objects',
47+
'forall_valid_objects',
48+
'Forall_valid_objects',
49+
'forall_nodes',
50+
'Forall_nodes',
51+
'forall_literals',
52+
'Forall_literals',
53+
'forall_operands',
54+
'Forall_operands',
55+
'forall_expr',
56+
'Forall_expr',
57+
'forall_expr_list',
58+
'Forall_expr_list',
59+
'forall_symbolptr_list',
60+
'Forall_symbolptr_list',
61+
'forall_guard',
62+
'Forall_guard',
63+
'forall_irep',
64+
'Forall_irep',
65+
'forall_named_irep',
66+
'Forall_named_irep',
67+
'forall_value_list',
68+
'Forall_value_list',
69+
'forall_symbols',
70+
'Forall_symbols',
71+
'forall_symbol_base_map',
72+
'Forall_symbol_base_map',
73+
'forall_symbol_module_map',
74+
'Forall_symbol_module_map',
75+
'forall_subtypes',
76+
'Forall_subtypes']
77+
IndentCaseLabels: 'false'
78+
IndentWidth: '2'
79+
IndentWrappedFunctionNames: 'false'
80+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
81+
Language: Cpp
82+
MaxEmptyLinesToKeep: '1'
83+
NamespaceIndentation: None
84+
PenaltyBreakString: 10000
85+
PointerAlignment: Right
86+
ReflowComments: 'false'
87+
SortIncludes: 'false'
88+
SpaceAfterCStyleCast: 'false'
89+
SpaceBeforeAssignmentOperators: 'true'
90+
SpaceBeforeParens: Never
91+
SpaceInEmptyParentheses: 'false'
92+
SpacesBeforeTrailingComments: '1'
93+
SpacesInAngles: 'false'
94+
SpacesInCStyleCastParentheses: 'false'
95+
SpacesInContainerLiterals: 'false'
96+
SpacesInParentheses: 'false'
97+
SpacesInSquareBrackets: 'false'
98+
Standard: Cpp11
99+
TabWidth: '2'
100+
UseTab: Never
101+
102+
...

.travis.yml

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,33 @@ language: cpp
33
jobs:
44
include:
55

6+
- &formatting-stage
7+
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
8+
env: NAME="clang-format"
9+
addons:
10+
apt:
11+
packages:
12+
- clang-format-3.8
13+
install:
14+
script: |
15+
# Apparently update-alternatives doesn't work in Travis containers
16+
mkdir -p priority-symlinks
17+
ln -s /usr/bin/clang-format-3.8 priority-symlinks/clang-format
18+
export PATH=${PWD}/priority-symlinks:${PATH}
19+
20+
# Now we can do the formatting pass
21+
clang-format --version
22+
git-clang-format-3.8 "${TRAVIS_BRANCH}"
23+
git diff --color > formatted.diff
24+
if [[ -s formatted.diff ]] ; then
25+
echo 'Formatting error! Apply the following diff and resubmit:'
26+
cat formatted.diff
27+
exit 1
28+
fi
29+
echo 'No formatting errors found'
30+
exit 0
31+
before_cache:
32+
633
- &linter-stage
734
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
835
env: NAME="CPP-LINT"
@@ -165,6 +192,7 @@ jobs:
165192
script: echo "This is coverity build. No need for tests."
166193

167194
allow_failures:
195+
- <<: *formatting-stage
168196
- <<: *linter-stage
169197

170198
install:

CODING_STANDARD.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Here a few minimalistic coding rules for the CPROVER source tree.
22

33
# Whitespaces
4+
5+
Formatting is enforced using clang-format. For more information about this, see
6+
`COMPILING.md`. A brief summary of the formatting rules is given below:
7+
48
- Use 2 spaces indent, no tabs.
59
- No lines wider than 80 chars.
610
- When line is wider, do the following:
@@ -16,8 +20,7 @@ Here a few minimalistic coding rules for the CPROVER source tree.
1620
even if the outer function call does.
1721
- If a method is bigger than 50 lines, break it into parts.
1822
- Put matching `{ }` into the same column.
19-
- No spaces around operators (`=`, `+`, `==` ...) Exceptions: Spaces around
20-
`&&`, `||` and `<<`
23+
- Spaces around binary operators (`=`, `+`, `==` ...)
2124
- Space after comma (parameter lists, argument lists, ...)
2225
- Space after colon inside `for`
2326
- For pointers and references, the `*`/`&` should be attached to the variable
@@ -27,10 +30,10 @@ Here a few minimalistic coding rules for the CPROVER source tree.
2730
- No whitespaces in blank lines
2831
- Put argument lists on next line (and indent 2 spaces) if too long
2932
- Put parameters on separate lines (and indent 2 spaces) if too long
30-
- No whitespaces around colon for inheritance, put inherited into separate
31-
lines in case of multiple inheritance
32-
- The initializer list follows the constructor without a whitespace around the
33-
colon. Break line after the colon if required and indent members.
33+
- Spaces around colon for inheritance, put inherited into separate lines in
34+
case of multiple inheritance
35+
- The initializer list follows the constructor with a whitespace around the
36+
colon.
3437
- `if(...)`, `else`, `for(...)`, `do`, and `while(...)` are always in a
3538
separate line
3639
- Break expressions in `if`, `for`, `while` if necessary and align them with

0 commit comments

Comments
 (0)