mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#24665: document clang tidy named args
This commit is contained in:
parent
40a22e457a
commit
8020bfa8c1
@ -160,11 +160,57 @@ public:
|
|||||||
} // namespace foo
|
} // namespace foo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Coding Style (C++ named arguments)
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
When passing named arguments, use a format that clang-tidy understands. The
|
||||||
|
argument names can otherwise not be verified by clang-tidy.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
void function(Addrman& addrman, bool clear);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
function(g_addrman, /*clear=*/false);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running clang-tidy
|
||||||
|
|
||||||
|
To run clang-tidy on Ubuntu/Debian, install the dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
apt install clang-tidy bear clang
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, pass clang as compiler to configure, and use bear to produce the `compile_commands.json`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./autogen.sh && ./configure CC=clang CXX=clang++
|
||||||
|
make clean && bear make -j $(nproc) # For bear 2.x
|
||||||
|
make clean && bear -- make -j $(nproc) # For bear 3.x
|
||||||
|
```
|
||||||
|
|
||||||
|
To run clang-tidy on all source files:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
( cd ./src/ && run-clang-tidy -j $(nproc) )
|
||||||
|
```
|
||||||
|
|
||||||
|
To run clang-tidy on the changed source lines:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git diff | ( cd ./src/ && clang-tidy-diff -p2 -j $(nproc) )
|
||||||
|
```
|
||||||
|
|
||||||
Coding Style (Python)
|
Coding Style (Python)
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
|
Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
|
||||||
|
|
||||||
|
|
||||||
Coding Style (Doxygen-compatible comments)
|
Coding Style (Doxygen-compatible comments)
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
|
@ -959,16 +959,16 @@ std::optional<AddressPosition> AddrManImpl::FindAddressEntry_(const CAddress& ad
|
|||||||
|
|
||||||
if(addr_info->fInTried) {
|
if(addr_info->fInTried) {
|
||||||
int bucket{addr_info->GetTriedBucket(nKey, m_asmap)};
|
int bucket{addr_info->GetTriedBucket(nKey, m_asmap)};
|
||||||
return AddressPosition(/*tried=*/true,
|
return AddressPosition(/*tried_in=*/true,
|
||||||
/*multiplicity=*/1,
|
/*multiplicity_in=*/1,
|
||||||
/*bucket=*/bucket,
|
/*bucket_in=*/bucket,
|
||||||
/*position=*/addr_info->GetBucketPosition(nKey, false, bucket));
|
/*position_in=*/addr_info->GetBucketPosition(nKey, false, bucket));
|
||||||
} else {
|
} else {
|
||||||
int bucket{addr_info->GetNewBucket(nKey, m_asmap)};
|
int bucket{addr_info->GetNewBucket(nKey, m_asmap)};
|
||||||
return AddressPosition(/*tried=*/false,
|
return AddressPosition(/*tried_in=*/false,
|
||||||
/*multiplicity=*/addr_info->nRefCount,
|
/*multiplicity_in=*/addr_info->nRefCount,
|
||||||
/*bucket=*/bucket,
|
/*bucket_in=*/bucket,
|
||||||
/*position=*/addr_info->GetBucketPosition(nKey, true, bucket));
|
/*position_in=*/addr_info->GetBucketPosition(nKey, true, bucket));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user