run clang tidy on travis

This commit is contained in:
arvidn 2018-07-17 15:01:01 +02:00 committed by Arvid Norberg
parent 730ef15b08
commit 27836ede70
4 changed files with 143 additions and 30 deletions

View File

@ -5,8 +5,18 @@ matrix:
fast_finish: true
include:
- if: repo = arvidn/libtorrent
env: variant=release sonar_scan=1 toolset=gcc pylint=1
- env: variant=test_debug lint=1 tests=1 toolset=gcc-sanitizer
env: variant=release sonar_scan=1 toolset=gcc
- env: variant=debug toolset=gcc lint=1 pylint=1 clang_tidy=1
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libc++-dev
- python3-pip
- libboost1.55-all-dev
- libboost1.55-tools-dev
- env: variant=test_debug tests=1 toolset=gcc-sanitizer
- env: variant=test_debug sim=1 crypto=openssl toolset=gcc-sanitizer
- env: variant=test_release coverage=1 tests=1 toolset=gcc-coverage python=1
- env: autotools=1 toolset=gcc
@ -46,7 +56,6 @@ addons:
- python2.7-dev
- g++-5
- [cmake3, ninja-build]
- python3-pip
before_install:
@ -110,6 +119,9 @@ install:
<linkflags>-static-libstdc++
<linkflags>-static-libgcc ;" >> ~/user-config.jam;
fi;'
- 'if [ $clang_tidy == "1" ]; then
echo "using clang_tidy : : clang-tidy "-checks=-clang-analyzer-core.*" : <cxxflags>-std=c++11 <cxxflags>-stdlib=libc++ <linkflags>-stdlib=libc++ ;" >> ~/user-config.jam;
fi'
- 'echo "using darwin : : ccache clang++ : <cxxflags>-std=c++11 ;" >> ~/user-config.jam'
- 'echo "using darwin : ios_sim : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-Wno-deprecated-declarations
<compileflags>\"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk\"
@ -174,8 +186,10 @@ install:
# remove all paths containing 'cmake' to use the executable from /usr/bin
export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/cmake/ {next} {print}'`
fi
- which cmake
- cmake --version
- if [[ "$cmake" == "1" ]]; then
which cmake;
cmake --version;
fi
script:
@ -196,6 +210,11 @@ script:
build-wrapper-linux-x86-64 --out-dir bw-output bjam -a -j3 optimization=off crypto=$crypto deprecated-functions=off $toolset variant=$variant -l300 &&
sonar-scanner -D sonar.login=$SONAR_TOKEN;
fi'
- 'if [[ $clang_tidy == "1" ]]; then
which clang-tidy;
clang-tidy --version;
bjam -a -j3 clang_tidy;
fi'
# if we are building with code coverage, report it as soon as possible
# libtorrent is the name of the test suite target

View File

@ -0,0 +1,2 @@
include clang_tidy.jam

92
clang_tidy.jam Normal file
View File

@ -0,0 +1,92 @@
# Copyright (c) 2018 Arvid Norberg (arvid@libtorrent.org)
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
import common ;
import toolset ;
import feature ;
feature.extend toolset : clang_tidy ;
generators.register-c-compiler clang_tidy.compile.c++ : CPP : OBJ : <toolset>clang_tidy ;
generators.register-c-compiler clang_tidy.compile.c : C : OBJ : <toolset>clang_tidy ;
generators.register-archiver clang_tidy.archive : OBJ : STATIC_LIB : <toolset>clang_tidy ;
generators.register-linker clang_tidy.link : OBJ SEARCHED_LIB STATIC_LIB : EXE : <toolset>clang_tidy ;
generators.register-linker clang_tidy.link.dll : OBJ SEARCHED_LIB STATIC_LIB : SHARED_LIB : <toolset>clang_tidy ;
rule init ( version ? : command * : options * ) {
command = [ common.get-invocation-command clang_tidy : clang-tidy
: $(command) ] ;
# Determine the version
if $(command) {
local command-string = \"$(command)\" ;
command-string = $(command-string:J=" ") ;
version ?= [ MATCH "version ([0-9.]+)"
: [ SHELL "$(command-string) --version" ] ] ;
}
local condition = [ common.check-init-parameters clang_tidy
: version $(version) ] ;
common.handle-options clang_tidy : $(condition) : $(command) : $(options) ;
}
###############################################################################
# Flags
toolset.flags clang_tidy.compile OPTIONS <cflags> ;
toolset.flags clang_tidy.compile.c++ OPTIONS <cxxflags> ;
toolset.flags clang_tidy.compile DEFINES <define> ;
toolset.flags clang_tidy.compile INCLUDES <include> ;
toolset.flags clang_tidy.compile OPTIONS <optimization>off : ;
toolset.flags clang_tidy.compile OPTIONS <optimization>speed : -O3 ;
toolset.flags clang_tidy.compile OPTIONS <optimization>space : -Os ;
toolset.flags clang_tidy.compile OPTIONS <inlining>off : -fno-inline ;
# For clang, 'on' and 'full' are identical.
toolset.flags clang_tidy.compile OPTIONS <inlining>on : -Wno-inline ;
toolset.flags clang_tidy.compile OPTIONS <inlining>full : -Wno-inline ;
toolset.flags clang_tidy.compile OPTIONS <warnings>off : -w ;
toolset.flags clang_tidy.compile OPTIONS <warnings>on : -Wall ;
toolset.flags clang_tidy.compile OPTIONS <warnings>all : -Wall -pedantic ;
toolset.flags clang_tidy.compile OPTIONS <warnings-as-errors>on : -Werror ;
toolset.flags clang_tidy.compile OPTIONS <debug-symbols>on : -g ;
toolset.flags clang_tidy.compile OPTIONS <profiling>on : -pg ;
toolset.flags clang_tidy.compile OPTIONS <rtti>off : -fno-rtti ;
###############################################################################
# C and C++ compilation
TOUCH = [ common.file-creation-command ] ;
actions compile.c++ {
"$(CONFIG_COMMAND)" -header-filter=*. -warnings-as-errors=* "$(>)" -- -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" \
&& $(TOUCH) "$(<)"
}
actions compile.c {
"$(CONFIG_COMMAND)" -header-filter=*. -warnings-as-errors=* "$(>)" -- -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" \
&& $(TOUCH) "$(<)"
}
###############################################################################
# Linking
actions archive {
$(TOUCH) "$(<)"
}
actions link {
$(TOUCH) "$(<)"
}
actions link.dll {
$(TOUCH) "$(<)"
}

View File

@ -88,42 +88,42 @@ void sc_reduce(unsigned char *s) {
s14 -= s23 * 997805;
s15 += s23 * 136657;
s16 -= s23 * 683901;
s23 = 0;
s23 = 0; // NOLINT
s10 += s22 * 666643;
s11 += s22 * 470296;
s12 += s22 * 654183;
s13 -= s22 * 997805;
s14 += s22 * 136657;
s15 -= s22 * 683901;
s22 = 0;
s22 = 0; // NOLINT
s9 += s21 * 666643;
s10 += s21 * 470296;
s11 += s21 * 654183;
s12 -= s21 * 997805;
s13 += s21 * 136657;
s14 -= s21 * 683901;
s21 = 0;
s21 = 0; // NOLINT
s8 += s20 * 666643;
s9 += s20 * 470296;
s10 += s20 * 654183;
s11 -= s20 * 997805;
s12 += s20 * 136657;
s13 -= s20 * 683901;
s20 = 0;
s20 = 0; // NOLINT
s7 += s19 * 666643;
s8 += s19 * 470296;
s9 += s19 * 654183;
s10 -= s19 * 997805;
s11 += s19 * 136657;
s12 -= s19 * 683901;
s19 = 0;
s19 = 0; // NOLINT
s6 += s18 * 666643;
s7 += s18 * 470296;
s8 += s18 * 654183;
s9 -= s18 * 997805;
s10 += s18 * 136657;
s11 -= s18 * 683901;
s18 = 0;
s18 = 0; // NOLINT
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= shift_left(carry6, 21);
@ -163,35 +163,35 @@ void sc_reduce(unsigned char *s) {
s8 -= s17 * 997805;
s9 += s17 * 136657;
s10 -= s17 * 683901;
s17 = 0;
s17 = 0; // NOLINT
s4 += s16 * 666643;
s5 += s16 * 470296;
s6 += s16 * 654183;
s7 -= s16 * 997805;
s8 += s16 * 136657;
s9 -= s16 * 683901;
s16 = 0;
s16 = 0; // NOLINT
s3 += s15 * 666643;
s4 += s15 * 470296;
s5 += s15 * 654183;
s6 -= s15 * 997805;
s7 += s15 * 136657;
s8 -= s15 * 683901;
s15 = 0;
s15 = 0; // NOLINT
s2 += s14 * 666643;
s3 += s14 * 470296;
s4 += s14 * 654183;
s5 -= s14 * 997805;
s6 += s14 * 136657;
s7 -= s14 * 683901;
s14 = 0;
s14 = 0; // NOLINT
s1 += s13 * 666643;
s2 += s13 * 470296;
s3 += s13 * 654183;
s4 -= s13 * 997805;
s5 += s13 * 136657;
s6 -= s13 * 683901;
s13 = 0;
s13 = 0; // NOLINT
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
@ -284,7 +284,7 @@ void sc_reduce(unsigned char *s) {
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
s12 = 0; // NOLINT
carry0 = s0 >> 21;
s1 += carry0;
s0 -= shift_left(carry0, 21);
@ -550,42 +550,42 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s14 -= s23 * 997805;
s15 += s23 * 136657;
s16 -= s23 * 683901;
s23 = 0;
s23 = 0; // NOLINT
s10 += s22 * 666643;
s11 += s22 * 470296;
s12 += s22 * 654183;
s13 -= s22 * 997805;
s14 += s22 * 136657;
s15 -= s22 * 683901;
s22 = 0;
s22 = 0; // NOLINT
s9 += s21 * 666643;
s10 += s21 * 470296;
s11 += s21 * 654183;
s12 -= s21 * 997805;
s13 += s21 * 136657;
s14 -= s21 * 683901;
s21 = 0;
s21 = 0; // NOLINT
s8 += s20 * 666643;
s9 += s20 * 470296;
s10 += s20 * 654183;
s11 -= s20 * 997805;
s12 += s20 * 136657;
s13 -= s20 * 683901;
s20 = 0;
s20 = 0; // NOLINT
s7 += s19 * 666643;
s8 += s19 * 470296;
s9 += s19 * 654183;
s10 -= s19 * 997805;
s11 += s19 * 136657;
s12 -= s19 * 683901;
s19 = 0;
s19 = 0; // NOLINT
s6 += s18 * 666643;
s7 += s18 * 470296;
s8 += s18 * 654183;
s9 -= s18 * 997805;
s10 += s18 * 136657;
s11 -= s18 * 683901;
s18 = 0;
s18 = 0; // NOLINT
carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6;
s6 -= shift_left(carry6, 21);
@ -625,42 +625,42 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s8 -= s17 * 997805;
s9 += s17 * 136657;
s10 -= s17 * 683901;
s17 = 0;
s17 = 0; // NOLINT
s4 += s16 * 666643;
s5 += s16 * 470296;
s6 += s16 * 654183;
s7 -= s16 * 997805;
s8 += s16 * 136657;
s9 -= s16 * 683901;
s16 = 0;
s16 = 0; // NOLINT
s3 += s15 * 666643;
s4 += s15 * 470296;
s5 += s15 * 654183;
s6 -= s15 * 997805;
s7 += s15 * 136657;
s8 -= s15 * 683901;
s15 = 0;
s15 = 0; // NOLINT
s2 += s14 * 666643;
s3 += s14 * 470296;
s4 += s14 * 654183;
s5 -= s14 * 997805;
s6 += s14 * 136657;
s7 -= s14 * 683901;
s14 = 0;
s14 = 0; // NOLINT
s1 += s13 * 666643;
s2 += s13 * 470296;
s3 += s13 * 654183;
s4 -= s13 * 997805;
s5 += s13 * 136657;
s6 -= s13 * 683901;
s13 = 0;
s13 = 0; // NOLINT
s0 += s12 * 666643;
s1 += s12 * 470296;
s2 += s12 * 654183;
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
s12 = 0; // NOLINT
carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0;
s0 -= shift_left(carry0, 21);
@ -746,7 +746,7 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s3 -= s12 * 997805;
s4 += s12 * 136657;
s5 -= s12 * 683901;
s12 = 0;
s12 = 0; // NOLINT
carry0 = s0 >> 21;
s1 += carry0;
s0 -= shift_left(carry0, 21);