Index: clang/test/Analysis/analyzer_test.py =================================================================== --- clang/test/Analysis/analyzer_test.py +++ clang/test/Analysis/analyzer_test.py @@ -4,6 +4,10 @@ # Custom format class for static analyzer tests class AnalyzerTest(lit.formats.ShTest): + def __init__(self, execute_external, z3_enabled=False): + super(AnalyzerTest, self).__init__(execute_external) + self.z3_enabled = z3_enabled + def execute(self, test, litConfig): results = [] @@ -19,7 +23,7 @@ return results[-1] # If z3 backend available, add an additional run line for it - if test.config.clang_staticanalyzer_z3 == '1': + if self.z3_enabled == '1' and test.config.clang_staticanalyzer_z3 == '1': results.append(self.executeWithAnalyzeSubstitution( saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')) Index: clang/test/Analysis/lit.local.cfg =================================================================== --- clang/test/Analysis/lit.local.cfg +++ clang/test/Analysis/lit.local.cfg @@ -7,7 +7,7 @@ site.addsitedir(os.path.dirname(__file__)) import analyzer_test config.test_format = analyzer_test.AnalyzerTest( - config.test_format.execute_external) + config.test_format.execute_external, config.z3_enabled) if not config.root.clang_staticanalyzer: config.unsupported = True Index: clang/test/CMakeLists.txt =================================================================== --- clang/test/CMakeLists.txt +++ clang/test/CMakeLists.txt @@ -88,8 +88,15 @@ set(CLANG_TEST_PARAMS clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + Z3_ENABLED=0 ) +set(ANALYZER_TEST_PARAMS + Z3_ENABLED=0) + +set(ANALYZER_TEST_PARAMS_Z3 + Z3_ENABLED=1) + if( NOT CLANG_BUILT_STANDALONE ) list(APPEND CLANG_TEST_DEPS llvm-config @@ -126,6 +133,22 @@ ) set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") +if (CLANG_ENABLE_STATIC_ANALYZER) + add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests" + ${CMAKE_CURRENT_BINARY_DIR}/Analysis + PARAMS ${ANALYZER_TEST_PARAMS} + DEPENDS ${CLANG_TEST_DEPS}) + set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests") + + + add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer tests, using Z3 as a solver" + ${CMAKE_CURRENT_BINARY_DIR}/Analysis + PARAMS ${ANALYZER_TEST_PARAMS_Z3} + DEPENDS ${CLANG_TEST_DEPS}) + set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER "Clang tests") + +endif() + add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR} PARAMS ${CLANG_TEST_PARAMS} DEPENDS ${CLANG_TEST_DEPS} Index: clang/test/lit.site.cfg.py.in =================================================================== --- clang/test/lit.site.cfg.py.in +++ clang/test/lit.site.cfg.py.in @@ -26,6 +26,7 @@ config.enable_backtrace = @ENABLE_BACKTRACES@ config.host_arch = "@HOST_ARCH@" config.python_executable = "@PYTHON_EXECUTABLE@" +config.z3_enabled = "@Z3_ENABLED@" # 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. @@ -34,6 +35,7 @@ config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params + config.z3_enabled = lit_config.params['Z3_ENABLED'] except KeyError: e = sys.exc_info()[1] key, = e.args