Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AFLplusplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ulf Kargén
AFLplusplus
Commits
cd259fe1
Commit
cd259fe1
authored
5 years ago
by
Andrea Fioraldi
Browse files
Options
Downloads
Patches
Plain Diff
add custom format wrapping clang-format
parent
d7b707a7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.clang-format
+148
-0
148 additions, 0 deletions
.clang-format
.custom-format.py
+71
-0
71 additions, 0 deletions
.custom-format.py
with
219 additions
and
0 deletions
.clang-format
0 → 100644
+
148
−
0
View file @
cd259fe1
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...
This diff is collapsed.
Click to expand it.
.custom-format.py
0 → 100755
+
71
−
0
View file @
cd259fe1
#!/usr/bin/env python3
import
subprocess
import
sys
with
open
(
"
.clang-format
"
)
as
f
:
fmt
=
f
.
read
()
COLUMN_LIMIT
=
80
for
line
in
fmt
.
split
(
"
\n
"
):
line
=
line
.
split
(
"
:
"
)
if
line
[
0
].
strip
()
==
"
ColumnLimit
"
:
COLUMN_LIMIT
=
int
(
line
[
1
].
strip
())
def
custom_format
(
filename
):
p
=
subprocess
.
Popen
([
'
clang-format-7
'
,
filename
],
stdout
=
subprocess
.
PIPE
)
src
,
_
=
p
.
communicate
()
src
=
str
(
src
,
"
utf-8
"
)
macro_indent
=
0
out
=
""
for
line
in
src
.
split
(
"
\n
"
):
if
line
.
startswith
(
"
#
"
):
i
=
macro_indent
if
line
.
startswith
(
"
#end
"
)
and
macro_indent
>
0
:
macro_indent
-=
1
i
-=
1
elif
line
.
startswith
(
"
#el
"
)
and
macro_indent
>
0
:
i
-=
1
elif
line
.
startswith
(
"
#if
"
)
and
not
(
line
.
startswith
(
"
#ifndef
"
)
and
line
.
endswith
(
"
_H
"
)):
macro_indent
+=
1
r
=
"
#
"
+
(
i
*
"
"
)
+
line
[
1
:]
if
i
!=
0
and
line
.
endswith
(
"
\\
"
):
r
=
r
[:
-
1
]
while
r
[
-
1
].
isspace
()
and
len
(
r
)
!=
(
len
(
line
)
-
1
):
r
=
r
[:
-
1
]
r
+=
"
\\
"
if
len
(
r
)
<=
COLUMN_LIMIT
:
line
=
r
elif
"
/*
"
in
line
and
not
line
.
strip
().
startswith
(
"
/*
"
)
and
line
.
endswith
(
"
*/
"
)
and
len
(
line
)
<
(
COLUMN_LIMIT
-
2
):
cmt_start
=
line
.
rfind
(
"
/*
"
)
line
=
line
[:
cmt_start
]
+
"
"
*
(
COLUMN_LIMIT
-
2
-
len
(
line
))
+
line
[
cmt_start
:]
out
+=
line
+
"
\n
"
return
(
out
)
args
=
sys
.
argv
[
1
:]
if
len
(
args
)
==
0
:
print
(
"
Usage: ./format.py [-i] <filename>
"
)
print
()
print
(
"
The -i option, if specified, let the script to modify in-place
"
)
print
(
"
the source files. By default the results are written to stdout.
"
)
print
()
exit
(
1
)
in_place
=
False
if
args
[
0
]
==
"
-i
"
:
in_place
=
True
args
=
args
[
1
:]
for
filename
in
args
:
code
=
custom_format
(
filename
)
if
in_place
:
with
open
(
filename
,
"
w
"
)
as
f
:
f
.
write
(
code
)
else
:
print
(
code
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment