Commit 523c443d authored by Brad King's avatar Brad King

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.
parent eb7ec19c
---
# 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
...
......@@ -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
......
......@@ -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
......
# Do not format third-party sources.
/kwsys/** -format.clang-format
/kwsys/** -format.clang-format-6.0
* -format.clang-format
* -format.clang-format-6.0
UsefulManagedCppClass.* -format.clang-format
UsefulManagedCppClass.* -format.clang-format-6.0
# 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
# 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
# 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
# Exclude reference content from formatting.
* -format.clang-format
* -format.clang-format-6.0
Direct3DApp1.cpp -format.clang-format
Direct3DApp1.cpp -format.clang-format-6.0
......@@ -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
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment