Skip to content

[clang-tidy] misc-include-cleaner incompatible with modernize-deprecated-headers ? #76567

@Zitrax

Description

@Zitrax

I have not found any way to fix code like this without suppressing with NOLINT or similar.

#include <iostream>

// Including this triggers:
//   inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead [modernize-deprecated-headers]
#include <string.h>

// Including this instead triggers:
//   no header providing "strsignal" is directly included [misc-include-cleaner]
#include <cstring>

int main() {
    std::cout << strsignal(2) << "\n";
    return 0;
}

The warning from modernize-deprecated-headers makes sense but shouldn't misc-include-headers allow using the modern C++ headers like cstring here without warning?

Godbolt example: https://godbolt.org/z/5TxEvK3P6

Tested with clang-tidy 17.0.6 and 18.0.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions