[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
This revision was automatically updated to reflect the committed changes. Closed by commit rL311983: [cmake] Support running extra clang tool tests without static analyzer (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D37188?vs=112811=113024#toc Repository: rL LLVM https://reviews.llvm.org/D37188 Files: clang-tools-extra/trunk/CMakeLists.txt clang-tools-extra/trunk/test/CMakeLists.txt clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp clang-tools-extra/trunk/test/lit.cfg clang-tools-extra/trunk/test/lit.site.cfg.in clang-tools-extra/trunk/unittests/CMakeLists.txt Index: clang-tools-extra/trunk/CMakeLists.txt === --- clang-tools-extra/trunk/CMakeLists.txt +++ clang-tools-extra/trunk/CMakeLists.txt @@ -15,8 +15,7 @@ add_subdirectory(tool-template) # Add the common testsuite after all the tools. -# TODO: Support tests with more granularity when features are off? -if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_INCLUDE_TESTS) +if(CLANG_INCLUDE_TESTS) add_subdirectory(test) add_subdirectory(unittests) endif() Index: clang-tools-extra/trunk/unittests/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/CMakeLists.txt @@ -9,6 +9,8 @@ add_subdirectory(clang-apply-replacements) add_subdirectory(clang-move) add_subdirectory(clang-query) -add_subdirectory(clang-tidy) +if(CLANG_ENABLE_STATIC_ANALYZER) + add_subdirectory(clang-tidy) +endif() add_subdirectory(clangd) add_subdirectory(include-fixer) Index: clang-tools-extra/trunk/test/lit.site.cfg.in === --- clang-tools-extra/trunk/test/lit.site.cfg.in +++ clang-tools-extra/trunk/test/lit.site.cfg.in @@ -10,6 +10,7 @@ config.clang_libs_dir = "@SHLIBDIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.target_triple = "@TARGET_TRIPLE@" +config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. Index: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp === --- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp +++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp @@ -1,23 +1,24 @@ +// REQUIRES: static-analyzer // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-include-fixer -fspell-checking -Xclang -plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 | FileCheck %s foo f; foo g; unknown u; -// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo" -// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Insert "#include "foo.h" // CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 'foo'? // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo" // CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Insert "#include "foo.h" -// CHECK: " at 3:1 -// CHECK: yamldb_plugin.cpp:5:1: +// CHECK: yamldb_plugin.cpp:5:1: error: unknown type name 'foo'; did you mean 'foo'? +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Replace [5:1 - 5:4] with "foo" +// CHECK: yamldb_plugin.cpp:5:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Insert "#include "foo.h" +// CHECK: " at 4:1 +// CHECK: yamldb_plugin.cpp:6:1: // CHECK: error: unknown type name 'unknown' // CHECK: Number FIX-ITs = 0 // CHECK-NOT: error Index: clang-tools-extra/trunk/test/CMakeLists.txt === --- clang-tools-extra/trunk/test/CMakeLists.txt +++ clang-tools-extra/trunk/test/CMakeLists.txt @@ -15,6 +15,9 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +llvm_canonicalize_cmake_booleans( + CLANG_ENABLE_STATIC_ANALYZER) + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @@ -31,11 +34,6 @@ endif() set(CLANG_TOOLS_TEST_DEPS - # clang-tidy tests require it. - clang-headers - - # For the clang-tidy libclang integration test. - c-index-test # For the clang-apply-replacements test that uses clang-rename. clang-rename @@ -47,15 +45,25 @@ clang-move clang-query clang-reorder-fields - clang-tidy find-all-symbols
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny added a comment. Thanks for the clarification. Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D37188#854144, @mgorny wrote: > I might be missing something but currently clang-tidy is not built at all > when static analyzer is disabled. Yes, but it could be built except for the parts that actually need the static analyzer. As I've said, this would require careful surgery of ClangTidy.cpp and of some other files. We can do that later. LG Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny added a comment. I might be missing something but currently clang-tidy is not built at all when static analyzer is disabled. Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
alexfh added a comment. IIUC, these are the only clang-tidy tests that need static analyzer: clang/tools/extra/test/clang-tidy/nolint.cpp clang/tools/extra/test/clang-tidy/static-analyzer.cpp clang/tools/extra/test/clang-tidy/static-analyzer-config.cpp clang/tools/extra/test/clang-tidy/temporaries.cpp as well as the mpi module and its tests: clang/tools/extra/clang-tidy/mpi/* clang/tools/extra/test/clang-tidy/mpi-buffer-deref.cpp clang/tools/extra/test/clang-tidy/mpi-type-mismatch.cpp Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
alexfh added a comment. This could be done even more granularly, since clang-tidy only needs static analyzer to run clang-analyzer-* checks. But that would involve some careful #ifdef-ing of the parts of clang-tidy/ClangTidy.cpp, so I'll understand if you say you have little interest in this. Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny added inline comments. Comment at: test/include-fixer/yamldb_plugin.cpp:7 -// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? -// CHECK: Number FIX-ITs = 1 Differential is showing this a bit weird, all that's changed here and below are adjusted line numbers. Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny created this revision. Support running the extra clang tool tests when the static analyzer is disabled. Disable the relevant clang-tidy tests and one include-fixer test that require it to work. Previously, the tests were disabled entirely with CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being enabled and the relevant tests are excluded and marked unsupported appropriately. In order to disable clang-tidy tests, the whole test directory is added to the exclude lists, to avoid having to explicitly add 'REQUIRES' line to every single test. If the other solution is preferable, I can update the patch. The yamldb_plugin include-fixer test is also updated to be disabled without static analyzer. It fails in that case because clang is not outputting a replacement suggestion -- but I don't know the exact reason why it does not do that. Repository: rL LLVM https://reviews.llvm.org/D37188 Files: CMakeLists.txt test/CMakeLists.txt test/include-fixer/yamldb_plugin.cpp test/lit.cfg test/lit.site.cfg.in unittests/CMakeLists.txt Index: unittests/CMakeLists.txt === --- unittests/CMakeLists.txt +++ unittests/CMakeLists.txt @@ -9,6 +9,8 @@ add_subdirectory(clang-apply-replacements) add_subdirectory(clang-move) add_subdirectory(clang-query) -add_subdirectory(clang-tidy) +if(CLANG_ENABLE_STATIC_ANALYZER) + add_subdirectory(clang-tidy) +endif() add_subdirectory(clangd) add_subdirectory(include-fixer) Index: test/lit.site.cfg.in === --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -10,6 +10,7 @@ config.clang_libs_dir = "@SHLIBDIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.target_triple = "@TARGET_TRIPLE@" +config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -192,13 +192,18 @@ if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') -check_clang_tidy = os.path.join( -config.test_source_root, "clang-tidy", "check_clang_tidy.py") -config.substitutions.append( -('%check_clang_tidy', - '%s %s' % (config.python_executable, check_clang_tidy)) ) -clang_tidy_diff = os.path.join( -config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py") -config.substitutions.append( -('%clang_tidy_diff', - '%s %s' % (config.python_executable, clang_tidy_diff)) ) +if config.clang_staticanalyzer: +config.available_features.add('static-analyzer') +check_clang_tidy = os.path.join( +config.test_source_root, "clang-tidy", "check_clang_tidy.py") +config.substitutions.append( +('%check_clang_tidy', + '%s %s' % (config.python_executable, check_clang_tidy)) ) +clang_tidy_diff = os.path.join( +config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py") +config.substitutions.append( +('%clang_tidy_diff', + '%s %s' % (config.python_executable, clang_tidy_diff)) ) +else: +# exclude the clang-tidy test directory +config.excludes.append('clang-tidy') Index: test/include-fixer/yamldb_plugin.cpp === --- test/include-fixer/yamldb_plugin.cpp +++ test/include-fixer/yamldb_plugin.cpp @@ -1,23 +1,24 @@ +// REQUIRES: static-analyzer // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-include-fixer -fspell-checking -Xclang -plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 | FileCheck %s foo f; foo g; unknown u; -// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo" -// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Insert "#include "foo.h" // CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 'foo'? // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo" // CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Insert "#include "foo.h" -// CHECK: " at 3:1 -// CHECK: yamldb_plugin.cpp:5:1: +// CHECK: yamldb_plugin.cpp:5:1: error: unknown type name 'foo'; did you mean 'foo'? +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Replace [5:1 - 5:4] with "foo" +// CHECK: yamldb_plugin.cpp:5:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] +// CHECK: Number FIX-ITs = 1 +//