On Nix the LLVM analysis tools (clangd, clang-tidy, clang-check, include-what-you-use and others) need two things to work correctly: they need find the standard library headers at all, and they need to find same standard library the build uses (libc++ vs libstdc++). This PR makes the tools resolve the right headers on their own in every context they run in: editors, command line, and CI.
PR was motivated by recent discussion: #296#pullrequestreview-4839484696 and includes documentation improvements, new IWYU changes, and an old clang-tools change I've been using for a long time locally.
Specifically the PR:
- puts the header-aware clang-tools binaries ahead of the raw clang ones on
PATH, so clangd/clang-tidy/clang-check find the standard library on their own; - binds IWYU to the shell's compiler so it analyzes the same standard library the build uses in any context;
- provides IWYU only in the non-minimal shells that actually run it; and
- updates the comment on the build's
CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIESworkaround — which injects these header paths into the compile database when clang-tidy or IWYU are enabled — to note that clang-tidy no longer needs it and IWYU still does.
Details are in commit messages.