From b923e8f4df8e9c5cea6627d273ba135ab728e260 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sun, 1 Jan 2017 21:29:38 +0100 Subject: [PATCH] Travis: Added Clang AddressSanitizer and UndefinedBehaviorSanitizer --- .travis.yml | 6 ++++++ CMakeLists.txt | 4 ++++ scripts/travis/sanitize.sh | 7 +++++++ test/CMakeLists.txt | 1 - 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 scripts/travis/sanitize.sh diff --git a/.travis.yml b/.travis.yml index b9bbd5a2..fe467f55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,12 @@ matrix: sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8'] packages: ['clang-3.8'] env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.8 + - compiler: clang + addons: + apt: + sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8'] + packages: ['clang-3.8'] + env: SCRIPT=sanitize CMAKE_CXX_COMPILER=clang++-3.8 - compiler: gcc env: SCRIPT=coverage - os: osx diff --git a/CMakeLists.txt b/CMakeLists.txt index b8328b92..04597a30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,8 @@ if(${COVERAGE}) set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") endif() +if(${SANITIZE}) + set(CMAKE_CXX_FLAGS "-fsanitize=address,undefined") +endif() + add_subdirectory(test) diff --git a/scripts/travis/sanitize.sh b/scripts/travis/sanitize.sh new file mode 100755 index 00000000..3631a580 --- /dev/null +++ b/scripts/travis/sanitize.sh @@ -0,0 +1,7 @@ +#!/bin/sh -eux + +curl https://cmake.org/files/v3.4/cmake-3.4.0-Linux-x86_64.tar.gz | tar xz -C /tmp --strip 1 + +/tmp/bin/cmake -DSANITIZE=true . +make +make test diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4af4f006..0fa6ade2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,7 +12,6 @@ file(GLOB TESTS_FILES *.hpp *.cpp) if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") add_compile_options( -fno-exceptions - -fno-rtti -pedantic -Wall -Wcast-align