[compiler-rt] r350940 - Provide storage for `true_type::value` and `false_type::value`.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 11 09:59:52 PST 2019


Author: delcypher
Date: Fri Jan 11 09:59:52 2019
New Revision: 350940

URL: http://llvm.org/viewvc/llvm-project?rev=350940&view=rev
Log:
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

Added:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_type_traits.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt

Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=350940&r1=350939&r2=350940&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Fri Jan 11 09:59:52 2019
@@ -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")

Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_type_traits.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_type_traits.cc?rev=350940&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_type_traits.cc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_type_traits.cc Fri Jan 11 09:59:52 2019
@@ -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




More information about the llvm-commits mailing list