From 523c443d135f6474cf5a9d0372b3cc364fc7ebe5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 31 May 2018 13:40:34 -0400 Subject: 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. --- .clang-format | 17 +++++++++++++++-- .gitattributes | 4 ++-- Help/dev/source.rst | 2 +- Source/.gitattributes | 2 +- Source/CursesDialog/form/.gitattributes | 2 +- Tests/CSharpLinkFromCxx/.gitattributes | 2 +- Tests/CompileFeatures/.gitattributes | 2 +- Tests/PositionIndependentTargets/.gitattributes | 2 +- Tests/RunCMake/CommandLine/cmake_depends/.gitattributes | 2 +- .../GenerateExportHeader/reference/.gitattributes | 2 +- Tests/VSWinStorePhone/Direct3DApp1/.gitattributes | 2 +- Utilities/.gitattributes | 4 ++-- 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. -- cgit v0.12