[test] Fix plugin tests
authorDon Hinton <hintonda@gmail.com>
Tue, 28 May 2019 06:26:58 +0000 (06:26 +0000)
committerDon Hinton <hintonda@gmail.com>
Tue, 28 May 2019 06:26:58 +0000 (06:26 +0000)
Summary:
The following changes were required to fix these tests:

1) Change LLVM_ENABLE_PLUGINS to an option and move it to
   llvm/CMakeLists.txt with an appropriate default -- which matches
   the original default behavior.

2) Move the plugins directory from clang/test/Analysis
   clang/lib/Analysis.  It's not enough to add an exclude to the
   lit.local.cfg file because add_lit_testsuites recurses the tree and
   automatically adds the appropriate `check-` targets, which don't
   make sense for the plugins because they aren't tests and don't
   have `RUN` statements.

   Here's a list of the `clang-check-anlysis*` targets with this
   change:

```
  $ ninja -t targets all| sed -n "s/.*\/\(check[^:]*\):.*/\1/p" | sort -u | grep clang-analysis
  check-clang-analysis
  check-clang-analysis-checkers
  check-clang-analysis-copypaste
  check-clang-analysis-diagnostics
  check-clang-analysis-engine
  check-clang-analysis-exploration_order
  check-clang-analysis-html_diagnostics
  check-clang-analysis-html_diagnostics-relevant_lines
  check-clang-analysis-inlining
  check-clang-analysis-objc
  check-clang-analysis-unified-sources
  check-clang-analysis-z3
```

3) Simplify the logic and only include the subdirectories under
   clang/lib/Analysis/plugins if LLVM_ENABLE_PLUGINS is set.

Reviewed By: NoQ

Tags: #clang, #llvm

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

llvm-svn: 361790

17 files changed:
clang/lib/Analysis/CMakeLists.txt
clang/lib/Analysis/plugins/CMakeLists.txt [new file with mode: 0644]
clang/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt [moved from clang/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt with 51% similarity]
clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp [moved from clang/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp with 100% similarity]
clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports [moved from clang/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports with 100% similarity]
clang/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt [moved from clang/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt with 50% similarity]
clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp [moved from clang/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp with 100% similarity]
clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports [moved from clang/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports with 100% similarity]
clang/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt [new file with mode: 0644]
clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp [moved from clang/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp with 100% similarity]
clang/lib/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports [moved from clang/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports with 100% similarity]
clang/test/Analysis/lit.local.cfg
clang/test/Analysis/plugins/CMakeLists.txt [deleted file]
clang/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt [deleted file]
clang/test/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake

index 940a3df..9271714 100644 (file)
@@ -34,3 +34,5 @@ add_clang_library(clangAnalysis
   clangBasic
   clangLex
   )
+
+add_subdirectory(plugins)
diff --git a/clang/lib/Analysis/plugins/CMakeLists.txt b/clang/lib/Analysis/plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f7dbc93
--- /dev/null
@@ -0,0 +1,5 @@
+if(LLVM_ENABLE_PLUGINS)
+  add_subdirectory(SampleAnalyzer)
+  add_subdirectory(CheckerDependencyHandling)
+  add_subdirectory(CheckerOptionHandling)
+endif()
@@ -1,11 +1,10 @@
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
 add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
-    clangAnalysis
-    clangAST
-    clangStaticAnalyzerCore
-    LLVMSupport
-    )
-endif()
+target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
+  clangAnalysis
+  clangAST
+  clangStaticAnalyzerCore
+  clangStaticAnalyzerFrontend
+  LLVMSupport
+  )
@@ -1,11 +1,10 @@
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
 add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE CheckerOptionHandling.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
-    clangAnalysis
-    clangAST
-    clangStaticAnalyzerCore
-    LLVMSupport
-    )
-endif()
+target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
+  clangAnalysis
+  clangAST
+  clangStaticAnalyzerCore
+  clangStaticAnalyzerFrontend
+  LLVMSupport
+  )
diff --git a/clang/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt b/clang/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
new file mode 100644 (file)
index 0000000..639a97f
--- /dev/null
@@ -0,0 +1,10 @@
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
+add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang)
+
+target_link_libraries(SampleAnalyzerPlugin PRIVATE
+  clangAnalysis
+  clangAST
+  clangStaticAnalyzerCore
+  clangStaticAnalyzerFrontend
+  LLVMSupport
+  )
index b77cae8..84f7569 100644 (file)
@@ -18,7 +18,5 @@ config.substitutions.append(('%diff_plist',
 config.substitutions.append(('%diff_sarif',
     '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I "2\.0\.0\-csd\.[0-9]*\.beta\."'''))
 
-config.excludes.add('plugins')
-
 if not config.root.clang_staticanalyzer:
     config.unsupported = True
diff --git a/clang/test/Analysis/plugins/CMakeLists.txt b/clang/test/Analysis/plugins/CMakeLists.txt
deleted file mode 100644 (file)
index 8d4333f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-add_subdirectory(SampleAnalyzer)
-add_subdirectory(CheckerDependencyHandling)
-add_subdirectory(CheckerOptionHandling)
-
-set(CLANG_ANALYZER_PLUGIN_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-
-add_custom_target(clang-analyzer-plugin
-  DEPENDS ${CLANG_ANALYZER_PLUGIN_DEPS})
diff --git a/clang/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt b/clang/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
deleted file mode 100644 (file)
index 7c7b2ae..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
-add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang)
-
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(SampleAnalyzerPlugin PRIVATE
-    clangAnalysis
-    clangAST
-    clangStaticAnalyzerCore
-    LLVMSupport
-    )
-endif()
index 339f637..32fe571 100644 (file)
@@ -126,27 +126,13 @@ if( NOT CLANG_BUILT_STANDALONE )
 endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(Analysis/plugins)
-  list(APPEND CLANG_TEST_DEPS clang-analyzer-plugin)
-
-  # check-all would launch those tests via check-clang.
-  set(EXCLUDE_FROM_ALL ON)
-
-  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")
-
-  if (LLVM_WITH_Z3)
-    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")
+  if (LLVM_ENABLE_PLUGINS)
+    set(CLANG_ANALYZER_PLUGIN_DEPS
+      SampleAnalyzerPlugin
+      CheckerDependencyHandlingAnalyzerPlugin
+      CheckerOptionHandlingAnalyzerPlugin
+      )
   endif()
-
-  set(EXCLUDE_FROM_ALL OFF)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
index 895f9ab..6ca7b6d 100644 (file)
@@ -672,6 +672,17 @@ set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
 message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(WIN32 OR CYGWIN)
+  if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
+    set(LLVM_ENABLE_PLUGINS_default ON)
+  else()
+    set(LLVM_ENABLE_PLUGINS_default OFF)
+  endif()
+else()
+  set(LLVM_ENABLE_PLUGINS_default ON)
+endif()
+option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default})
+
 include(HandleLLVMOptions)
 
 # Verify that we can find a Python 2 interpreter.  Python 3 is unsupported.
index cb9a01e..8e7c93c 100644 (file)
@@ -912,14 +912,6 @@ if(LLVM_LINK_LLVM_DYLIB AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
   message(FATAL_ERROR "LLVM_LINK_LLVM_DYLIB not compatible with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS")
 endif()
 
-# Plugin support
-# FIXME: Make this configurable.
-if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
-  set(LLVM_ENABLE_PLUGINS ON)
-else()
-  set(LLVM_ENABLE_PLUGINS OFF)
-endif()
-
 # By default we should enable LLVM_ENABLE_IDE only for multi-configuration
 # generators. This option disables optional build system features that make IDEs
 # less usable.