r360891 - Reland "[analyzer] Add an example plugin for checker dependency handling"

Kristof Umann via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 06:22:04 PDT 2019


Author: szelethus
Date: Thu May 16 06:22:04 2019
New Revision: 360891

URL: http://llvm.org/viewvc/llvm-project?rev=360891&view=rev
Log:
Reland "[analyzer] Add an example plugin for checker dependency handling"

Buildbots complained that they couldn't find the newly added plugins.

The solution was to move the check-clang cmake target closer to the bottom of
the file, after the new dependencies are added.

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

Added:
    cfe/trunk/test/Analysis/plugins/
      - copied from r360804, cfe/trunk/test/Analysis/plugins/
Removed:
    cfe/trunk/examples/analyzer-plugin/
Modified:
    cfe/trunk/examples/CMakeLists.txt
    cfe/trunk/test/Analysis/checker-plugins.c
    cfe/trunk/test/Analysis/lit.local.cfg
    cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/examples/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/CMakeLists.txt?rev=360891&r1=360890&r2=360891&view=diff
==============================================================================
--- cfe/trunk/examples/CMakeLists.txt (original)
+++ cfe/trunk/examples/CMakeLists.txt Thu May 16 06:22:04 2019
@@ -3,9 +3,6 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
-add_subdirectory(analyzer-plugin)
-endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)

Modified: cfe/trunk/test/Analysis/checker-plugins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-plugins.c?rev=360891&r1=360890&r2=360891&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/checker-plugins.c (original)
+++ cfe/trunk/test/Analysis/checker-plugins.c Thu May 16 06:22:04 2019
@@ -1,5 +1,8 @@
-// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext -analyzer-checker='example.MainCallChecker' -verify %s
-// REQUIRES: plugins, examples
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
+// RUN:   -analyzer-checker='example.MainCallChecker'
+
+// REQUIRES: plugins
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -8,3 +11,22 @@ int main();
 void caller() {
   main(); // expected-warning {{call to main}}
 }
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: example.Dependency
+// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-disable-checker=example.Dependency \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
+// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker

Modified: cfe/trunk/test/Analysis/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=360891&r1=360890&r2=360891&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/lit.local.cfg Thu May 16 06:22:04 2019
@@ -18,5 +18,7 @@ config.substitutions.append(('%diff_plis
 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

Modified: cfe/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=360891&r1=360890&r2=360891&view=diff
==============================================================================
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu May 16 06:22:04 2019
@@ -123,19 +123,10 @@ if( NOT CLANG_BUILT_STANDALONE )
   endif()
 endif()
 
-add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
-set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
-
-add_lit_testsuite(check-clang "Running the Clang regression tests"
-  ${CMAKE_CURRENT_BINARY_DIR}
-  #LIT ${LLVM_LIT}
-  PARAMS ${CLANG_TEST_PARAMS}
-  DEPENDS ${CLANG_TEST_DEPS}
-  ARGS ${CLANG_TEST_EXTRA_ARGS}
-  )
-set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
-
 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)
 
@@ -145,7 +136,6 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
     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
@@ -157,6 +147,18 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
   set(EXCLUDE_FROM_ALL OFF)
 endif()
 
+add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
+set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
+
+add_lit_testsuite(check-clang "Running the Clang regression tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  #LIT ${LLVM_LIT}
+  PARAMS ${CLANG_TEST_PARAMS}
+  DEPENDS ${CLANG_TEST_DEPS}
+  ARGS ${CLANG_TEST_EXTRA_ARGS}
+  )
+set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
+
 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
   PARAMS ${CLANG_TEST_PARAMS}
   DEPENDS ${CLANG_TEST_DEPS}




More information about the cfe-commits mailing list