Issue |
100909
|
Summary |
[clang-tidy 20] `warning: argument unused during compilation: '-c'` when using compilation database
|
Labels |
|
Assignees |
|
Reporter |
zufuliu
|
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>
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs