You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/03/24 21:38:17 UTC
mesos git commit: Upgraded to clang-format-3.8.
Repository: mesos
Updated Branches:
refs/heads/master 39acb0a6b -> 09b31633a
Upgraded to clang-format-3.8.
Review: https://reviews.apache.org/r/44758/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/09b31633
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/09b31633
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/09b31633
Branch: refs/heads/master
Commit: 09b31633a3edb3896e62cac2a006720f33c4b90d
Parents: 39acb0a
Author: Yong Tang <yo...@outlook.com>
Authored: Thu Mar 24 16:29:54 2016 -0400
Committer: Michael Park <mp...@apache.org>
Committed: Thu Mar 24 16:30:07 2016 -0400
----------------------------------------------------------------------
docs/clang-format.md | 41 +++++-------
support/clang-format | 163 ++++++++++++++++++++--------------------------
2 files changed, 87 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/09b31633/docs/clang-format.md
----------------------------------------------------------------------
diff --git a/docs/clang-format.md b/docs/clang-format.md
index 7f1c1df..4289813 100644
--- a/docs/clang-format.md
+++ b/docs/clang-format.md
@@ -5,34 +5,31 @@ layout: documentation
# ClangFormat
-[ClangFormat](http://llvm.org/releases/3.5.1/tools/clang/docs/ClangFormat.html) is an automatic source code formatting tool which helps us focus on the code rather than the formatting.
+[ClangFormat](http://llvm.org/releases/3.8.0/tools/clang/docs/ClangFormat.html) is an automatic source code formatting tool which helps us focus on the code rather than the formatting.
> The provided configurations try to honor the [Mesos C++ Style Guide](c++-style-guide.md) as much as possible, but there are some limitations which require manual attention. Even with these limitations however, ClangFormat will be extremely useful for your workflow!
## Setup
-### Install `clang-format-3.5`
+### Install `clang-format-3.8`
#### Ubuntu 14.04
+ # Add llvm repository
+ sudo apt-add-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main"
+
# Ensure apt-get is up to date.
sudo apt-get update
- # Install clang-format-3.5
- sudo apt-get install clang-format-3.5
-
-
-#### OS X Yosemite
+ # Install clang-format-3.8
+ sudo apt-get install clang-format-3.8
- # Install clang-3.5. The binaries are suffixed with '-3.5', e.g. 'clang++-3.5'.
- $ brew install llvm35 --with-clang
+#### OS X El Capitan
- # Download and install the clang-format scripts.
- $ wget http://llvm.org/releases/3.5.1/cfe-3.5.1.src.tar.xz
- $ tar -xzf cfe-3.5.1.src.tar.xz
- $ cp cfe-3.5.1.src/tools/clang-format/clang-format* `brew --cellar`/llvm35/3.5.1/share/clang-3.5
+ # Install clang-format (3.8).
+ $ brew install clang-format
### Formatting Configuration
@@ -42,8 +39,6 @@ By default, ClangFormat uses the configuration defined in a `.clang-format` or
The `bootstrap` script creates a `.clang-format` symlink at the top-level
directory which points to `support/clang-format` for ClangFormat to find.
-> NOTE: If you're using `clang-format-3.6`, you'll need to add a new option
-`BinPackArguments: false` to the `.clang-format` file!
### Editor Integration
@@ -53,13 +48,13 @@ Add the following to your `.vimrc`:
Ubuntu:
- map <C-K> :pyf /usr/share/vim/addons/syntax/clang-format-3.5.py<cr>
- imap <C-K> <c-o>:pyf /usr/share/vim/addons/syntax/clang-format-3.5.py<cr>
+ map <C-K> :pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr>
+ imap <C-K> <c-o>:pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr>
OS X:
- map <C-K> :pyf /usr/local/share/clang-3.5/clang-format.py<cr>
- imap <C-K> <c-o>:pyf /usr/local/share/clang-3.5/clang-format.py<cr>
+ map <C-K> :pyf /usr/local/share/clang/clang-format.py<cr>
+ imap <C-K> <c-o>:pyf /usr/local/share/clang/clang-format.py<cr>
The first line enables clang-format for `NORMAL` and `VISUAL` mode, the second line adds support for `INSERT` mode. Change `C-K` to another binding if you need clang-format on a different key (`C-K` stands for `Ctrl+k`).
@@ -67,7 +62,7 @@ With this integration you can press the bound key and clang-format will format t
It operates on the current, potentially unsaved buffer and does not create or save any files. To revert a formatting, just undo.
-> Source: http://llvm.org/releases/3.5.1/tools/clang/docs/ClangFormat.html
+> Source: http://llvm.org/releases/3.8.0/tools/clang/docs/ClangFormat.html
#### Emacs
@@ -75,17 +70,17 @@ Add the following to your `.emacs`:
Ubuntu:
- (load "/usr/share/emacs/site-lisp/clang-format-3.5/clang-format.el")
+ (load "/usr/share/emacs/site-lisp/clang-format-3.8/clang-format.el")
(global-set-key [C-M-tab] 'clang-format-region)
OS X:
- (load "/usr/local/share/clang-3.5/clang-format.el")
+ (load "/usr/local/share/clang/clang-format.el")
(global-set-key [C-M-tab] 'clang-format-region)
This binds the function `clang-format-region` to `C-M-tab`, which then formats the current line or selected region.
-> Source: http://llvm.org/releases/3.5.1/tools/clang/docs/ClangFormat.html
+> Source: http://llvm.org/releases/3.8.0/tools/clang/docs/ClangFormat.html
## Known Limitations
http://git-wip-us.apache.org/repos/asf/mesos/blob/09b31633/support/clang-format
----------------------------------------------------------------------
diff --git a/support/clang-format b/support/clang-format
index 499d0e7..bb58702 100644
--- a/support/clang-format
+++ b/support/clang-format
@@ -1,105 +1,80 @@
---
+# Note: Generated from clang-format 3.8.
BasedOnStyle: Google
-
-# Good:
-#
-# class Foo
-# {
-# public:
-#
-# Foo() = default;
-#
-# };
-#
-# Bad:
-#
-# class Foo
-# {
-# public:
-#
-# Foo() = default;
-#
-# };
-#
+Language: Cpp
AccessModifierOffset: -2
-
-# Good:
-#
-# clang = Clang(); // Comment 1
-# format = Format(); // Comment 2
-#
-# Bad:
-# clang = Clang(); // Comment 1
-# format = Format(); // Comment 2
-#
+AlignAfterOpenBracket: AlwaysBreak
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: true
+AlignOperands: true
AlignTrailingComments: false
-
-# Good:
-#
-# void F(int first,
-# int second,
-# int third,
-# int fourth,
-# int fifth,
-# int sixth,
-# int seventh,
-# int eighth) {}
-#
-# Bad:
-#
-# void F(int first, int second, int third, int fourth, int fifth, int sixth,
-# int seventh, int eighth) {}
-#
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: false
BinPackParameters: false
-
-# Like 'Attach', but break before braces on function, namespaces, class, struct
-# and union definitions.
-#
-BreakBeforeBraces: Linux
-
-# Good:
-#
-# class Foo
-# {
-# public:
-#
-# Foo()
-# : first(1), second(2) {}
-#
-# };
-#
-# Bad:
-#
-# class Foo
-# {
-# public:
-#
-# Foo()
-# : first(1), second(2) {}
-#
-# };
-#
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Mozilla
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
-
-# Continuation indents such as assignment statements are indented by 2 spaces.
ContinuationIndentWidth: 2
-
-# Don't try to guess the pointer alignment
+Cpp11BracedListStyle: true
DerivePointerAlignment: false
-
-# List of foreach macros due to lack of range-based for loops.
-ForEachMacros: [ foreach, foreachkey, foreachvalue, foreachpair ]
-
-# Maximum number of empty lines to keep.
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+ForEachMacros: [ foreach, foreachkey, foreachvalue, foreachpair ]
+IncludeCategories:
+ - Regex: '^<.*\.h>'
+ Priority: 1
+ - Regex: '^<.*\.hpp>'
+ Priority: 3
+ - Regex: '^<.*>'
+ Priority: 2
+ - Regex: '.*'
+ Priority: 4
+IndentCaseLabels: true
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
-
-# Good:
-#
-# x = 42; // Comment
-#
-# Bad:
-#
-# x = 42; // Comment
-#
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PenaltyBreakBeforeFirstCallParameter: 1
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 200
+PointerAlignment: Left
+ReflowComments: true
+SortIncludes: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Auto
+TabWidth: 8
+UseTab: Never
...