Use clang-format for qualifier alignment (#5845)

`QualifierAlignment` option is available since clang-format v14 and
works better than our own script.
This commit is contained in:
Mike Gelfand 2023-07-30 16:43:43 +01:00 committed by GitHub
parent 84f9d01e7d
commit c14094f4c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 20 deletions

View File

@ -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

View File

@ -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</g' '{}' '+'
fi
# format JS
# but only if js has changed
git diff --cached --quiet -- "web/**" && exit $exitcode

View File

@ -75,7 +75,7 @@ public:
return ::dht_search(id, port, af, callback, closure);
}
virtual int init(int s, int s6, unsigned const char* id, unsigned const char* v)
virtual int init(int s, int s6, unsigned char const* id, unsigned char const* v)
{
return ::dht_init(s, s6, id, v);
}

View File

@ -26,7 +26,7 @@ private:
public:
using value_type = Char;
using const_reference = const Char&;
using const_reference = Char const&;
tr_strbuf()
{

View File

@ -509,7 +509,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
return;
}
volatile int status;
int volatile status;
tr_torrentSetLocation(self.fHandle, folder.UTF8String, YES, NULL, &status);
while (status == TR_LOC_MOVING) //block while moving (for now)

View File

@ -209,7 +209,7 @@ protected:
return 0;
}
int init(int dht_socket, int dht_socket6, unsigned const char* id, unsigned const char* /*v*/) override
int init(int dht_socket, int dht_socket6, unsigned char const* id, unsigned char const* /*v*/) override
{
inited_ = true;
dht_socket_ = dht_socket;