forked from MarcelRaschke/tor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.clang-format
163 lines (144 loc) · 3.83 KB
/
.clang-format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# DO NOT COMMIT OR MERGE CODE THAT IS RUN THROUGH THIS TOOL YET.
#
# WE ARE STILL DISCUSSING OUR DESIRED STYLE AND ITERATING ON IT.
# (12 Feb 2020)
---
Language: Cpp
# Out of all supported styles, LLVM seems closest to our own.
BasedOnStyle: LLVM
################
#
# Deviations from LLVM's style.
#
################
# We prefer an indentation width of 4 columns; LLVM likes 2.
## OVERRIDE FOR COMPARISON
IndentWidth: 2
## OVERRIDE FOR COMPARISON
## for now i'm not sorting includes, since that makes every file get touched.
SortIncludes: false
# We prefer 79; llvm likes 80.
ColumnLimit: 79
# Where do we want to put backslashes on multiline macros? Our choices are
# "as far left as possible", "as far right as possible", and "make no changes."
# LLVM defaults to right, but we don't dig that.
AlignEscapedNewlines: Left
# When we see a bunch of things in a row with comments after them, should we
# try to align those comments? Doing so makes some of our code pretty ugly.
AlignTrailingComments: false
# We use a function declaration style much closer to BSD KNF than to LLVM's.
# We say:
# int foo(int x);
# int
# foo(int x)
# {
# ...
# }
# whereas llvm prefers:
# int foo(int x);
# int foo(int x) {
# ...
# }
# or even:
# int foo(int x) { ... }
#
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
AllowShortFunctionsOnASingleLine: None
AlwaysBreakAfterReturnType: AllDefinitions
# We don't like blocks to start with an empty line.
#
KeepEmptyLinesAtTheStartOfBlocks: false
################
#
# Tor-specific magic
#
################
#
# These comments are magical, and should not be changed.
#
CommentPragmas: 'LCOV_EXCL|COVERITY'
#
# Remove duplicate empty lines.
#
MaxEmptyLinesToKeep: 1
#
# Indent preprocessor directives, for clarity.
#
IndentPPDirectives: AfterHash
#
# These introduce an iteration, and work a bit like a for loop.
#
# Note that we can NOT include ones that don't work like "for". For example,
# if the body is an argument to the macro, we can't list it here.
#
ForEachMacros:
- MAP_FOREACH
- MAP_FOREACH_MODIFY
- TOR_SIMPLEQ_FOREACH
- TOR_SIMPLEQ_FOREACH_SAFE
- TOR_SLIST_FOREACH
- TOR_SLIST_FOREACH_SAFE
- TOR_LIST_FOREACH
- TOR_LIST_FOREACH_SAFE
- TOR_TAILQ_FOREACH
- TOR_TAILQ_FOREACH_SAFE
- TOR_TAILQ_FOREACH_REVERSE
- TOR_TAILQ_FOREACH_REVERSE_SAFE
- TOR_CIRCLEQ_FOREACH
- TOR_CIRCLEQ_FOREACH_SAFE
- TOR_CIRCLEQ_FOREACH_REVERSE
- TOR_CIRCLEQ_FOREACH_REVERSE_SAFE
- HT_FOREACH
- SMARTLIST_FOREACH_BEGIN
- DIGESTMAP_FOREACH
- DIGESTMAP_FOREACH_MODIFY
- DIGEST256MAP_FOREACH
- DIGEST256MAP_FOREACH_MODIFY
- SDMAP_FOREACH
- RIMAP_FOREACH
- EIMAP_FOREACH
#
# Omitting:
#
# - SMARTLIST_FOREACH, since the body of the loop is an argument.
#
# This explains how to sort our headers.
#
# This is more complex than it truly should be, but I've edited this till
# compilation still mostly passes.
#
# I'm disabling this, however, since it's a distraction from the other
# formatting issues. See SortIncludes above.
#
IncludeCategories:
- Regex: '^"orconfig.h'
Priority: -30
- Regex: '^"ext/'
Priority: -18
- Regex: '^"lib/'
Priority: -10
- Regex: '^"core/or/or.h'
Priority: -5
- Regex: '^"core/'
Priority: 5
- Regex: '^"feature/'
Priority: 10
- Regex: '^"app/'
Priority: 20
#
# These macros should always cause indentation, as though they were { and }.
#
# Do NOT put macros here unless you want an extra level of indentation between
# them whenever they appear.
#
MacroBlockBegin: "^STMT_BEGIN|TT_STMT_BEGIN$"
MacroBlockEnd: "^STMT_END|TT_STMT_END$"
#
# These macros are interpreted as types.
# (Not supported in my clang-format)
#
# TypenameMacros:
# - "STACK_OF"
...