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/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,7 +45,6 @@ clang-move clang-query clang-reorder-fields - clang-tidy find-all-symbols modularize pp-trace @@ -56,6 +53,17 @@ ExtraToolsUnitTests ) +if(CLANG_ENABLE_STATIC_ANALYZER) + list(APPEND CLANG_TOOLS_TEST_DEPS + # For the clang-tidy libclang integration test. + c-index-test + # clang-tidy tests require it. + clang-headers + + clang-tidy + ) +endif() + set(llvm_utils FileCheck count not ) 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/lit.cfg =================================================================== --- clang-tools-extra/trunk/test/lit.cfg +++ clang-tools-extra/trunk/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: 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/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)