diff options
author | Brad King <brad.king@kitware.com> | 2018-05-31 17:40:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-06-01 13:52:02 (GMT) |
commit | 523c443d135f6474cf5a9d0372b3cc364fc7ebe5 (patch) | |
tree | 82f22000589d6ded60d2c325b221c5290cda3d3d | |
parent | eb7ec19c1c639e91b812763ead3a56e97d20aec4 (diff) | |
download | CMake-523c443d135f6474cf5a9d0372b3cc364fc7ebe5.zip CMake-523c443d135f6474cf5a9d0372b3cc364fc7ebe5.tar.gz CMake-523c443d135f6474cf5a9d0372b3cc364fc7ebe5.tar.bz2 |
clang-format.bash: update to clang-format-6.0
Update `.clang-format` with configuration to make the 6.0 format as
close as possible to what 3.8 produced before. Then revise the style:
* Indent preprocessor directives (a feature new since 3.8)
* Add a newline and indentation before inheritance `:` and `,`
Rename the Git attribute identifying the format to include the
clang-format version number: `format.clang-format-6.0`. This will aid
external infrastructure in knowing what version of the tool to run.
-rw-r--r-- | .clang-format | 17 | ||||
-rw-r--r-- | .gitattributes | 4 | ||||
-rw-r--r-- | Help/dev/source.rst | 2 | ||||
-rw-r--r-- | Source/.gitattributes | 2 | ||||
-rw-r--r-- | Source/CursesDialog/form/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/CSharpLinkFromCxx/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/CompileFeatures/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/PositionIndependentTargets/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/cmake_depends/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/RunCMake/GenerateExportHeader/reference/.gitattributes | 2 | ||||
-rw-r--r-- | Tests/VSWinStorePhone/Direct3DApp1/.gitattributes | 2 | ||||
-rw-r--r-- | Utilities/.gitattributes | 4 | ||||
-rwxr-xr-x | Utilities/Scripts/clang-format.bash | 10 |
13 files changed, 33 insertions, 20 deletions
diff --git a/.clang-format b/.clang-format index c0b5cc3..162c56d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,8 +1,21 @@ --- -# This configuration requires clang-format version 3.8 exactly. +# This configuration requires clang-format version 6.0 exactly. BasedOnStyle: Mozilla AlignOperands: false -AlwaysBreakAfterReturnType: None +AllowShortFunctionsOnASingleLine: InlineOnly AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterEnum: true + AfterFunction: true + AfterStruct: true + AfterUnion: true +BreakBeforeBraces: Custom ColumnLimit: 79 +IndentPPDirectives: AfterHash +SortUsingDeclarations: false +SpaceAfterTemplateKeyword: true ... diff --git a/.gitattributes b/.gitattributes index fd878ac..d6fd5d6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,11 +2,11 @@ .hooks* export-ignore # Custom attribute to mark sources as using our C code style. -[attr]our-c-style whitespace=tab-in-indent format.clang-format +[attr]our-c-style whitespace=tab-in-indent format.clang-format-6.0 # Custom attribute to mark sources as generated. # Do not perform whitespace checks. Do not format. -[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format +[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format-6.0 bootstrap eol=lf configure eol=lf diff --git a/Help/dev/source.rst b/Help/dev/source.rst index d0c19eb..57de818 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -9,7 +9,7 @@ See documentation on `CMake Development`_ for more information. C++ Code Style ============== -We use `clang-format`_ version **3.8** to define our style for C++ code in +We use `clang-format`_ version **6.0** to define our style for C++ code in the CMake source tree. See the `.clang-format`_ configuration file for our style settings. Use the `Utilities/Scripts/clang-format.bash`_ script to format source code. It automatically runs ``clang-format`` on the set of diff --git a/Source/.gitattributes b/Source/.gitattributes index 0f829a3..7c160cc 100644 --- a/Source/.gitattributes +++ b/Source/.gitattributes @@ -1,2 +1,2 @@ # Do not format third-party sources. -/kwsys/** -format.clang-format +/kwsys/** -format.clang-format-6.0 diff --git a/Source/CursesDialog/form/.gitattributes b/Source/CursesDialog/form/.gitattributes index 62d728c..12ede74 100644 --- a/Source/CursesDialog/form/.gitattributes +++ b/Source/CursesDialog/form/.gitattributes @@ -1 +1 @@ -* -format.clang-format +* -format.clang-format-6.0 diff --git a/Tests/CSharpLinkFromCxx/.gitattributes b/Tests/CSharpLinkFromCxx/.gitattributes index 57a39049..cf9d355 100644 --- a/Tests/CSharpLinkFromCxx/.gitattributes +++ b/Tests/CSharpLinkFromCxx/.gitattributes @@ -1 +1 @@ -UsefulManagedCppClass.* -format.clang-format +UsefulManagedCppClass.* -format.clang-format-6.0 diff --git a/Tests/CompileFeatures/.gitattributes b/Tests/CompileFeatures/.gitattributes index 83da28d..95a8956 100644 --- a/Tests/CompileFeatures/.gitattributes +++ b/Tests/CompileFeatures/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source containing C++11 '>>' syntax as C++98. -cxx_right_angle_brackets.cpp -format.clang-format +cxx_right_angle_brackets.cpp -format.clang-format-6.0 diff --git a/Tests/PositionIndependentTargets/.gitattributes b/Tests/PositionIndependentTargets/.gitattributes index ed36631..61b2751 100644 --- a/Tests/PositionIndependentTargets/.gitattributes +++ b/Tests/PositionIndependentTargets/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source where we want a long line preserved. -pic_test.h -format.clang-format +pic_test.h -format.clang-format-6.0 diff --git a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes index 9c22288..d9a4db4 100644 --- a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes +++ b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source encoded in UTF-16. -test_UTF-16LE.h -format.clang-format +test_UTF-16LE.h -format.clang-format-6.0 diff --git a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes index 883a7f1..d9b566e 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes +++ b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes @@ -1,2 +1,2 @@ # Exclude reference content from formatting. -* -format.clang-format +* -format.clang-format-6.0 diff --git a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes index 601c97b..78a5469 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes +++ b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes @@ -1 +1 @@ -Direct3DApp1.cpp -format.clang-format +Direct3DApp1.cpp -format.clang-format-6.0 diff --git a/Utilities/.gitattributes b/Utilities/.gitattributes index bd97802..96a4323 100644 --- a/Utilities/.gitattributes +++ b/Utilities/.gitattributes @@ -3,5 +3,5 @@ SetupForDevelopment.sh export-ignore # Do not format third-party sources. -/KWIML/** -format.clang-format -/cm*/** -format.clang-format +/KWIML/** -format.clang-format-6.0 +/cm*/** -format.clang-format-6.0 diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash index 4c6225d..7ca4433 100755 --- a/Utilities/Scripts/clang-format.bash +++ b/Utilities/Scripts/clang-format.bash @@ -78,7 +78,7 @@ test "$#" = 0 || die "$usage" # Find a default tool. tools=' - clang-format-3.8 + clang-format-6.0 clang-format ' if test "x$clang_format" = "x"; then @@ -96,8 +96,8 @@ if ! type -p "$clang_format" >/dev/null; then exit 1 fi -if ! "$clang_format" --version | grep 'clang-format version 3\.8' >/dev/null 2>/dev/null; then - echo "clang-format version 3.8 is required (exactly)" +if ! "$clang_format" --version | grep 'clang-format version 6\.0' >/dev/null 2>/dev/null; then + echo "clang-format version 6.0 is required (exactly)" exit 1 fi @@ -115,8 +115,8 @@ esac $git_ls | # Select sources with our attribute. - git check-attr --stdin format.clang-format | - grep -e ': format\.clang-format: set$' | + git check-attr --stdin format.clang-format-6.0 | + grep -e ': format\.clang-format-6\.0: set$' | sed -n 's/:[^:]*:[^:]*$//p' | # Update sources in-place. |