Skip to content

Commit 67f654e

Browse files
MarcoFalkefanquake
authored andcommitted
doc: Document clang-tidy in dev notes
1 parent 95cac21 commit 67f654e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

doc/developer-notes.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,57 @@ public:
137137
} // namespace foo
138138
```
139139

140+
Coding Style (C++ named arguments)
141+
------------------------------
142+
143+
When passing named arguments, use a format that clang-tidy understands. The
144+
argument names can otherwise not be verified by clang-tidy.
145+
146+
For example:
147+
148+
```c++
149+
void function(Addrman& addrman, bool clear);
150+
151+
int main()
152+
{
153+
function(g_addrman, /*clear=*/false);
154+
}
155+
```
156+
157+
### Running clang-tidy
158+
159+
To run clang-tidy on Ubuntu/Debian, install the dependencies:
160+
161+
```sh
162+
apt install clang-tidy bear clang
163+
```
164+
165+
Then, pass clang as compiler to configure, and use bear to produce the `compile_commands.json`:
166+
167+
```sh
168+
./autogen.sh && ./configure CC=clang CXX=clang++
169+
make clean && bear make -j $(nproc) # For bear 2.x
170+
make clean && bear -- make -j $(nproc) # For bear 3.x
171+
```
172+
173+
To run clang-tidy on all source files:
174+
175+
```sh
176+
( cd ./src/ && run-clang-tidy -j $(nproc) )
177+
```
178+
179+
To run clang-tidy on the changed source lines:
180+
181+
```sh
182+
git diff | ( cd ./src/ && clang-tidy-diff -p2 -j $(nproc) )
183+
```
184+
140185
Coding Style (Python)
141186
---------------------
142187

143188
Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
144189

190+
145191
Coding Style (Doxygen-compatible comments)
146192
------------------------------------------
147193

0 commit comments

Comments
 (0)