Skip to content

Commit db42c2b

Browse files
committed
First draft of .clang-format
1 parent 3cec2f9 commit db42c2b

2 files changed

Lines changed: 324 additions & 2 deletions

File tree

.clang-format

Lines changed: 322 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,327 @@
11
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
22

33
BasedOnStyle: LLVM
4+
Language: Cpp
5+
46
IndentWidth: 8
57
TabWidth: 8
6-
ColumnLimit: 100
8+
#ColumnLimit: 120
9+
ColumnLimit: 132
10+
ConstructorInitializerIndentWidth: 8
11+
ContinuationIndentWidth: 8
12+
#UseTab: ForContinuationAndIndentation
13+
UseTab: AlignWithSpaces
14+
UseCRLF: false
15+
16+
#AccessModifierOffset:
17+
AlignAfterOpenBracket: Align
18+
#AlignArrayOfStructures: None
19+
AlignConsecutiveAssignments: None
20+
AlignConsecutiveBitFields: None
21+
AlignConsecutiveDeclarations: None
22+
#AlignConsecutiveMacros: Consecutive
23+
AlignConsecutiveMacros: AcrossComments
24+
AlignEscapedNewlines: DontAlign
25+
AlignOperands: Align
26+
#AlignTrailingComments: true
27+
AlignTrailingComments: false
28+
29+
AllowAllArgumentsOnNextLine: false
30+
#AllowAllConstructorInitializersOnNextLine: false
31+
AllowAllParametersOfDeclarationOnNextLine: false
32+
AllowShortBlocksOnASingleLine: Never
33+
AllowShortCaseLabelsOnASingleLine: false
34+
AllowShortEnumsOnASingleLine: false
35+
AllowShortFunctionsOnASingleLine: None
36+
AllowShortIfStatementsOnASingleLine: Never
37+
AllowShortLambdasOnASingleLine: None
38+
AllowShortLoopsOnASingleLine: false
39+
40+
#AlwaysBreakAfterDefinitionReturnType
41+
AlwaysBreakAfterReturnType: None
42+
AlwaysBreakBeforeMultilineStrings: false
43+
AlwaysBreakTemplateDeclarations: No
44+
45+
#AttributeMacros:
46+
# - DUK_EXTERNAL_DECL
47+
# - DUK_EXTERNAL
48+
# - DUK_INTERNAL_DECL
49+
# - DUK_INTERNAL
50+
# - DUK_LOCAL_DECL
51+
# - DUK_LOCAL
52+
# - DUK_NORETURN
53+
54+
BinPackArguments: false
55+
BinPackParameters: false
56+
BitFieldColonSpacing: After
57+
58+
#BreakBeforeBraces: Custom
59+
#BraceWrapping: {}
60+
61+
#BreakAfterJavaFieldAnnotations
62+
BreakBeforeBinaryOperators: None
63+
BreakBeforeBraces: Attach
64+
#BreakBeforeConceptDeclarations
65+
BreakBeforeTernaryOperators: false
66+
BreakConstructorInitializers: AfterColon
67+
#BreakInheritanceList: AfterComma
68+
BreakStringLiterals: true
69+
70+
#CommentPragmas
71+
CompactNamespaces: false
72+
#ConstructorInitializerAllOnOneLineOrOnePerLine
73+
Cpp11BracedListStyle: false
74+
DeriveLineEnding: false
75+
DerivePointerAlignment: false
76+
#DisableFormat
77+
#EmptyLineAfterAccessModifier: Never
78+
EmptyLineBeforeAccessModifier: Never
79+
#ExperimentalAutoDetectBinPacking
80+
FixNamespaceComments: false
81+
#ForEachMacros: []
82+
#IfMacros: []
83+
IncludeBlocks: Preserve
84+
#IncludeCategories
85+
#IncludeIsMainRegex
86+
#IncludeIsMainSourceRegex
87+
#IndentAccessModifiers: false
88+
IndentCaseBlocks: false
89+
IndentCaseLabels: false
90+
IndentExternBlock: NoIndent
91+
IndentGotoLabels: true
92+
IndentPPDirectives: None
93+
#IndentRequires
94+
IndentWrappedFunctionNames: false
95+
InsertTrailingCommas: None
96+
#JavaImportGroups: []
97+
#JavaScriptQuotes: Single
98+
#JavaScriptWrapImports: true
99+
KeepEmptyLinesAtTheStartOfBlocks: false
100+
#LambdaBodyIndentation
101+
#MacroBlockBegin
102+
#MacroBlockEnd
103+
MaxEmptyLinesToKeep: 1
104+
#NamespaceIndentation: None
105+
#NamespaceMacros
106+
#ObjCBinPackProtocolList
107+
#ObjCBlockIndentWidth
108+
#ObjCBreakBeforeNestedBlockParam
109+
#ObjCSpaceAfterProperty
110+
#ObjCSpaceBeforeProtocolList
111+
#PPIndentWidth: 0
112+
#PackConstructorInitializers: CurrentLine
113+
114+
#PenaltyBreakAssignment
115+
#PenaltyBreakBeforeFirstCallParameter
116+
#PenaltyBreakComment
117+
#PenaltyBreakFirstLessLess
118+
#PenaltyBreakString
119+
#PenaltyBreakTemplateDeclaration
120+
#PenaltyExcessCharacter
121+
#PenaltyIndentedWhitespace
122+
PenaltyReturnTypeOnItsOwnLine: 1000
123+
124+
PointerAlignment: Right
125+
#RawStringFormats
126+
#ReferenceAlignment: Right
127+
ReflowComments: true
128+
#ReflowComments: false
129+
#ShortNamespaceLines
130+
SortIncludes: false
131+
#SortJavaStaticImport
132+
#SortUsingDeclarations
133+
SpaceAfterCStyleCast: true
134+
SpaceAfterLogicalNot: false
135+
#SpaceAfterTemplateKeyword
136+
SpaceAroundPointerQualifiers: Before
137+
SpaceBeforeAssignmentOperators: true
138+
SpaceBeforeCaseColon: false
139+
#SpaceBeforeCpp11BracedList: true
140+
#SpaceBeforeCtorInitializerColon: false
141+
#SpaceBeforeInheritanceColon: false
142+
SpaceBeforeParens: ControlStatements
143+
#SpaceBeforeRangeBasedForLoopColon
144+
SpaceBeforeSquareBrackets: false
145+
SpaceInEmptyBlock: false
146+
SpaceInEmptyParentheses: false
147+
SpacesBeforeTrailingComments: 1
148+
#SpacesInAngles
149+
SpacesInCStyleCastParentheses: false
150+
SpacesInConditionalStatement: false
151+
SpacesInContainerLiterals: true
152+
#SpacesInLineCommentPrefix
153+
SpacesInParentheses: false
154+
SpacesInSquareBrackets: false
155+
#Standard
156+
#StatementAttributeLikeMacros
157+
#StatementMacros
158+
#TypenameMacros
159+
#WhitespaceSensitiveMacros
160+
161+
# LLVM defaults for clang-format-12
162+
# $ clang-format-12 -style=llvm -dump-config
163+
# ---
164+
# Language: Cpp
165+
# # BasedOnStyle: LLVM
166+
# AccessModifierOffset: -2
167+
# AlignAfterOpenBracket: Align
168+
# AlignConsecutiveMacros: None
169+
# AlignConsecutiveAssignments: None
170+
# AlignConsecutiveBitFields: None
171+
# AlignConsecutiveDeclarations: None
172+
# AlignEscapedNewlines: Right
173+
# AlignOperands: Align
174+
# AlignTrailingComments: true
175+
# AllowAllArgumentsOnNextLine: true
176+
# AllowAllConstructorInitializersOnNextLine: true
177+
# AllowAllParametersOfDeclarationOnNextLine: true
178+
# AllowShortEnumsOnASingleLine: true
179+
# AllowShortBlocksOnASingleLine: Never
180+
# AllowShortCaseLabelsOnASingleLine: false
181+
# AllowShortFunctionsOnASingleLine: All
182+
# AllowShortLambdasOnASingleLine: All
183+
# AllowShortIfStatementsOnASingleLine: Never
184+
# AllowShortLoopsOnASingleLine: false
185+
# AlwaysBreakAfterDefinitionReturnType: None
186+
# AlwaysBreakAfterReturnType: None
187+
# AlwaysBreakBeforeMultilineStrings: false
188+
# AlwaysBreakTemplateDeclarations: MultiLine
189+
# AttributeMacros:
190+
# - __capability
191+
# BinPackArguments: true
192+
# BinPackParameters: true
193+
# BraceWrapping:
194+
# AfterCaseLabel: false
195+
# AfterClass: false
196+
# AfterControlStatement: Never
197+
# AfterEnum: false
198+
# AfterFunction: false
199+
# AfterNamespace: false
200+
# AfterObjCDeclaration: false
201+
# AfterStruct: false
202+
# AfterUnion: false
203+
# AfterExternBlock: false
204+
# BeforeCatch: false
205+
# BeforeElse: false
206+
# BeforeLambdaBody: false
207+
# BeforeWhile: false
208+
# IndentBraces: false
209+
# SplitEmptyFunction: true
210+
# SplitEmptyRecord: true
211+
# SplitEmptyNamespace: true
212+
# BreakBeforeBinaryOperators: None
213+
# BreakBeforeConceptDeclarations: true
214+
# BreakBeforeBraces: Attach
215+
# BreakBeforeInheritanceComma: false
216+
# BreakInheritanceList: BeforeColon
217+
# BreakBeforeTernaryOperators: true
218+
# BreakConstructorInitializersBeforeComma: false
219+
# BreakConstructorInitializers: BeforeColon
220+
# BreakAfterJavaFieldAnnotations: false
221+
# BreakStringLiterals: true
222+
# ColumnLimit: 80
223+
# CommentPragmas: '^ IWYU pragma:'
224+
# CompactNamespaces: false
225+
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
226+
# ConstructorInitializerIndentWidth: 4
227+
# ContinuationIndentWidth: 4
228+
# Cpp11BracedListStyle: true
229+
# DeriveLineEnding: true
230+
# DerivePointerAlignment: false
231+
# DisableFormat: false
232+
# EmptyLineBeforeAccessModifier: LogicalBlock
233+
# ExperimentalAutoDetectBinPacking: false
234+
# FixNamespaceComments: true
235+
# ForEachMacros:
236+
# - foreach
237+
# - Q_FOREACH
238+
# - BOOST_FOREACH
239+
# StatementAttributeLikeMacros:
240+
# - Q_EMIT
241+
# IncludeBlocks: Preserve
242+
# IncludeCategories:
243+
# - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
244+
# Priority: 2
245+
# SortPriority: 0
246+
# CaseSensitive: false
247+
# - Regex: '^(<|"(gtest|gmock|isl|json)/)'
248+
# Priority: 3
249+
# SortPriority: 0
250+
# CaseSensitive: false
251+
# - Regex: '.*'
252+
# Priority: 1
253+
# SortPriority: 0
254+
# CaseSensitive: false
255+
# IncludeIsMainRegex: '(Test)?$'
256+
# IncludeIsMainSourceRegex: ''
257+
# IndentCaseLabels: false
258+
# IndentCaseBlocks: false
259+
# IndentGotoLabels: true
260+
# IndentPPDirectives: None
261+
# IndentExternBlock: AfterExternBlock
262+
# IndentRequires: false
263+
# IndentWidth: 2
264+
# IndentWrappedFunctionNames: false
265+
# InsertTrailingCommas: None
266+
# JavaScriptQuotes: Leave
267+
# JavaScriptWrapImports: true
268+
# KeepEmptyLinesAtTheStartOfBlocks: true
269+
# MacroBlockBegin: ''
270+
# MacroBlockEnd: ''
271+
# MaxEmptyLinesToKeep: 1
272+
# NamespaceIndentation: None
273+
# ObjCBinPackProtocolList: Auto
274+
# ObjCBlockIndentWidth: 2
275+
# ObjCBreakBeforeNestedBlockParam: true
276+
# ObjCSpaceAfterProperty: false
277+
# ObjCSpaceBeforeProtocolList: true
278+
# PenaltyBreakAssignment: 2
279+
# PenaltyBreakBeforeFirstCallParameter: 19
280+
# PenaltyBreakComment: 300
281+
# PenaltyBreakFirstLessLess: 120
282+
# PenaltyBreakString: 1000
283+
# PenaltyBreakTemplateDeclaration: 10
284+
# PenaltyExcessCharacter: 1000000
285+
# PenaltyReturnTypeOnItsOwnLine: 60
286+
# PenaltyIndentedWhitespace: 0
287+
# PointerAlignment: Right
288+
# ReflowComments: true
289+
# SortIncludes: true
290+
# SortJavaStaticImport: Before
291+
# SortUsingDeclarations: true
292+
# SpaceAfterCStyleCast: false
293+
# SpaceAfterLogicalNot: false
294+
# SpaceAfterTemplateKeyword: true
295+
# SpaceBeforeAssignmentOperators: true
296+
# SpaceBeforeCaseColon: false
297+
# SpaceBeforeCpp11BracedList: false
298+
# SpaceBeforeCtorInitializerColon: true
299+
# SpaceBeforeInheritanceColon: true
300+
# SpaceBeforeParens: ControlStatements
301+
# SpaceAroundPointerQualifiers: Default
302+
# SpaceBeforeRangeBasedForLoopColon: true
303+
# SpaceInEmptyBlock: false
304+
# SpaceInEmptyParentheses: false
305+
# SpacesBeforeTrailingComments: 1
306+
# SpacesInAngles: false
307+
# SpacesInConditionalStatement: false
308+
# SpacesInContainerLiterals: true
309+
# SpacesInCStyleCastParentheses: false
310+
# SpacesInParentheses: false
311+
# SpacesInSquareBrackets: false
312+
# SpaceBeforeSquareBrackets: false
313+
# BitFieldColonSpacing: Both
314+
# Standard: Latest
315+
# StatementMacros:
316+
# - Q_UNUSED
317+
# - QT_REQUIRE_VERSION
318+
# TabWidth: 8
319+
# UseCRLF: false
320+
# UseTab: Never
321+
# WhitespaceSensitiveMacros:
322+
# - STRINGIZE
323+
# - PP_STRINGIZE
324+
# - BOOST_PP_STRINGIZE
325+
# - NS_SWIFT_NAME
326+
# - CF_SWIFT_NAME
327+
# ...

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,8 @@ codepolicycheckvim:
12161216
.PHONY: clang-format-source
12171217
clang-format-source: | tmp
12181218
-rm -f tmp/docker-clang-format-input.zip tmp/docker-clang-format-output.zip
1219-
zip -1 -q -r tmp/docker-clang-format-input.zip .clang-format src-input
1219+
@# Omit duktape.h.in for now, clang-format has some issues with e.g. 'extern "C"' in the file.
1220+
zip -1 -q -r tmp/docker-clang-format-input.zip .clang-format src-input/*.c src-input/*.h
12201221
$(DOCKER) run --rm -i duktape-clang-format < tmp/docker-clang-format-input.zip > tmp/docker-clang-format-output.zip
12211222
unzip -q -o tmp/docker-clang-format-output.zip ; true # avoid failure due to leading garbage
12221223

0 commit comments

Comments
 (0)