Module: check_mk
Branch: master
Commit: 38820f099fc5fbc3c3db062fc3ca3b8b08617b30
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=38820f099fc5fb…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Dec 8 11:33:11 2017 +0100
Overhaul clang-tidy handling.
* Use local compilation databases.
* Run clang-tidy via wrapper in parallel, speeding things up tremendously.
* Temporarily disable a few checs, we will re-enable them soon.
Change-Id: Icce5368a4c8ff88b075ffae3caab7719c0e6806d
---
.clang-tidy | 21 ++++++++++++++++++++-
Makefile | 10 +++++++---
configure.ac | 2 +-
livestatus/src/Makefile.am | 13 +++++++++++++
4 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 46467a1..bea4985 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -30,7 +30,26 @@
# * cppcoreguidelines-pro-type-union-access ("do not access members of unions;
use (boost::)variant instead")
# * modernize-use-bool-literals ("converting integer literal to bool, use bool
literal instead") Incorrectly triggered by e.g. FD_ZERO
#
-Checks:
'*,-android-cloexec-fopen,-android-cloexec-open,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-google-runtime-int,-google-runtime-references,-hicpp-member-init,-hicpp-no-assembler,-llvm-header-guard,-llvm-include-order,-modernize-use-bool-literals'
+# * temporarily disabled:
+# * clang-analyzer-optin.performance.Padding
+# * cppcoreguidelines-special-member-functions
+# * google-build-using-namespace
+# * google-explicit-constructor
+# * google-readability-todo
+# * hicpp-explicit-conversions
+# * hicpp-use-equals-delete
+# * hicpp-special-member-functions
+# * modernize-deprecated-headers
+# * modernize-pass-by-value
+# * modernize-use-default-member-init
+# * modernize-use-equals-delete
+# * modernize-use-noexcept
+# * performance-unnecessary-value-param
+# * readability-avoid-const-params-in-decls
+# * readability-implicit-bool-cast
+# * readability-named-parameter
+#
+Checks:
'*,-android-cloexec-fopen,-android-cloexec-open,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-google-runtime-int,-google-runtime-references,-hicpp-member-init,-hicpp-no-assembler,-llvm-header-guard,-llvm-include-order,-modernize-use-bool-literals,-clang-analyzer-optin.performance.Padding,-cppcoreguidelines-special-member-functions,-google-build-using-namespace,-google-explicit-constructor,-google-readability-todo,-hicpp-explicit-conversions,-hicpp-use-equals-delete,-hicpp-special-member-functions,-modernize-deprecated-headers,-modernize-pass-by-value,-modernize-use-default-member-init,-modernize-use-equals-delete,-modernize-use-noexcept,-performance-unnecessary-value-param,-readability-avoid-const-params-in-decls,-readability-implicit-bool-cast,-readability-named-parameter'
CheckOptions:
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '1'
diff --git a/Makefile b/Makefile
index 2ebb43b..2afb60b 100644
--- a/Makefile
+++ b/Makefile
@@ -70,6 +70,7 @@ CXX_FLAGS += -std=c++14
CLANG_VERSION := 5.0
CLANG_FORMAT := clang-format-$(CLANG_VERSION)
CLANG_TIDY := clang-tidy-$(CLANG_VERSION)
+export RUN_CLANG_TIDY := run-clang-tidy-$(CLANG_VERSION).py
SCAN_BUILD := scan-build-$(CLANG_VERSION)
CPPCHECK := cppcheck
DOXYGEN := doxygen
@@ -91,7 +92,7 @@ IWYU_TOOL := iwyu_tool
# git clone
https://github.com/rizsotto/Bear.git && cd Bear && git
checkout 2.2.0 && cmake -DCMAKE_INSTALL_PREFIX=$HOME/local/Bear-2.2.0 &&
make install
# and put $HOME/local/Bear-2.2.0/bin into your PATH or set the make variable
# below accordingly.
-BEAR := bear
+export BEAR := bear
M4_DEPS := $(wildcard m4/*) configure.ac
CONFIGURE_DEPS := $(M4_DEPS) aclocal.m4
@@ -483,8 +484,11 @@ ifeq ($(ENTERPRISE),yes)
$(MAKE) -C enterprise/core -j4
endif
-tidy: compile_commands.json
- @scripts/compiled_sources | xargs $(CLANG_TIDY) --extra-arg=-D__clang_analyzer__
+tidy:
+ $(MAKE) -C livestatus/src tidy
+ifeq ($(ENTERPRISE),yes)
+ $(MAKE) -C enterprise/core/src tidy
+endif
# Not really perfect rules, but better than nothing
iwyu: compile_commands.json
diff --git a/configure.ac b/configure.ac
index bdd8d5d..c30008d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@
AC_PREREQ(2.61)
AC_INIT([MK Livestatus], [1.5.0i2], [mk(a)mathias-kettner.de])
-AM_INIT_AUTOMAKE([-Wall foreign])
+AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
diff --git a/livestatus/src/Makefile.am b/livestatus/src/Makefile.am
index 79a7227..9639f3d 100644
--- a/livestatus/src/Makefile.am
+++ b/livestatus/src/Makefile.am
@@ -22,6 +22,10 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+CLANG_VERSION ?= 5.0
+RUN_CLANG_TIDY ?= run-clang-tidy-$(CLANG_VERSION).py
+BEAR ?= bear
+
bin_PROGRAMS = unixcat
unixcat_SOURCES = unixcat.cc
@@ -149,6 +153,8 @@ liblivestatus_a_SOURCES = \
pnp4nagios.cc \
strutil.cc
+.PHONY: tidy
+
liblivestatus_a_CPPFLAGS = -I.. @BOOST_CPPFLAGS@
liblivestatus_a_CXXFLAGS = -fPIC
@@ -160,6 +166,13 @@ livestatus.o: $(liblivestatus_a_OBJECTS)
$(CXX) $(liblivestatus_a_CXXFLAGS) $(CXXFLAGS) NagiosMockup.o $@ -o NagiosMockup
$(RM) NagiosMockup
+compile_commands.json: Makefile $(wildcard *.cc *.h)
+ $(MAKE) clean
+ $(BEAR) $(MAKE) -j4
+
+tidy: compile_commands.json
+ $(RUN_CLANG_TIDY) -quiet -j6
+
all-local: livestatus.o
install-data-local: