|
1 | 1 | src/tools/pginclude/README
|
2 | 2 |
|
| 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 | + |
3 | 45 | headerscheck
|
4 | 46 | ============
|
5 | 47 |
|
|
0 commit comments