Skip to content

Commit 7f455d4

Browse files
committed
Add clang formatter
1 parent 9ab52a5 commit 7f455d4

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

.clang-format

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: true
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: Right
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Inline
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: true
24+
AfterControlStatement: true
25+
AfterEnum: true
26+
AfterFunction: true
27+
AfterNamespace: false
28+
AfterObjCDeclaration: true
29+
AfterStruct: true
30+
AfterUnion: true
31+
AfterExternBlock: true
32+
BeforeCatch: true
33+
BeforeElse: true
34+
IndentBraces: false
35+
SplitEmptyFunction: false
36+
SplitEmptyRecord: false
37+
SplitEmptyNamespace: false
38+
BreakBeforeBinaryOperators: None
39+
BreakBeforeBraces: Custom
40+
BreakBeforeInheritanceComma: false
41+
BreakBeforeTernaryOperators: true
42+
BreakConstructorInitializersBeforeComma: false
43+
BreakConstructorInitializers: BeforeColon
44+
BreakAfterJavaFieldAnnotations: false
45+
BreakStringLiterals: true
46+
ColumnLimit: 80
47+
CommentPragmas: '^ IWYU pragma:'
48+
CompactNamespaces: false
49+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
50+
ConstructorInitializerIndentWidth: 4
51+
ContinuationIndentWidth: 4
52+
Cpp11BracedListStyle: true
53+
DerivePointerAlignment: false
54+
DisableFormat: false
55+
ExperimentalAutoDetectBinPacking: false
56+
FixNamespaceComments: true
57+
ForEachMacros:
58+
- foreach
59+
- Q_FOREACH
60+
- BOOST_FOREACH
61+
IncludeBlocks: Preserve
62+
IncludeCategories:
63+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
64+
Priority: 2
65+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
66+
Priority: 3
67+
- Regex: '.*'
68+
Priority: 1
69+
IncludeIsMainRegex: '(Test)?$'
70+
IndentCaseLabels: true
71+
IndentPPDirectives: None
72+
IndentWidth: 4
73+
IndentWrappedFunctionNames: false
74+
JavaScriptQuotes: Leave
75+
JavaScriptWrapImports: true
76+
KeepEmptyLinesAtTheStartOfBlocks: true
77+
MacroBlockBegin: ''
78+
MacroBlockEnd: ''
79+
MaxEmptyLinesToKeep: 1
80+
NamespaceIndentation: None
81+
ObjCBlockIndentWidth: 4
82+
ObjCSpaceAfterProperty: false
83+
ObjCSpaceBeforeProtocolList: true
84+
PenaltyBreakAssignment: 2
85+
PenaltyBreakBeforeFirstCallParameter: 19
86+
PenaltyBreakComment: 300
87+
PenaltyBreakFirstLessLess: 120
88+
PenaltyBreakString: 1000
89+
PenaltyExcessCharacter: 1000000
90+
PenaltyReturnTypeOnItsOwnLine: 60
91+
PointerAlignment: Left
92+
RawStringFormats:
93+
- Delimiter: pb
94+
Language: TextProto
95+
BasedOnStyle: google
96+
ReflowComments: true
97+
SortIncludes: true
98+
SortUsingDeclarations: true
99+
SpaceAfterCStyleCast: false
100+
SpaceAfterTemplateKeyword: true
101+
SpaceBeforeAssignmentOperators: true
102+
SpaceBeforeParens: ControlStatements
103+
SpaceInEmptyParentheses: false
104+
SpacesBeforeTrailingComments: 1
105+
SpacesInAngles: false
106+
SpacesInContainerLiterals: false
107+
SpacesInCStyleCastParentheses: false
108+
SpacesInParentheses: false
109+
SpacesInSquareBrackets: false
110+
Standard: Cpp11
111+
TabWidth: 4
112+
UseTab: Never
113+
...
114+

format

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
format_directory() {
4+
declare -r directory="$1"
5+
find "$directory" -type f -exec clang-format -i {} \;
6+
}
7+
8+
main() {
9+
declare -ar targets=("sample/" "src/" "include/pfs")
10+
for target in "${targets[@]}"; do
11+
format_directory "$target"
12+
done
13+
}
14+
15+
main "$@"

0 commit comments

Comments
 (0)