我正在使用以下文件来尝试clang-tidy
:
#include <stdio.h>
int main(int argc, char **argv)
{
int i=2; int j=1;
if (argc = 5) { return 2; }
while (i<argc) { j++; }
return 0;
}
我旨在通过以下方式检测无限循环:
$ clang-tidy -checks=bugprone-infinite-loop main.c
但是clang-tidy
发现的只是=
而不是==
:
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "main.c"
No compilation database found in /home/oren 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.
1 warning generated.
/home/oren/main.c:6:11: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
if (argc = 5) { return 2; }
~~~~ ^ ~
( == )
/home/oren/main.c:6:11: note: place parentheses around the assignment to silence this warning
/home/oren/main.c:6:11: note: use '==' to turn this assignment into an equality comparison
您正在使用尚未发布的LLVM(10.0.0)版本中的功能。
在我的系统上(Windows),您的文件可以正常工作: