Skip to content

[clang-tidy] misc-include-cleaner does not handle error codes in <errno.h> #134818

@abdelmaged

Description

@abdelmaged

Source C File:

#include <errno.h>
#include <stdio.h>

static void testErrno(void) {
  if (errno == EEXIST) {
    puts("Already Exists!");
  }
}

Using clang-tidy misc-include-cleaner:

<source>:5:16: warning: no header providing "EEXIST" is directly included [misc-include-cleaner]
    1 | #include <errno.h>
    2 | #include <stdio.h>
    3 | 
    4 | static void testErrno(void) {
    5 |   if (errno == EEXIST) {
      |                ^
1 warning generated.

Issue also reproducible in this link:
https://godbolt.org/z/xMo84z8oz

clang-tidy version: 20.1.1
This warning was not produced in 18.1.6

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