[llvm] Automatic removal of unused standard header (PR #192800)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 10:53:48 PDT 2026
serge-sans-paille wrote:
> Sorry if it's a stupid question - does the tool consider whether C/C++ library includes incidentally/indirectly are taking place?
It's not :-)
> In which case it might appear to be unused only because some other prior include pulled it in (for this particular C/C++ library implementation, for this particular version of it etc).
The algorithm of diskarzhañ is stupidly simple: each standard header is associated with the set of symbols it defines (e.g. `<vector>` only defines `std::vector`, although some implementation may bring in `<cstddef> for `std::size_t`). If a standard header is included but none of the symbol it defines is referenced in the same code, the include is removed.
https://github.com/llvm/llvm-project/pull/192800
More information about the llvm-commits
mailing list