Merge pull request #1143 from gedankenexperimenter/clang-format
Switch from `astyle` to `clang-format` for code formattingpull/1149/head
commit
aba8c9ee66
@ -0,0 +1,47 @@
|
|||||||
|
# -*- mode: yaml -*-
|
||||||
|
---
|
||||||
|
BasedOnStyle: Google
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
## clang-format-15
|
||||||
|
# AlignConsecutiveAssignments:
|
||||||
|
# Enabled: true
|
||||||
|
# AlignCompound: true
|
||||||
|
# PadOperators: true
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: AcrossEmptyLines
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AttributeMacros:
|
||||||
|
- __attribute__((weak))
|
||||||
|
- __attribute__((always_inline))
|
||||||
|
- __attribute__((noinline))
|
||||||
|
- __attribute__((packed))
|
||||||
|
- __attribute__((optimize(3)))
|
||||||
|
- __attribute__((unused))
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
# BraceWrapping:
|
||||||
|
# SplitEmptyFunction: false
|
||||||
|
# SplitEmptyRecord: true
|
||||||
|
# SplitEmptyNamespace: true
|
||||||
|
# BreakBeforeBraces: Custom
|
||||||
|
ColumnLimit: 0
|
||||||
|
ConstructorInitializerIndentWidth: 2
|
||||||
|
ContinuationIndentWidth: 2
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IndentCaseLabels: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
# PackConstructorInitializers: CurrentLine
|
||||||
|
PointerAlignment: Right
|
||||||
|
# ReferenceAlignment: Right
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Allow the caller to specify a particular version of clang-format to use:
|
||||||
|
: "${CLANG_FORMAT_CMD:=clang-format}"
|
||||||
|
|
||||||
|
# Find all *.cpp and *.h files, except those in `testing/googletest/` and files
|
||||||
|
# generated by testcase scripts, and run `clang-format` on them:
|
||||||
|
find ./* -type f \( -name '*.h' -o -name '*.cpp' \) \
|
||||||
|
-not \( -path './testing/googletest/*' -o -name 'generated-testcase.cpp' \) \
|
||||||
|
-print0 | \
|
||||||
|
xargs -0 "${CLANG_FORMAT_CMD}" -i
|
||||||
|
|
||||||
|
# If we get the `--check` option, return an error if there are any changes to
|
||||||
|
# the git working tree after running `clang-format`:
|
||||||
|
if [[ $1 == '--check' ]]; then
|
||||||
|
|
||||||
|
if ! git diff --quiet; then
|
||||||
|
cat >&2 <<EOF
|
||||||
|
Differences found between git head and working tree. Either 'clang-format' made
|
||||||
|
formatting changes to your code, or you had uncommitted changes in your working
|
||||||
|
tree. Please remember to run 'bin/format-code.sh' before committing changes.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue