doc: Fix incorrect C++ named args#22981
Conversation
|
Setup clang-tidy: Full test: Diff test: |
|
Concept ACK, being able to check these automatically with a tool is a good idea. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
fanquake
left a comment
There was a problem hiding this comment.
Concept ACK - Tested using the steps below. If we are going to start making more of these changes we should be integrating this into the CI at some point soon.
docker run -it --rm ubuntu:hirsute
apt update && apt upgrade
apt install git build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 clang-12 clang-tidy-12 bear libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libdb-dev libdb++-dev
clang-12 --version
Ubuntu clang version 12.0.0-3ubuntu1~21.04.2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-tidy-12 --version
LLVM (http://llvm.org/):
LLVM version 12.0.0
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: skylake-avx512
bear --version
bear 3.0.8
git clone https://github.com/bitcoin/bitcoin
cd bitcoin
./autogen
./configure --with-incompatible-bdb CC=clang-12 CXX=clang++-12
make clean && bear -- make -j $(nproc)
( cd ./src/ && run-clang-tidy-12 -j $(nproc) )
Enabled checks:
bugprone-argument-comment
clang-tidy-12 --use-color -p=/bitcoin /bitcoin/src/blockfilter.cpp
clang-tidy-12 --use-color -p=/bitcoin /bitcoin/src/chain.cpp
clang-tidy-12 --use-color -p=/bitcoin /bitcoin/src/banman.cpp
<snipp>
git diff | ( cd ./src/ && clang-tidy-diff-12.py -p2 -j $(nproc) )
No relevant changes found.
Happy to review a pull doing this. Though, I think it is also acceptable to run it only once before every major release. |
|
I think we should first make sure our argument names make sense, then do this. |
fa47e7e to
fab1408
Compare
fab1408 to
fa41833
Compare
|
Concept ACK |
fa41833 to
fadf4db
Compare
fadf4db to
fa7efa0
Compare
|
Concept ACK. Should we document the required comment style somewhere in the developer docs? |
|
Happy to document the style in a follow-up. I have one follow-up myself that adjusts the style of existing args. The goal of this pull is to replace wrong names with correct names. |
lsilva01
left a comment
There was a problem hiding this comment.
tACK fa7efa0
The commands described in #22981 (comment) ran successfully.
And after clang-tidy-10 returned without an error, I changed a commented named argument in a function, reran it, and the error was identified.
Should compile_commands.json be added to .gitignore ?
fa7efa0 to
faa5a80
Compare
Yeah, will do on the next force push or the next follow-up pull, unless someone beats me to it. |
|
Concept ACK. |
/usr/local/opt/llvm/bin/clang-tidy --use-color -p=/Users/michael/github/bitcoin-merge-tree /Users/michael/github/bitcoin-merge-tree/src/psbt.cpp
psbt.cpp:226:53: error: argument name 'input_idx' in comment does not match parameter name 'nInIn' [bugprone-argument-comment,-warnings-as-errors]
MutableTransactionSignatureCreator creator(&tx, /*input_idx=*/0, out.nValue, SIGHASH_ALL);
^
./script/sign.h:48:88: note: 'nInIn' declared here
MutableTransactionSignatureCreator(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn);
^
1 warning generated.
1 warning treated as error |
|
Good catch. Fixed in #23525 |
faa5a80 to
fa83737
Compare
fa83737 to
fac4947
Compare
|
Rebased to get rid of already fixed instances. Only 29 left in this pull for now. |
fac4947 doc: Fix incorrect C++ named args (MarcoFalke) Pull request description: Incorrect named args are source of bugs, like bitcoin#22979. Fix that by correcting them and adjust the format, so that clang-tidy can check it. ACKs for top commit: fanquake: ACK fac4947 - `run-clang-tidy` works for me now. Tree-SHA512: 2694e17a1586394baf30bbc479a913e4bad361221e8470b8739caf30aacea736befc73820f3fe56f6207d9f5d969323278d43a647f58c3497e8e44cad79f8934
fac4947 doc: Fix incorrect C++ named args (MarcoFalke) Pull request description: Incorrect named args are source of bugs, like bitcoin#22979. Fix that by correcting them and adjust the format, so that clang-tidy can check it. ACKs for top commit: fanquake: ACK fac4947 - `run-clang-tidy` works for me now. Tree-SHA512: 2694e17a1586394baf30bbc479a913e4bad361221e8470b8739caf30aacea736befc73820f3fe56f6207d9f5d969323278d43a647f58c3497e8e44cad79f8934
Incorrect named args are source of bugs, like #22979.
Fix that by correcting them and adjust the format, so that clang-tidy can check it.