From c14094f4c9c05455c58e1e503d0d31001e679401 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sun, 30 Jul 2023 16:43:43 +0100 Subject: [PATCH] Use clang-format for qualifier alignment (#5845) `QualifierAlignment` option is available since clang-format v14 and works better than our own script. --- .clang-format | 2 ++ code_style.sh | 16 ---------------- libtransmission/tr-dht.h | 2 +- libtransmission/tr-strbuf.h | 2 +- macosx/Torrent.mm | 2 +- tests/libtransmission/dht-test.cc | 2 +- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/.clang-format b/.clang-format index e1a5ddd00..b30567097 100644 --- a/.clang-format +++ b/.clang-format @@ -56,6 +56,7 @@ ConstructorInitializerIndentWidth: 4 FixNamespaceComments: true IndentGotoLabels: false KeepEmptyLinesAtTheStartOfBlocks: true +QualifierAlignment: Right SortUsingDeclarations: true SpaceAfterTemplateKeyword: false StatementMacros: @@ -71,3 +72,4 @@ ObjCBlockIndentWidth: 4 ObjCBreakBeforeNestedBlockParam: false ObjCSpaceBeforeProtocolList: false PenaltyExcessCharacter: 1 +QualifierAlignment: Right diff --git a/code_style.sh b/code_style.sh index 8769ce79c..7bb9e887c 100755 --- a/code_style.sh +++ b/code_style.sh @@ -65,22 +65,6 @@ if ! find_cfiles -exec "${clang_format_exe}" $clang_format_args '{}' '+'; then exitcode=1 fi -# enforce east const -# look for 'const' -# - as the first token in the line -# - or preceded by 'static' -# - or following any of (<,; -# - but not if 'const' is followed by ` override` (const virtual function) -# - but not if 'const' is followed by ` = 0` (const virtual function) -matches="$(find_cfiles -exec perl -ne 'print "west const:",$ARGV,":",$_ if /((?:^|[(<,;]|\bstatic\s+)\s*)\b(const)\b(?!\s+((\w+\s*\[)|(override)|(\=\ 0)))/' '{}' '+')" -if [ -n "$matches" ]; then - echo "$matches" - exitcode=1 -fi -if [ -n "$fix" ]; then - find_cfiles -exec perl -pi -e 's/((?:^|[(<,;]|\bstatic\s+)\s*)\b(const)\b(?!\s+((\w+\s*\[)|(override)|(\=\ 0)))/\1>\2