Issue 243520
Summary clang-tidy bugprone macro-condition test depends on host <sys/file.h> working
Labels clang-tidy
Assignees
Reporter statham-arm
    The test file `clang-tools-extra/test/clang-tidy/checkers/bugprone/macro-condition.cpp`, added by #210768 recently, can fail to compile if clang-tidy's default target architecture doesn't match the host, because the test includes the real `<sys/file.h>` and depends on that header working.

The include is in this snippet, apparently intended to check that the `__has_include` test doesn't trigger spurious warnings about the identifiers making up the include file name being undefined macros:
```c++
#if __has_include(<sys/file.h>)
#include <sys/file.h>
#endif
// CHECK-MESSAGES-NOT: warning: Undefined macro 'sys' checked here for value
// CHECK-MESSAGES-NOT: warning: Undefined macro 'file' checked here for value
// CHECK-MESSAGES-NOT: warning: Undefined macro 'h' checked here for value
```

The problem is that it _really_ includes the host's `sys/file.h`, if present, even if that's not appropriate to the set of enabled targets in clang (e.g. if it's being built entirely as a cross-compiler). As far as I can see, including that header isn't important to what's being tested.

In one of our builds of Arm Toolchain for Embedded, this manifests as a build failure:
```
# | /usr/include/gnu/stubs.h:7:11: error: 'gnu/stubs-32.h' file not found [clang-diagnostic-error]
# |     7 | # include <gnu/stubs-32.h>
# |       | ^~~~~~~~~~~~~~~~
```
because `gnu/stubs.h` (included indirectly from `sys/file.h`) has checked the compiler-defined macros to decide whether to include `stubs-64.h` or `stubs-32.h` and decided on one that our build machine didn't have installed.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to