Skip to content

Commit 2c76deb

Browse files
mergennachinmalfet
authored andcommitted
Enable CLANG-FORMAT (pytorch#224)
1 parent f69429f commit 2c76deb

File tree

5 files changed

+1014
-600
lines changed

5 files changed

+1014
-600
lines changed

.clang-format

+244
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -1
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionPointers: false
12+
PadOperators: true
13+
AlignConsecutiveBitFields:
14+
Enabled: false
15+
AcrossEmptyLines: false
16+
AcrossComments: false
17+
AlignCompound: false
18+
AlignFunctionPointers: false
19+
PadOperators: true
20+
AlignConsecutiveDeclarations:
21+
Enabled: false
22+
AcrossEmptyLines: false
23+
AcrossComments: false
24+
AlignCompound: false
25+
AlignFunctionPointers: false
26+
PadOperators: true
27+
AlignConsecutiveMacros:
28+
Enabled: false
29+
AcrossEmptyLines: false
30+
AcrossComments: false
31+
AlignCompound: false
32+
AlignFunctionPointers: false
33+
PadOperators: true
34+
AlignConsecutiveShortCaseStatements:
35+
Enabled: false
36+
AcrossEmptyLines: false
37+
AcrossComments: false
38+
AlignCaseColons: false
39+
AlignEscapedNewlines: Left
40+
AlignOperands: DontAlign
41+
AlignTrailingComments:
42+
Kind: Never
43+
OverEmptyLines: 0
44+
AllowAllArgumentsOnNextLine: true
45+
AllowAllParametersOfDeclarationOnNextLine: false
46+
AllowBreakBeforeNoexceptSpecifier: Never
47+
AllowShortBlocksOnASingleLine: Never
48+
AllowShortCaseLabelsOnASingleLine: false
49+
AllowShortCompoundRequirementOnASingleLine: true
50+
AllowShortEnumsOnASingleLine: true
51+
AllowShortFunctionsOnASingleLine: Empty
52+
AllowShortIfStatementsOnASingleLine: Never
53+
AllowShortLambdasOnASingleLine: All
54+
AllowShortLoopsOnASingleLine: false
55+
AlwaysBreakAfterDefinitionReturnType: None
56+
AlwaysBreakAfterReturnType: None
57+
AlwaysBreakBeforeMultilineStrings: true
58+
AlwaysBreakTemplateDeclarations: Yes
59+
AttributeMacros:
60+
- __capability
61+
BinPackArguments: false
62+
BinPackParameters: false
63+
BitFieldColonSpacing: Both
64+
BraceWrapping:
65+
AfterCaseLabel: false
66+
AfterClass: false
67+
AfterControlStatement: Never
68+
AfterEnum: false
69+
AfterExternBlock: false
70+
AfterFunction: false
71+
AfterNamespace: false
72+
AfterObjCDeclaration: false
73+
AfterStruct: false
74+
AfterUnion: false
75+
BeforeCatch: false
76+
BeforeElse: false
77+
BeforeLambdaBody: false
78+
BeforeWhile: false
79+
IndentBraces: false
80+
SplitEmptyFunction: true
81+
SplitEmptyRecord: true
82+
SplitEmptyNamespace: true
83+
BreakAdjacentStringLiterals: true
84+
BreakAfterAttributes: Leave
85+
BreakAfterJavaFieldAnnotations: false
86+
BreakArrays: true
87+
BreakBeforeBinaryOperators: None
88+
BreakBeforeConceptDeclarations: Always
89+
BreakBeforeBraces: Attach
90+
BreakBeforeInlineASMColon: OnlyMultiline
91+
BreakBeforeTernaryOperators: true
92+
BreakConstructorInitializers: BeforeColon
93+
BreakInheritanceList: BeforeColon
94+
BreakStringLiterals: false
95+
ColumnLimit: 80
96+
CommentPragmas: '^ IWYU pragma:'
97+
CompactNamespaces: false
98+
ConstructorInitializerIndentWidth: 4
99+
ContinuationIndentWidth: 4
100+
Cpp11BracedListStyle: true
101+
DerivePointerAlignment: false
102+
DisableFormat: false
103+
EmptyLineAfterAccessModifier: Never
104+
EmptyLineBeforeAccessModifier: LogicalBlock
105+
ExperimentalAutoDetectBinPacking: false
106+
FixNamespaceComments: true
107+
ForEachMacros:
108+
- FOR_EACH
109+
- FOR_EACH_R
110+
- FOR_EACH_RANGE
111+
IfMacros:
112+
- KJ_IF_MAYBE
113+
IncludeBlocks: Preserve
114+
IncludeCategories:
115+
- Regex: '^<.*\.h(pp)?>'
116+
Priority: 1
117+
SortPriority: 0
118+
CaseSensitive: false
119+
- Regex: '^<.*'
120+
Priority: 2
121+
SortPriority: 0
122+
CaseSensitive: false
123+
- Regex: '.*'
124+
Priority: 3
125+
SortPriority: 0
126+
CaseSensitive: false
127+
IncludeIsMainRegex: '(Test)?$'
128+
IncludeIsMainSourceRegex: ''
129+
IndentAccessModifiers: false
130+
IndentCaseBlocks: false
131+
IndentCaseLabels: true
132+
IndentExternBlock: AfterExternBlock
133+
IndentGotoLabels: true
134+
IndentPPDirectives: None
135+
IndentRequiresClause: true
136+
IndentWidth: 2
137+
IndentWrappedFunctionNames: false
138+
InsertBraces: false
139+
InsertNewlineAtEOF: false
140+
InsertTrailingCommas: None
141+
IntegerLiteralSeparator:
142+
Binary: 0
143+
BinaryMinDigits: 0
144+
Decimal: 0
145+
DecimalMinDigits: 0
146+
Hex: 0
147+
HexMinDigits: 0
148+
JavaScriptQuotes: Leave
149+
JavaScriptWrapImports: true
150+
KeepEmptyLinesAtTheStartOfBlocks: false
151+
KeepEmptyLinesAtEOF: false
152+
LambdaBodyIndentation: Signature
153+
LineEnding: DeriveLF
154+
MacroBlockBegin: ''
155+
MacroBlockEnd: ''
156+
MaxEmptyLinesToKeep: 1
157+
NamespaceIndentation: None
158+
ObjCBinPackProtocolList: Auto
159+
ObjCBlockIndentWidth: 2
160+
ObjCBreakBeforeNestedBlockParam: true
161+
ObjCSpaceAfterProperty: false
162+
ObjCSpaceBeforeProtocolList: false
163+
PackConstructorInitializers: NextLine
164+
PenaltyBreakAssignment: 2
165+
PenaltyBreakBeforeFirstCallParameter: 1
166+
PenaltyBreakComment: 300
167+
PenaltyBreakFirstLessLess: 120
168+
PenaltyBreakOpenParenthesis: 0
169+
PenaltyBreakScopeResolution: 500
170+
PenaltyBreakString: 1000
171+
PenaltyBreakTemplateDeclaration: 10
172+
PenaltyExcessCharacter: 1000000
173+
PenaltyIndentedWhitespace: 0
174+
PenaltyReturnTypeOnItsOwnLine: 200
175+
PointerAlignment: Left
176+
PPIndentWidth: -1
177+
QualifierAlignment: Leave
178+
ReferenceAlignment: Pointer
179+
ReflowComments: true
180+
RemoveBracesLLVM: false
181+
RemoveParentheses: Leave
182+
RemoveSemicolon: false
183+
RequiresClausePosition: OwnLine
184+
RequiresExpressionIndentation: OuterScope
185+
SeparateDefinitionBlocks: Leave
186+
ShortNamespaceLines: 1
187+
SkipMacroDefinitionBody: false
188+
SortIncludes: CaseSensitive
189+
SortJavaStaticImport: Before
190+
SortUsingDeclarations: LexicographicNumeric
191+
SpaceAfterCStyleCast: false
192+
SpaceAfterLogicalNot: false
193+
SpaceAfterTemplateKeyword: true
194+
SpaceAroundPointerQualifiers: Default
195+
SpaceBeforeAssignmentOperators: true
196+
SpaceBeforeCaseColon: false
197+
SpaceBeforeCpp11BracedList: false
198+
SpaceBeforeCtorInitializerColon: true
199+
SpaceBeforeInheritanceColon: true
200+
SpaceBeforeJsonColon: false
201+
SpaceBeforeParens: ControlStatements
202+
SpaceBeforeParensOptions:
203+
AfterControlStatements: true
204+
AfterForeachMacros: true
205+
AfterFunctionDefinitionName: false
206+
AfterFunctionDeclarationName: false
207+
AfterIfMacros: true
208+
AfterOverloadedOperator: false
209+
AfterPlacementOperator: true
210+
AfterRequiresInClause: false
211+
AfterRequiresInExpression: false
212+
BeforeNonEmptyParentheses: false
213+
SpaceBeforeRangeBasedForLoopColon: true
214+
SpaceBeforeSquareBrackets: false
215+
SpaceInEmptyBlock: false
216+
SpacesBeforeTrailingComments: 1
217+
SpacesInAngles: Never
218+
SpacesInContainerLiterals: true
219+
SpacesInLineCommentPrefix:
220+
Minimum: 1
221+
Maximum: -1
222+
SpacesInParens: Never
223+
SpacesInParensOptions:
224+
InCStyleCasts: false
225+
InConditionalStatements: false
226+
InEmptyParentheses: false
227+
Other: false
228+
SpacesInSquareBrackets: false
229+
Standard: Latest
230+
StatementAttributeLikeMacros:
231+
- Q_EMIT
232+
StatementMacros:
233+
- Q_UNUSED
234+
- QT_REQUIRE_VERSION
235+
TabWidth: 8
236+
UseTab: Never
237+
VerilogBreakBetweenInstancePorts: true
238+
WhitespaceSensitiveMacros:
239+
- BOOST_PP_STRINGIZE
240+
- CF_SWIFT_NAME
241+
- NS_SWIFT_NAME
242+
- PP_STRINGIZE
243+
- STRINGIZE
244+
...

.lintrunner.toml

+30-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,33 @@ init_command = [
4848
'--no-black-binary',
4949
'--requirement=requirements-lintrunner.txt',
5050
]
51-
is_formatter = true
51+
is_formatter = true
52+
53+
#CLANGFORMAT
54+
[[linter]]
55+
code = 'CLANGFORMAT'
56+
include_patterns = [
57+
'**/*.h',
58+
'**/*.cpp',
59+
]
60+
command = [
61+
'python',
62+
'-m',
63+
'lintrunner_adapters',
64+
'run',
65+
'clangformat_linter',
66+
'--binary=clang-format',
67+
'--fallback',
68+
'--',
69+
'@{{PATHSFILE}}'
70+
]
71+
init_command = [
72+
'python',
73+
'-m',
74+
'lintrunner_adapters',
75+
'run',
76+
'pip_init',
77+
'--dry-run={{DRYRUN}}',
78+
'--requirement=requirements-lintrunner.txt',
79+
]
80+
is_formatter = true

requirements-lintrunner.txt

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ torchfix==0.1.1
1616
black==24.2.0
1717
ufmt==2.5.1
1818
usort==1.0.5
19+
20+
# Clang
21+
clang-format==18.1.3

0 commit comments

Comments
 (0)