[TSan] Provide default values for compile definitions.

Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY.
Replace #ifdef directives with #if. This fixes a bug introduced
in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0
would still enable stats collection and reporting.

llvm-svn: 229581
diff --git a/compiler-rt/lib/tsan/rtl/tsan_defs.h b/compiler-rt/lib/tsan/rtl/tsan_defs.h
index 971178d..910a483 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_defs.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_defs.h
@@ -18,6 +18,15 @@
 #include "sanitizer_common/sanitizer_libc.h"
 #include "tsan_stat.h"
 
+// Setup defaults for compile definitions.
+#ifndef TSAN_NO_HISTORY
+# define TSAN_NO_HISTORY 0
+#endif
+
+#ifndef TSAN_COLLECT_STATS
+# define TSAN_COLLECT_STATS 0
+#endif
+
 namespace __tsan {
 
 #ifdef SANITIZER_GO
@@ -63,7 +72,7 @@
 // Size of a single meta shadow value (u32).
 const uptr kMetaShadowSize = 4;
 
-#if defined(TSAN_NO_HISTORY) && TSAN_NO_HISTORY
+#if TSAN_NO_HISTORY
 const bool kCollectHistory = false;
 #else
 const bool kCollectHistory = true;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index 4317894..0d2c70b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -397,7 +397,7 @@
 
   failed = OnFinalize(failed);
 
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
   StatAggregate(ctx->stat, thr->stat);
   StatOutput(ctx->stat);
 #endif
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 440d60a..570c8d6 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -351,7 +351,7 @@
   Vector<JmpBuf> jmp_bufs;
   int ignore_interceptors;
 #endif
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
   u64 stat[StatCnt];
 #endif
   const int tid;
@@ -543,18 +543,18 @@
 }
 
 
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
 void StatAggregate(u64 *dst, u64 *src);
 void StatOutput(u64 *stat);
 #endif
 
 void ALWAYS_INLINE StatInc(ThreadState *thr, StatType typ, u64 n = 1) {
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
   thr->stat[typ] += n;
 #endif
 }
 void ALWAYS_INLINE StatSet(ThreadState *thr, StatType typ, u64 n) {
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
   thr->stat[typ] = n;
 #endif
 }
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
index 3ca9793..8ed1fbf 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
@@ -145,7 +145,7 @@
   AllocatorThreadFinish(thr);
 #endif
   thr->~ThreadState();
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
   StatAggregate(ctx->stat, thr->stat);
 #endif
   thr = 0;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_stat.cc b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
index 203ee1d..15fa43d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_stat.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
@@ -15,7 +15,7 @@
 
 namespace __tsan {
 
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
 
 void StatAggregate(u64 *dst, u64 *src) {
   for (int i = 0; i < StatCnt; i++)