summaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorDan Liew <dan@su-root.co.uk>2019-01-11 17:59:52 +0000
committerDan Liew <dan@su-root.co.uk>2019-01-11 17:59:52 +0000
commit90d5ae1914714ba7dd3de7b732201b7f06d5d76d (patch)
tree621b2568751df38e6786055e5655168df19e96af /compiler-rt
parentd1b492b4eb6f70afb7d10e50913a84e052df86a4 (diff)
Provide storage for `true_type::value` and `false_type::value`.
Summary: This fixes linker errors that occurs when the `sanitizer_type_traits_test.cc` is built without optimizations. The error occurs because the test tries to take a reference. A possible workaround is to give the GTest macros take boolean rvalues by doing something like: ``` ASSERT_TRUE(bool(is_same<uptr, uptr>::value)); ``` However this only hides the problem. Unfortunately Using `constexpr` won't fix the problem unless we are using C++17. Reviewers: vitalybuka, kubamracek, george.karpenkov, yln Subscribers: mgorny, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D56035
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_type_traits.cc21
2 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 64a7bc49c79..f4e768f1a62 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -38,6 +38,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_suppressions.cc
sanitizer_tls_get_addr.cc
sanitizer_thread_registry.cc
+ sanitizer_type_traits.cc
sanitizer_win.cc)
if(UNIX AND NOT APPLE AND NOT OS_NAME MATCHES "SunOS")
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_type_traits.cc b/compiler-rt/lib/sanitizer_common/sanitizer_type_traits.cc
new file mode 100644
index 00000000000..27fec6e1f49
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_type_traits.cc
@@ -0,0 +1,21 @@
+//===-- sanitizer_type_traits.cc --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implements a subset of C++ type traits. This is so we can avoid depending
+// on system C++ headers.
+//
+//===----------------------------------------------------------------------===//
+#include "sanitizer_type_traits.h"
+
+namespace __sanitizer {
+
+const bool true_type::value;
+const bool false_type::value;
+
+} // namespace __sanitizer