mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
When the -p option is given to clang-tidy, it doesn't need the compile command line to be appended. It can get everything it needs from the compile_commands.json file in the directory specified with the -p option. When the compiler being used is not the system default compiler, clang-tidy has been observed to pick up the wrong headers when the compiler command line is given, but not if only the -p option is used. Therefore, don't append the compiler command line if -p is present in the <LANG>_CLANG_TIDY target property. Fixes: #24017
31 lines
819 B
C
31 lines
819 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int i;
|
|
for (i = 1; i < argc; ++i) {
|
|
if (strcmp(argv[i], "-p") == 0) {
|
|
// Ensure compile commands were not appended after the source file
|
|
for (++i; i < argc; ++i) {
|
|
if (strcmp(argv[i], "--") == 0) {
|
|
fprintf(stderr, "Command line arguments unexpectedly appended\n");
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
if (strcmp(argv[i], "-bad") == 0) {
|
|
fprintf(stdout, "stdout from bad command line arg '-bad'\n");
|
|
fprintf(stderr, "stderr from bad command line arg '-bad'\n");
|
|
return 1;
|
|
}
|
|
if (argv[i][0] != '-') {
|
|
fprintf(stdout, "%s:0:0: warning: message [checker]\n", argv[i]);
|
|
break;
|
|
}
|
|
}
|
|
fprintf(stderr, "1 warning generated.\n");
|
|
return 0;
|
|
}
|