Skip to content

clang-include-cleaner: Consider supporting IWYU pragma: no_include #89989

Open
@crisluengo

Description

@crisluengo

According to the documentation for clang-include-cleaner at https://clangd.llvm.org/design/include-cleaner#iwyu-pragmas, the IWYU pragma no_include is not supported (and I see it not having an effect in my IDE).

Plenty of libraries are designed for the user to include a single header file, not any of the private implementation files, but don't have any IWYU pragmas to indicate this to clang-tidy. And let's be honest, it'll be a long time before all software is making good use of IWYU pragmas.

As a user of these libraries, we can either turn off the misc-include-cleaner test in clang-tidy, or try to ignore the warnings in the IDE. Neither is ideal. If the library is open-source, of course, we could also submit a PR to the library in the hopes the owner cares. Currently the only way to suppress the warning is to add // NOLINT(*-include-cleaner) to each line that uses functionality from this library. This is of course highly impractical.

A simple and practical solution for the user would be to add // IWYU pragma: no_include "library/private/*" to the source file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-include-cleanerconfirmedVerified by a second partyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions