From 010ea126f3662c76e2d484e9710be2b8fcd53785 Mon Sep 17 00:00:00 2001
From: Daniel Cohen <daniel.cohen599@gmail.com>
Date: Sun, 25 Dec 2016 14:04:04 +0200
Subject: [PATCH] going to try clang_sanitize with libstdc++ with g++-6
 implementation

Conflicts:
	.travis.yml
	Makefile
---
 .travis.yml | 22 ++++++++++++++--------
 Makefile    |  3 ++-
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 006647ed..6bf2297e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,14 +42,20 @@ matrix:
       - make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
 
   # cLang sanitizer
-
-  #- os: linux
-  #  env:
-  #    - LLVM_VERSION=3.8.1
-  #    - SPECIAL=sanitizer
-  #  compiler: clang
-  #  before_script:
-  #    - make clang_sanitize
+  # note: sadly clang's libc++ has errors when running with sanitize,
+  # so we use clang with gcc's libstdc++ which doesn't give those error.
+  # that's why we need to install g++-6 to get the lastest version
+  - os: linux
+    env:
+      - LLVM_VERSION=3.8.1
+      - SPECIAL=sanitizer
+    addons:
+      apt:
+        sources: ['ubuntu-toolchain-r-test']
+        packages: g++-6
+    compiler: clang
+    before_script:
+      - make clang_sanitize
 
   # cppcheck
 
diff --git a/Makefile b/Makefile
index e2c120db..c16d9d9b 100644
--- a/Makefile
+++ b/Makefile
@@ -92,8 +92,9 @@ fuzzing-stop:
 cppcheck:
 	cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
 
+# run clang sanitize (we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++)
 clang_sanitize: clean
-	CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)
+	CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE) check -C test
 
 
 ##########################################################################