You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2016/04/18 02:14:12 UTC

[trafficserver] 01/02: TS-4164 Update to new clang-format version

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit f2e3fbbdabc395a53a444f8545f0780bca2d0031
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Sat Apr 16 09:47:46 2016 -0600

    TS-4164 Update to new clang-format version
---
 .clang-format         | 85 +++++++++++++++++++++++++++++++++++----------------
 tools/clang-format.sh | 28 ++++++++++++-----
 2 files changed, 79 insertions(+), 34 deletions(-)

diff --git a/.clang-format b/.clang-format
index 8af2a45..61d0d66 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,62 +1,93 @@
 ---
 Language:        Cpp
-# BasedOnStyle:  Mozilla
 AccessModifierOffset: -2
-ConstructorInitializerIndentWidth: 2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
 AlignEscapedNewlinesLeft: true
+AlignOperands:   true
 AlignTrailingComments: true
 AllowAllParametersOfDeclarationOnNextLine: false
 AllowShortBlocksOnASingleLine: false
 AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
 AllowShortIfStatementsOnASingleLine: false
 AllowShortLoopsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: Inline
-AlwaysBreakAfterDefinitionReturnType: true
-AlwaysBreakTemplateDeclarations: false
+AlwaysBreakAfterDefinitionReturnType: All
+AlwaysBreakAfterReturnType: AllDefinitions
 AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:   
+  AfterClass:      true
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   true
+  AfterNamespace:  true
+  AfterObjCDeclaration: false
+  AfterStruct:     true
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
 BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Linux
 BreakBeforeTernaryOperators: false
 BreakConstructorInitializersBeforeComma: false
-BinPackParameters: true
-BinPackArguments: true
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
 ColumnLimit:     132
+CommentPragmas:  '^ IWYU pragma:'
 ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 2
+ContinuationIndentWidth: 2
+Cpp11BracedListStyle: true
 DerivePointerAlignment: false
+DisableFormat:   false
 ExperimentalAutoDetectBinPacking: false
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+SortIncludes:    false
+IncludeCategories: 
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+  - Regex:           '^(<|"(gtest|isl|json)/)'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '$'
 IndentCaseLabels: false
+IndentWidth:     2
 IndentWrappedFunctionNames: false
-IndentFunctionDeclarationAfterType: false
-MaxEmptyLinesToKeep: 2
 KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
 NamespaceIndentation: Inner
+ObjCBlockIndentWidth: 2
 ObjCSpaceAfterProperty: true
 ObjCSpaceBeforeProtocolList: false
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
-PenaltyBreakString: 1000
 PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 200
 PointerAlignment: Right
-SpacesBeforeTrailingComments: 1
-Cpp11BracedListStyle: true
-Standard:        Cpp03
-IndentWidth:     2
-TabWidth:        8
-UseTab:          Never
-BreakBeforeBraces: Linux
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-SpacesInAngles:  false
-SpaceInEmptyParentheses: false
-SpacesInCStyleCastParentheses: false
+ReflowComments:  true
 SpaceAfterCStyleCast: false
-SpacesInContainerLiterals: true
 SpaceBeforeAssignmentOperators: true
-ContinuationIndentWidth: 2
-CommentPragmas:  '^ IWYU pragma:'
-ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
 SpaceBeforeParens: ControlStatements
-DisableFormat:   false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        8
+UseTab:          Never
+JavaScriptQuotes: Leave
 ...
 
diff --git a/tools/clang-format.sh b/tools/clang-format.sh
index aab69a0..f9b9544 100755
--- a/tools/clang-format.sh
+++ b/tools/clang-format.sh
@@ -22,7 +22,10 @@ set -e # exit on error
 
 DIR=${1:-.}
 ROOT=${ROOT:-$(git rev-parse --show-toplevel)/.git/fmt}
-URL=${URL:-https://bintray.com/artifact/download/apache/trafficserver/clang-format-20150331.tar.bz2}
+PACKAGE="clang-format-20160415.tar.bz2"
+VERSION="clang-format version 3.9.0 (trunk 265913)"
+
+URL=${URL:-https://bintray.com/artifact/download/apache/trafficserver/${PACKAGE}}
 
 TAR=${TAR:-tar}
 CURL=${CURL:-curl}
@@ -50,16 +53,27 @@ esac
 
 mkdir -p ${ROOT}
 
-if [ ! -e ${FORMAT} ] ; then
+# Note that the two spaces between the hash and ${ARCHIVE) is needed
+if [ ! -e ${FORMAT} -o ! -e ${ROOT}/${PACKAGE} ] ; then
   ${CURL} -L --progress-bar -o ${ARCHIVE} ${URL}
   ${TAR} -x -C ${ROOT} -f ${ARCHIVE}
   cat > ${ROOT}/sha1 << EOF
-7117c5bed99da43be733427970b4239f4bd8063d  ${ARCHIVE}
+d5558924377a6ad5799956cec5b37d4e421e2156  ${ARCHIVE}
 EOF
   ${SHASUM} -c ${ROOT}/sha1
 fi
 
-for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc); do
-    echo $file
-    ${FORMAT} -i $file
-done
+
+# Make sure we only run this with our exact version
+ver=$(${FORMAT} --version)
+if [ "$ver" != "$VERSION" ]; then
+    echo "Wrong version of clang-format!"
+    echo "See https://bintray.com/apache/trafficserver/clang-format-tools/view for a newer version,"
+    echo "or alternatively, undefine the FORMAT environment variable"
+    exit 1
+else
+    for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc); do
+	echo $file
+	${FORMAT} -i $file
+    done
+fi

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.