llvm / llvm/llvm-project

misc-include-cleaner false positive

Open
#190,831 4 comments 0 reactions 0 assignees View on GitHub
clang-tidy confirmed false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```
> clang-tidy -checks='*,-llvmlibc-restrict-system-libc-headers,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-altera-unroll-loops,-concurrency-mt-unsafe,-altera-id-dependent-backward-branch,-readability-function-cognitive-complexity,-*-magic-numbers,-cppcoreguidelines-avoid-non-const-global-variables' vector.c
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "vector.c"
No compilation database found in /u/talib or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
3771 warnings generated.
/u/talib/vector.c:7:1: warning: included header getopt.h is not used directly [misc-include-cleaner]
7 | #include
| ^~~~~~~~~~~~~~~~~~~
8 | #include
/u/talib/vector.c:56:23: warning: no header providing "getopt" is directly included [misc-include-cleaner]
4 | while ((opt = getopt(argc, argv, OPTIONS)) != -1) {
| ^
/u/talib/vector.c:59:35: warning: no header providing "optarg" is directly included [misc-include-cleaner]
59 | ifile = fopen(optarg, "re");
| ^
Suppressed 3768 warnings (3768 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the shown clang-tidy command against vector.c and examine the conflicting misc-include-cleaner diagnostics for getopt.h, getopt, and optarg. Trace the check's handling of these includes and review any existing regression tests; done means the reproducer no longer reports the false positive.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.