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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361790
91177308-0d34-0410-b5e6-
96231b3b80d8
clangBasic
clangLex
)
+
+add_subdirectory(plugins)
--- /dev/null
+if(LLVM_ENABLE_PLUGINS)
+ add_subdirectory(SampleAnalyzer)
+ add_subdirectory(CheckerDependencyHandling)
+ add_subdirectory(CheckerOptionHandling)
+endif()
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
+ )
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
+ )
--- /dev/null
+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
+ )
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
+++ /dev/null
-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})
+++ /dev/null
-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()
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})