summaryrefslogtreecommitdiff
path: root/solenv/Module_solenv.mk
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-11-14 23:35:19 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-11-15 11:09:29 +0100
commit645583dfd374c8b02f3c0eeba6233a0bb5884d68 (patch)
tree522ce0e474fb6263a69b3402f786245c73a1357e /solenv/Module_solenv.mk
parent10efab2b9a3cf7fc49655c90ba29db4512680c38 (diff)
New compilerplugins/clang unit tests
...to check that loplugin produces warnings/errors as expected: * Clang has a -verify switch that makes it easy to write test input .cxx files that list in comments all the warnings/errors that are expected, and let Clang check those expectations instead of generating object code. See include/clang/Frontend/VerifyDiagnosticConsumer.h in the Clang source tree for documentation. * Introduce a CompilerTest gbuild class that uses the existing LinkTarget class as much as possible. Checking the input files is implicitly phony, as the compilation step doesn't generate any object files, and the link step does nothing because there is no gb_LinkTarget_set_targettype for CompilerTest. The setup at least works for Clang on Linux (will need adaptions for Clang on Windows; compilers other than Clang are not relevant for now given this is used to check compilerplugins). * Definition of gb_CFLAGS_WERROR in solenv/gbuild/platform/com_GCC_defs.mk needs to be lazy ('=' vs. ':=') so that CompilerTest can override it: The Clang -verify mode wants the input files to specify whether the loplugin diagnostics are warnings or errros, so they consistently need to be errors independent of --enable-werror configuration. * A first (example) test is in compilerplugins/clang/test/salbool.cxx. The corresponding gbuild CompilerTest instance is in solenv/CompilerTest_compilerplugins_clang.mk for now. The reason for that odd split across compilerplugins/ and solenv/ is that there is no compilerplugins/Modules_compilerplugins.mk file, so this setup is the easiest hack for now (to be cleaned up). (Another area that could be improved is that all test files need to be listed explicitly in the CompilerTest_*.mk file, instead of, say, using all .c/.cxx/.m/.mm files in a specified directory.) * The test is run somewhat late during a top-level 'make', after loplugin has already been used in compilation. But it can be run manually (e.g., 'make solenv') when making changes to loplugin during development. Change-Id: I01e12fb84887d264ac03ef2484807458c2075af4
Diffstat (limited to 'solenv/Module_solenv.mk')
-rw-r--r--solenv/Module_solenv.mk6
1 files changed, 6 insertions, 0 deletions
diff --git a/solenv/Module_solenv.mk b/solenv/Module_solenv.mk
index 229ee5854425..127007eae676 100644
--- a/solenv/Module_solenv.mk
+++ b/solenv/Module_solenv.mk
@@ -33,4 +33,10 @@ endif
endif
endif
+ifneq ($(COMPILER_PLUGINS),)
+$(eval $(call gb_Module_add_check_targets,solenv, \
+ CompilerTest_compilerplugins_clang \
+))
+endif
+
# vim: set shiftwidth=4 tabstop=4 noexpandtab: