Hi Jordan,

It should be possible to add a test for analyzer plugins using SampleAnalyzerPlugin now.

Can you suggest an invocation that loads and verifies that it works?

This should be testable now using the facilities I've checked in (assuming there's something in tree that knows how to load it).

Alp.


On 08/01/2014 11:38, Alp Toker wrote:
Author: alp
Date: Wed Jan  8 05:38:47 2014
New Revision: 198747

URL: http://llvm.org/viewvc/llvm-project?rev=198747&view=rev
Log:
Add tests for clang plugins

Somehow the entire plugin infrastructure went wholly untested until now.

The only plugins available for use in testing are the examples, so plugin tests
will only be run if CLANG_BUILD_EXAMPLES is enabled in the build.

(The examples should really be enabled by default, not just to aid testing but
also to prevent bitrot in some key user-facing code. I'll propose that
shortly.)

Requires supporting changes in LLVM r198746.

Added:
     cfe/trunk/test/Frontend/plugins.c
Modified:
     cfe/trunk/CMakeLists.txt
     cfe/trunk/test/lit.cfg
     cfe/trunk/test/lit.site.cfg.in

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=198747&r1=198746&r2=198747&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jan  8 05:38:47 2014
@@ -319,6 +319,10 @@ macro(add_clang_library name)
      add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
    endif()
+ if (MODULE)
+    set_property(TARGET ${name} PROPERTY SUFFIX ${LLVM_PLUGIN_EXT})
+  endif ()
+
    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
      install(TARGETS ${name}
        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}

Added: cfe/trunk/test/Frontend/plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugins.c?rev=198747&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/plugins.c (added)
+++ cfe/trunk/test/Frontend/plugins.c Wed Jan  8 05:38:47 2014
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns 
%s 2>&1 | FileCheck %s
+// REQUIRES: plugins, examples
+
+// CHECK: top-level-decl: "x"
+void x();

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=198747&r1=198746&r2=198747&view=diff
==============================================================================
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Wed Jan  8 05:38:47 2014
@@ -195,6 +195,22 @@ config.clang = inferClang(config.environ
  if not lit_config.quiet:
      lit_config.note('using clang: %r' % config.clang)
+# Plugins (loadable modules)
+# TODO: This should be supplied by Makefile or autoconf.
+if sys.platform in ['win32', 'cygwin']:
+    has_plugins = (config.enable_shared == 1)
+else:
+    has_plugins = True
+
+if has_plugins and config.llvm_plugin_ext:
+    config.available_features.add('plugins')
+
+config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
+config.substitutions.append( ('%pluginext', config.llvm_plugin_ext) )
+
+if config.clang_examples:
+    config.available_features.add('examples')
+
  # Note that when substituting %clang_cc1 also fill in the include directory of
  # the builtin headers. Those are part of even a freestanding environment, but
  # Clang relies on the driver to locate them.

Modified: cfe/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.in?rev=198747&r1=198746&r2=198747&view=diff
==============================================================================
--- cfe/trunk/test/lit.site.cfg.in (original)
+++ cfe/trunk/test/lit.site.cfg.in Wed Jan  8 05:38:47 2014
@@ -6,6 +6,8 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR
  config.llvm_obj_root = "@LLVM_BINARY_DIR@"
  config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
  config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
  config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
  config.clang_obj_root = "@CLANG_BINARY_DIR@"
  config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -14,6 +16,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_S
  config.clang_arcmt = @ENABLE_CLANG_ARCMT@
  config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@
  config.clang_rewriter = @ENABLE_CLANG_REWRITER@
+config.clang_examples = @CLANG_BUILD_EXAMPLES@
  config.host_arch = "@HOST_ARCH@"
# Support substitution of the tools and libs dirs with user parameters. This is
@@ -21,6 +24,7 @@ config.host_arch = "@HOST_ARCH@"
  try:
      config.clang_tools_dir = config.clang_tools_dir % lit_config.params
      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
  except KeyError:
      e = sys.exc_info()[1]


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

--
http://www.nuanti.com
the browser experts

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to