Skip to content

Commit 48c4fc0

Browse files
serprextheory
andcommitted
replace pg_bsd_indent with clang-format
Co-authored-by: David E. Wheeler <david.wheeler@clickhouse.com>
1 parent 22d3c5d commit 48c4fc0

31 files changed

Lines changed: 16394 additions & 15614 deletions

.clang-format

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
---
2+
Language: Cpp
3+
AlignAfterOpenBracket: true
4+
AccessModifierOffset: -2
5+
AlignArrayOfStructures: Left
6+
AlignConsecutiveAssignments:
7+
Enabled: true
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionDeclarations: false
12+
AlignFunctionPointers: false
13+
PadOperators: true
14+
AlignConsecutiveBitFields:
15+
Enabled: false
16+
AcrossEmptyLines: false
17+
AcrossComments: false
18+
AlignCompound: false
19+
AlignFunctionDeclarations: false
20+
AlignFunctionPointers: false
21+
PadOperators: false
22+
AlignConsecutiveDeclarations:
23+
Enabled: false
24+
AcrossEmptyLines: false
25+
AcrossComments: false
26+
AlignCompound: false
27+
AlignFunctionDeclarations: true
28+
AlignFunctionPointers: false
29+
PadOperators: false
30+
AlignConsecutiveMacros:
31+
Enabled: false
32+
AcrossEmptyLines: false
33+
AcrossComments: false
34+
AlignCompound: false
35+
AlignFunctionDeclarations: false
36+
AlignFunctionPointers: false
37+
PadOperators: false
38+
AlignConsecutiveShortCaseStatements:
39+
Enabled: false
40+
AcrossEmptyLines: false
41+
AcrossComments: false
42+
AlignCaseArrows: false
43+
AlignCaseColons: false
44+
AlignConsecutiveTableGenBreakingDAGArgColons:
45+
Enabled: false
46+
AcrossEmptyLines: false
47+
AcrossComments: false
48+
AlignCompound: false
49+
AlignFunctionDeclarations: false
50+
AlignFunctionPointers: false
51+
PadOperators: false
52+
AlignConsecutiveTableGenCondOperatorColons:
53+
Enabled: false
54+
AcrossEmptyLines: false
55+
AcrossComments: false
56+
AlignCompound: false
57+
AlignFunctionDeclarations: false
58+
AlignFunctionPointers: false
59+
PadOperators: false
60+
AlignConsecutiveTableGenDefinitionColons:
61+
Enabled: false
62+
AcrossEmptyLines: false
63+
AcrossComments: false
64+
AlignCompound: false
65+
AlignFunctionDeclarations: false
66+
AlignFunctionPointers: false
67+
PadOperators: false
68+
AlignEscapedNewlines: Right
69+
AlignOperands: Align
70+
AlignTrailingComments:
71+
AlignPPAndNotPP: true
72+
Kind: Always
73+
OverEmptyLines: 0
74+
AllowAllArgumentsOnNextLine: true
75+
AllowAllParametersOfDeclarationOnNextLine: false
76+
AllowBreakBeforeNoexceptSpecifier: Never
77+
AllowBreakBeforeQtProperty: false
78+
AllowShortBlocksOnASingleLine: Always
79+
AllowShortCaseExpressionOnASingleLine: true
80+
AllowShortCaseLabelsOnASingleLine: false
81+
AllowShortCompoundRequirementOnASingleLine: true
82+
AllowShortEnumsOnASingleLine: true
83+
AllowShortFunctionsOnASingleLine: Inline
84+
AllowShortIfStatementsOnASingleLine: Never
85+
AllowShortLambdasOnASingleLine: All
86+
AllowShortLoopsOnASingleLine: false
87+
AllowShortNamespacesOnASingleLine: false
88+
AlwaysBreakAfterDefinitionReturnType: TopLevel
89+
AlwaysBreakBeforeMultilineStrings: false
90+
AttributeMacros:
91+
- __capability
92+
BinPackArguments: false
93+
BinPackLongBracedList: true
94+
BinPackParameters: OnePerLine
95+
BitFieldColonSpacing: Both
96+
BracedInitializerIndentWidth: -1
97+
BraceWrapping:
98+
AfterCaseLabel: false
99+
AfterClass: false
100+
AfterControlStatement: Never
101+
AfterEnum: false
102+
AfterExternBlock: false
103+
AfterFunction: false
104+
AfterNamespace: false
105+
AfterObjCDeclaration: false
106+
AfterStruct: false
107+
AfterUnion: false
108+
BeforeCatch: false
109+
BeforeElse: false
110+
BeforeLambdaBody: false
111+
BeforeWhile: false
112+
IndentBraces: false
113+
SplitEmptyFunction: false
114+
SplitEmptyRecord: false
115+
SplitEmptyNamespace: true
116+
BreakAdjacentStringLiterals: true
117+
BreakAfterAttributes: Leave
118+
BreakAfterJavaFieldAnnotations: false
119+
BreakAfterOpenBracketBracedList: false
120+
BreakAfterOpenBracketFunction: true
121+
BreakAfterOpenBracketIf: true
122+
BreakAfterOpenBracketLoop: false
123+
BreakAfterOpenBracketSwitch: false
124+
BreakAfterReturnType: TopLevel
125+
BreakArrays: true
126+
BreakBeforeBinaryOperators: None
127+
BreakBeforeCloseBracketBracedList: true
128+
BreakBeforeCloseBracketFunction: true
129+
BreakBeforeCloseBracketIf: true
130+
BreakBeforeCloseBracketLoop: false
131+
BreakBeforeCloseBracketSwitch: false
132+
BreakBeforeConceptDeclarations: Always
133+
BreakBeforeBraces: Custom
134+
BreakBeforeInlineASMColon: OnlyMultiline
135+
BreakBeforeTemplateCloser: false
136+
BreakBeforeTernaryOperators: true
137+
BreakBinaryOperations: Never
138+
BreakConstructorInitializers: BeforeComma
139+
BreakFunctionDefinitionParameters: false
140+
BreakInheritanceList: BeforeComma
141+
BreakStringLiterals: true
142+
BreakTemplateDeclarations: Yes
143+
ColumnLimit: 88
144+
CommentPragmas: "^ IWYU pragma:"
145+
CompactNamespaces: false
146+
ConstructorInitializerIndentWidth: 4
147+
ContinuationIndentWidth: 4
148+
Cpp11BracedListStyle: Block
149+
DerivePointerAlignment: false
150+
DisableFormat: false
151+
EmptyLineAfterAccessModifier: Never
152+
EmptyLineBeforeAccessModifier: LogicalBlock
153+
EnumTrailingComma: Leave
154+
ExperimentalAutoDetectBinPacking: false
155+
FixNamespaceComments: false
156+
ForEachMacros:
157+
- foreach
158+
- Q_FOREACH
159+
- BOOST_FOREACH
160+
IfMacros:
161+
- KJ_IF_MAYBE
162+
IncludeBlocks: Preserve
163+
IncludeCategories:
164+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
165+
Priority: 2
166+
SortPriority: 0
167+
CaseSensitive: false
168+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
169+
Priority: 3
170+
SortPriority: 0
171+
CaseSensitive: false
172+
- Regex: ".*"
173+
Priority: 1
174+
SortPriority: 0
175+
CaseSensitive: false
176+
IncludeIsMainRegex: "(Test)?$"
177+
IncludeIsMainSourceRegex: ""
178+
IndentAccessModifiers: false
179+
IndentCaseBlocks: false
180+
IndentCaseLabels: false
181+
IndentExportBlock: true
182+
IndentExternBlock: AfterExternBlock
183+
IndentGotoLabels: true
184+
IndentPPDirectives: None
185+
IndentRequiresClause: true
186+
IndentWidth: 4
187+
IndentWrappedFunctionNames: false
188+
InsertBraces: true
189+
InsertNewlineAtEOF: true
190+
InsertTrailingCommas: None
191+
IntegerLiteralSeparator:
192+
Binary: 0
193+
BinaryMinDigitsInsert: 0
194+
BinaryMaxDigitsRemove: 0
195+
Decimal: 0
196+
DecimalMinDigitsInsert: 0
197+
DecimalMaxDigitsRemove: 0
198+
Hex: 0
199+
HexMinDigitsInsert: 0
200+
HexMaxDigitsRemove: 0
201+
BinaryMinDigits: 0
202+
DecimalMinDigits: 0
203+
HexMinDigits: 0
204+
JavaScriptQuotes: Leave
205+
JavaScriptWrapImports: true
206+
KeepEmptyLines:
207+
AtEndOfFile: false
208+
AtStartOfBlock: true
209+
AtStartOfFile: true
210+
KeepFormFeed: false
211+
LambdaBodyIndentation: Signature
212+
LineEnding: DeriveLF
213+
MacroBlockBegin: ""
214+
MacroBlockEnd: ""
215+
MainIncludeChar: Quote
216+
MaxEmptyLinesToKeep: 1
217+
NamespaceIndentation: None
218+
NumericLiteralCase:
219+
ExponentLetter: Leave
220+
HexDigit: Leave
221+
Prefix: Leave
222+
Suffix: Leave
223+
ObjCBinPackProtocolList: Auto
224+
ObjCBlockIndentWidth: 4
225+
ObjCBreakBeforeNestedBlockParam: true
226+
ObjCSpaceAfterProperty: true
227+
ObjCSpaceBeforeProtocolList: false
228+
OneLineFormatOffRegex: ""
229+
PackConstructorInitializers: BinPack
230+
PenaltyBreakAssignment: 2
231+
PenaltyBreakBeforeFirstCallParameter: 19
232+
PenaltyBreakBeforeMemberAccess: 150
233+
PenaltyBreakComment: 300
234+
PenaltyBreakFirstLessLess: 120
235+
PenaltyBreakOpenParenthesis: 0
236+
PenaltyBreakScopeResolution: 500
237+
PenaltyBreakString: 1000
238+
PenaltyBreakTemplateDeclaration: 10
239+
PenaltyExcessCharacter: 1000000
240+
PenaltyIndentedWhitespace: 0
241+
PenaltyReturnTypeOnItsOwnLine: 200
242+
PointerAlignment: Left
243+
PPIndentWidth: -1
244+
QualifierAlignment: Leave
245+
ReferenceAlignment: Pointer
246+
ReflowComments: Always
247+
RemoveBracesLLVM: false
248+
RemoveEmptyLinesInUnwrappedLines: false
249+
RemoveParentheses: Leave
250+
RemoveSemicolon: false
251+
RequiresClausePosition: OwnLine
252+
RequiresExpressionIndentation: OuterScope
253+
SeparateDefinitionBlocks: Leave
254+
ShortNamespaceLines: 1
255+
SkipMacroDefinitionBody: false
256+
SortIncludes:
257+
Enabled: true
258+
IgnoreCase: false
259+
IgnoreExtension: false
260+
SortJavaStaticImport: Before
261+
SortUsingDeclarations: LexicographicNumeric
262+
SpaceAfterCStyleCast: false
263+
SpaceAfterLogicalNot: false
264+
SpaceAfterOperatorKeyword: false
265+
SpaceAfterTemplateKeyword: false
266+
SpaceAroundPointerQualifiers: Default
267+
SpaceBeforeAssignmentOperators: true
268+
SpaceBeforeCaseColon: false
269+
SpaceBeforeCpp11BracedList: false
270+
SpaceBeforeCtorInitializerColon: true
271+
SpaceBeforeInheritanceColon: true
272+
SpaceBeforeJsonColon: false
273+
SpaceBeforeParens: ControlStatements
274+
SpaceBeforeParensOptions:
275+
AfterControlStatements: true
276+
AfterForeachMacros: true
277+
AfterFunctionDefinitionName: false
278+
AfterFunctionDeclarationName: false
279+
AfterIfMacros: true
280+
AfterNot: false
281+
AfterOverloadedOperator: false
282+
AfterPlacementOperator: true
283+
AfterRequiresInClause: false
284+
AfterRequiresInExpression: false
285+
BeforeNonEmptyParentheses: false
286+
SpaceBeforeRangeBasedForLoopColon: true
287+
SpaceBeforeSquareBrackets: false
288+
SpaceInEmptyBraces: Never
289+
SpacesBeforeTrailingComments: 1
290+
SpacesInAngles: Never
291+
SpacesInContainerLiterals: true
292+
SpacesInLineCommentPrefix:
293+
Minimum: 1
294+
Maximum: -1
295+
SpacesInParens: Never
296+
SpacesInParensOptions:
297+
ExceptDoubleParentheses: false
298+
InCStyleCasts: false
299+
InConditionalStatements: false
300+
InEmptyParentheses: false
301+
Other: false
302+
SpacesInSquareBrackets: false
303+
Standard: Latest
304+
StatementAttributeLikeMacros:
305+
- Q_EMIT
306+
StatementMacros:
307+
- Q_UNUSED
308+
- QT_REQUIRE_VERSION
309+
TableGenBreakInsideDAGArg: DontBreak
310+
TabWidth: 4
311+
UseTab: Never
312+
VerilogBreakBetweenInstancePorts: true
313+
WhitespaceSensitiveMacros:
314+
- BOOST_PP_STRINGIZE
315+
- CF_SWIFT_NAME
316+
- NS_SWIFT_NAME
317+
- PP_STRINGIZE
318+
- STRINGIZE
319+
WrapNamespaceBodyWithEmptyLines: Leave

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ repos:
2424
rev: v2.4.1
2525
hooks:
2626
- id: codespell
27-
- repo: local
27+
- repo: https://github.com/pre-commit/mirrors-clang-format
28+
rev: v22.1.5
2829
hooks:
29-
- id: indent
30-
name: indent code
31-
language: system
32-
entry: ./dev/indent.sh
33-
pass_filenames: false
30+
- id: clang-format
31+
name: format code
32+
types: [c]
3433
- repo: local
3534
hooks:
3635
- id: clang-tidy

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ All notable changes to this project will be documented in this file. It uses the
4444
argument is not a constant.
4545
* Fixed a memory leak in the http driver when not using streaming ([#281]).
4646

47+
### 🏗️ Build Setup
48+
49+
* Replaced code formatting, previously performed by `pg_bsd_indent`, with
50+
[clang-format] using a modified "Mozilla style" with an emphasis on
51+
legibility and safety ([#283]).
52+
4753
[#227]: https://github.com/ClickHouse/pg_clickhouse/pull/227
4854
"ClickHouse/pg_clickhouse#227 add three-state secure option for TLS control"
4955
[#268]: https://github.com/ClickHouse/pg_clickhouse/pull/268
@@ -52,6 +58,9 @@ All notable changes to this project will be documented in this file. It uses the
5258
"ClickHouse/pg_clickhouse#269 Add support for PostgreSQL 19beta1"
5359
[#218]: https://github.com/ClickHouse/pg_clickhouse/pull/218
5460
"ClickHouse/pg_clickhouse#218 Properly free Curl memory on palloc error"
61+
[clang-format]: https://clang.llvm.org/docs/ClangFormat.html
62+
[#283]: https://github.com/ClickHouse/pg_clickhouse/pull/283
63+
"ClickHouse/pg_clickhouse#283 clang-format"
5564

5665
## [v0.3.1] — 2026-05-02
5766

dev/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ development of pg_clickhouse.
66
* `bear.json`: [Bear Configuration](#bear-configuration)
77
* `bear.yml`: [Bear Configuration](#bear-configuration)
88
* `docker-compose.yml`: [ClickHouse Version Testing Containers](#clickhouse-version-testing-containers)
9-
* `indent.sh`: Run by `make indent`; requires [pg_bsd_indent]
109
* `Makefile`: Automates [ClickHouse Version Testing Containers](#clickhouse-version-testing-containers)
1110
* `README.md`: This file
1211
* `runch`: [Run ClickHouse Server](#run-clickhouse-server)
@@ -87,7 +86,6 @@ There are currently two files:
8786

8887
The `compile_commands.json` target determines which to use.
8988

90-
[pg_bsd_indent]: https://github.com/postgres/postgres/tree/master/src/tools/pg_bsd_indent
9189
[clickhousectl]: https://clickhouse.com/docs/interfaces/cli "ClickHouse Docs: clickhousectl"
9290
[pgxn-tools]: https://github.com/pgxn/docker-pgxn-tools/
9391
[Bear]: https://github.com/rizsotto/Bear "Bear generates a compilation database for Clang tooling"

0 commit comments

Comments
 (0)