summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-08 11:38:47 +0000
committerAlp Toker <alp@nuanti.com>2014-01-08 11:38:47 +0000
commit120dd1afaf4daedfd8482fd255d7734862fbcea3 (patch)
tree6b3265309e31da923cd10f87a99ab5627fb803a7
parentc0b7bb56db27859e7c1d6f4640cac5107b72d224 (diff)
downloadbcm5719-llvm-120dd1afaf4daedfd8482fd255d7734862fbcea3.tar.gz
bcm5719-llvm-120dd1afaf4daedfd8482fd255d7734862fbcea3.zip
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. llvm-svn: 198747
-rw-r--r--clang/CMakeLists.txt4
-rw-r--r--clang/test/Frontend/plugins.c5
-rw-r--r--clang/test/lit.cfg16
-rw-r--r--clang/test/lit.site.cfg.in4
4 files changed, 29 insertions, 0 deletions
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f6351697579..a54c1fa3b4a 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -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}
diff --git a/clang/test/Frontend/plugins.c b/clang/test/Frontend/plugins.c
new file mode 100644
index 00000000000..8117f72fa7a
--- /dev/null
+++ b/clang/test/Frontend/plugins.c
@@ -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();
diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg
index eea7f89b9ff..ee011c6d2ea 100644
--- a/clang/test/lit.cfg
+++ b/clang/test/lit.cfg
@@ -195,6 +195,22 @@ config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
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.
diff --git a/clang/test/lit.site.cfg.in b/clang/test/lit.site.cfg.in
index a5234da01e7..09d4d213f16 100644
--- a/clang/test/lit.site.cfg.in
+++ b/clang/test/lit.site.cfg.in
@@ -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_SANITIZER@"
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]
OpenPOWER on IntegriCloud