diff options
author | Brad King <brad.king@kitware.com> | 2022-10-07 15:19:55 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-10-07 15:20:03 (GMT) |
commit | a07be2ffd18a03cc30153f8bafbe47f8e640eb44 (patch) | |
tree | 741906773394f23827506ef5ed656651758c57ce /Tests | |
parent | 5f9994a6c1abe28522c1fd21783f4d3d60a8f3fb (diff) | |
parent | 3f4e0839c48480b0cb3396ddbcadef25e69854ee (diff) | |
download | CMake-a07be2ffd18a03cc30153f8bafbe47f8e640eb44.zip CMake-a07be2ffd18a03cc30153f8bafbe47f8e640eb44.tar.gz CMake-a07be2ffd18a03cc30153f8bafbe47f8e640eb44.tar.bz2 |
Merge topic 'clang-tidy-prefer-p-option'
3f4e0839c4 clang-tidy: Don't append compiler commands if using -p
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7753
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/ClangTidy/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/compdb.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/pseudo_tidy.c | 10 |
3 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake index ee41d94..5e3fbc4 100644 --- a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake +++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake @@ -29,3 +29,4 @@ if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") endif() endif() run_tidy(C-bad) +run_tidy(compdb) diff --git a/Tests/RunCMake/ClangTidy/compdb.cmake b/Tests/RunCMake/ClangTidy/compdb.cmake new file mode 100644 index 0000000..f83e0ae --- /dev/null +++ b/Tests/RunCMake/ClangTidy/compdb.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +# Include a --checks option to confirm that we don't match options that start +# with --, only a standalone -- +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -p ${CMAKE_BINARY_DIR} --checks=*) + +add_executable(main main.c) diff --git a/Tests/RunCMake/pseudo_tidy.c b/Tests/RunCMake/pseudo_tidy.c index 2feeb0f..a43133b 100644 --- a/Tests/RunCMake/pseudo_tidy.c +++ b/Tests/RunCMake/pseudo_tidy.c @@ -5,6 +5,16 @@ 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"); |