[code-style] change to clang-format

This commit is contained in:
Jonathan Hui
2018-02-09 21:43:42 +00:00
parent 053557ca72
commit d3e9925b42
8 changed files with 131 additions and 39 deletions
-16
View File
@@ -1,16 +0,0 @@
--style=allman
--max-code-length=120
--max-instatement-indent=100
--attach-namespaces --attach-inlines
--attach-extern-c
--min-conditional-indent=0
--break-blocks
--pad-oper
--pad-header
--unpad-paren
--align-pointer=name
--add-brackets
--keep-one-line-blocks
--convert-tabs
--break-after-logical
--formatted
+112
View File
@@ -0,0 +1,112 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<openthread/.*/'
Priority: 4
- Regex: '^<openthread/'
Priority: 3
- Regex: '^<'
Priority: 2
- Regex: '^".*/'
Priority: 5
- Regex: '^"'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
+7 -1
View File
@@ -61,7 +61,13 @@ matrix:
compiler: gcc
- env: BUILD_TARGET="pretty-check"
os: linux
- env: BUILD_TARGET="scan-build" CC=clang-5.0 CXX=clang++-5.0
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
- env: BUILD_TARGET="scan-build" CC="clang" CXX="clang++"
os: linux
addons:
apt:
+1 -7
View File
@@ -49,13 +49,7 @@ cd /tmp || die
}
[ $BUILD_TARGET != pretty-check ] || {
wget http://jaist.dl.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz || die
tar xzvf astyle_2.05.1_linux.tar.gz || die
cd astyle/build/gcc || die
LDFLAGS=" " make || die
cd ../../..
export PATH=/tmp/astyle/build/gcc/bin:$PATH || die
astyle --version || die
clang-format --version || die
}
[ $BUILD_TARGET != scan-build ] || {
-1
View File
@@ -35,7 +35,6 @@ die() {
set -x
[ $BUILD_TARGET != pretty-check ] || {
export PATH=/tmp/astyle/build/gcc/bin:$PATH || die
./bootstrap || die
./configure || die
make pretty-check || die
-2
View File
@@ -59,8 +59,6 @@ SUBDIRS = \
$(NULL)
EXTRA_DIST = \
.astyle/astyle-opts \
.astyle/astyle-wrap.sh \
.default-version \
bootstrap \
etc \
+4 -4
View File
@@ -357,10 +357,10 @@ fi
# Code style
#
AC_SUBST(PRETTY, ["\${abs_top_srcdir}/.astyle/astyle-wrap.sh"])
AC_SUBST(PRETTY_ARGS, ["astyle --options=\${abs_top_srcdir}/.astyle/astyle-opts"])
AC_SUBST(PRETTY_CHECK, ["\${abs_top_srcdir}/.astyle/astyle-wrap.sh"])
AC_SUBST(PRETTY_CHECK_ARGS, ["astyle --options=\${abs_top_srcdir}/.astyle/astyle-opts --dry-run"])
AC_SUBST(PRETTY, ["clang-format"])
AC_SUBST(PRETTY_ARGS, ["-style=file -i"])
AC_SUBST(PRETTY_CHECK, ["\${abs_top_srcdir}/script/clang-format-check.sh"])
AC_SUBST(PRETTY_CHECK_ARGS, [""])
#
# Tests
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2016, The OpenThread Authors.
# Copyright (c) 2018, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,17 +28,16 @@
#
#
# astye does not return a non-zero exit code. This wrapper exists with a
# non-zero exit code if there is any output from astyle.
# clang-format does not return a non-zero exit code. This wrapper
# exits with a non-zero exit code if clang-format outputs any
# replacements.
#
die() {
echo " *** ERROR: " $*
exit 1
echo " *** ERROR: " $*
exit 1
}
set -x
[ -z "`$@`" ] || {
[ "$3" != "--dry-run" ] || die
}
[ -z "`clang-format -style=file -output-replacements-xml $@ | grep \"<replacement \"`" ] || die