Skip to content

Commit 44512e7

Browse files
committed
Add a bit of documentation related to IWYU
Add some basic information about IWYU to src/tools/pginclude/README. Discussion: https://www.postgresql.org/message-id/flat/9395d484-eff4-47c2-b276-8e228526c8ae@eisentraut.org
1 parent fecc802 commit 44512e7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/tools/pginclude/README

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
src/tools/pginclude/README
22

3+
This directory contains some scripts and information for managing
4+
header files and includes in PostgreSQL source code.
5+
6+
7+
include-what-you-use
8+
====================
9+
10+
include-what-you-use (IWYU) (<https://include-what-you-use.org/>) is a
11+
tool for finding missing or superfluous includes in C source files.
12+
13+
With a compilation database (compile_commands.json, produced by
14+
meson), it can be run like this, over the whole source tree:
15+
16+
iwyu_tool.py -p build .
17+
18+
(this will likely be very noisy) or for individual files:
19+
20+
iwyu_tool.py -p build src/bin/psql/startup.c
21+
22+
Various other invocation options are available.
23+
24+
It is recommended to use at least version 0.23. Earlier versions give
25+
advice that is incompatible with the compiler warning option
26+
-Wmissing-variable-declarations.
27+
28+
clangd (the language server) can automatically give IWYU-style advice;
29+
see <https://clangd.llvm.org/guides/include-cleaner>.
30+
31+
The source code contains some "IWYU pragma" comments to tell IWYU
32+
about some PostgreSQL include file conventions (such as that a header
33+
such as "postgres.h" should always be included, even if it doesn't
34+
contribute any symbols used by the particular source file) and to
35+
silence a few warnings that are difficult to fix. See
36+
<https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md>
37+
for documentation about those.
38+
39+
Of course, any include changes suggested by this or other tools should
40+
be checked and verified carefully. Note that some includes are only
41+
used on some platforms or with some compilation options, so blindly
42+
following the produced advice is not recommended.
43+
44+
345
headerscheck
446
============
547

0 commit comments

Comments
 (0)