<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100909>100909</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy 20] `warning: argument unused during compilation: '-c'` when using compilation database
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zufuliu
</td>
</tr>
</table>
<pre>
This is regression from clang-tidy 18 and 19, with clang-tidy build from today's main (at bbc457a4f40328452f0c8c8f9b0b5fcb8d286a7b).
test.cpp:
```cpp
#include <stdio.h>
int main() {
return printf("Hello, world!\n");
}
```
compile_commands.json:
```json
[
{
"directory": "D:\\test",
"command": "clang++.exe -c D:\\test\\test.cpp",
"file": "D:\\test\\test.cpp"
}
]
```
output:
```
D:\test>clang-tidy test.cpp
1 warning generated.
warning: argument unused during compilation: '-c' [clang-diagnostic-unused-command-line-argument]
D:\test>clang-tidy -checks=* test.cpp
9508 warnings generated.
warning: argument unused during compilation: '-c' [clang-diagnostic-unused-command-line-argument]
D:\test\test.cpp:1:1: warning: system include stdio.h not allowed [llvmlibc-restrict-system-libc-headers]
1 | #include <stdio.h>
| ^~~~~~~~~~~~~~~~~~
2 | int main() {
D:\test\test.cpp:1:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead [hicpp-deprecated-headers,modernize-deprecated-headers]
1 | #include <stdio.h>
| ^
note: this fix will not be applied because it overlaps with another fix
D:\test\test.cpp:2:5: warning: declaration must be enclosed within the 'LIBC_NAMESPACE_DECL' namespace [llvmlibc-implementation-in-namespace]
2 | int main() {
| ^
D:\test\test.cpp:2:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
2 | int main() {
| ~~~ ^
| auto -> int
D:\test\test.cpp:3:9: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg,hicpp-vararg]
3 | return printf("Hello, world!\n");
| ^
Suppressed 9500 warnings (9500 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.
D:\test>
```
Same behavior after change `command` to `clang-cl.exe /c D:\\test\\test.cpp`:
```
D:\test>clang-tidy test.cpp
1 warning generated.
warning: argument unused during compilation: '/c' [clang-diagnostic-unused-command-line-argument]
D:\test>clang-tidy -checks=* test.cpp
9508 warnings generated.
warning: argument unused during compilation: '/c' [clang-diagnostic-unused-command-line-argument]
D:\test\test.cpp:1:1: warning: system include stdio.h not allowed [llvmlibc-restrict-system-libc-headers]
1 | #include <stdio.h>
| ^~~~~~~~~~~~~~~~~~
2 | int main() {
D:\test\test.cpp:1:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead [hicpp-deprecated-headers,modernize-deprecated-headers]
1 | #include <stdio.h>
| ^
note: this fix will not be applied because it overlaps with another fix
D:\test\test.cpp:2:5: warning: declaration must be enclosed within the 'LIBC_NAMESPACE_DECL' namespace [llvmlibc-implementation-in-namespace]
2 | int main() {
| ^
D:\test\test.cpp:2:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
2 | int main() {
| ~~~ ^
| auto -> int
D:\test\test.cpp:3:9: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg,hicpp-vararg]
3 | return printf("Hello, world!\n");
| ^
Suppressed 9500 warnings (9500 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.
D:\test>
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWEuP27YT_zT0ZSBDoixbOviwfiz-fyAtCqQ9BxQ5sphSpEBSu3EO-9kLUvJjneymSS9Bu4L34SFn-PvNkzZzTh404poUG1LsZmzwrbHrz0MzKDnMaiOO699b6UA6sHiw6Jw0GhprOuCK6UPipThCVgLTArKK0C08St9eL9aDVGJU8UawI6ErBx2TGggtmYe65otixRbNIs1puShok_KSl01Vp3XR8LoUtFyyVU1oNSfpjqR342-Pzs9535N8EpBlOr6CcJTQXGquB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