[clang-tools-extra] r311983 - [cmake] Support running extra clang tool tests without static analyzer

Michal Gorny via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 22:58:08 PDT 2017


Author: mgorny
Date: Mon Aug 28 22:58:08 2017
New Revision: 311983

URL: http://llvm.org/viewvc/llvm-project?rev=311983&view=rev
Log:
[cmake] Support running extra clang tool tests without static analyzer

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.

Differential Revision: https://reviews.llvm.org/D37188

Modified:
    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

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Mon Aug 28 22:58:08 2017
@@ -15,8 +15,7 @@ add_subdirectory(pp-trace)
 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()

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Mon Aug 28 22:58:08 2017
@@ -15,6 +15,9 @@ endif ()
 
 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 @@ if(CLANG_TOOLS_TEST_USE_VG)
 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 @@ set(CLANG_TOOLS_TEST_DEPS
   clang-move
   clang-query
   clang-reorder-fields
-  clang-tidy
   find-all-symbols
   modularize
   pp-trace
@@ -56,6 +53,17 @@ set(CLANG_TOOLS_TEST_DEPS
   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
   )

Modified: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp Mon Aug 28 22:58:08 2017
@@ -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

Modified: clang-tools-extra/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/lit.cfg (original)
+++ clang-tools-extra/trunk/test/lit.cfg Mon Aug 28 22:58:08 2017
@@ -192,13 +192,18 @@ if not platform.system() in ['Windows']
 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')

Modified: clang-tools-extra/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.site.cfg.in?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/lit.site.cfg.in (original)
+++ clang-tools-extra/trunk/test/lit.site.cfg.in Mon Aug 28 22:58:08 2017
@@ -10,6 +10,7 @@ config.clang_tools_dir = "@CLANG_TOOLS_D
 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.

Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=311983&r1=311982&r2=311983&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/CMakeLists.txt Mon Aug 28 22:58:08 2017
@@ -9,6 +9,8 @@ add_subdirectory(change-namespace)
 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)




More information about the cfe-commits mailing list