1 //===------------------------- typeinfo.cpp -------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "typeinfo" 11 12 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(_LIBCPP_NO_VCRUNTIME) 13 #include <string.h> 14 __compare(const type_info & __rhs) const15int std::type_info::__compare(const type_info &__rhs) const _NOEXCEPT { 16 if (&__data == &__rhs.__data) 17 return 0; 18 return strcmp(&__data.__decorated_name[1], &__rhs.__data.__decorated_name[1]); 19 } 20 name() const21const char *std::type_info::name() const _NOEXCEPT { 22 // TODO(compnerd) cache demangled &__data.__decorated_name[1] 23 return &__data.__decorated_name[1]; 24 } 25 hash_code() const26size_t std::type_info::hash_code() const _NOEXCEPT { 27 #if defined(_WIN64) 28 constexpr size_t fnv_offset_basis = 14695981039346656037ull; 29 constexpr size_t fnv_prime = 10995116282110ull; 30 #else 31 constexpr size_t fnv_offset_basis = 2166136261ull; 32 constexpr size_t fnv_prime = 16777619ull; 33 #endif 34 35 size_t value = fnv_offset_basis; 36 for (const char* c = &__data.__decorated_name[1]; *c; ++c) { 37 value ^= static_cast<size_t>(static_cast<unsigned char>(*c)); 38 value *= fnv_prime; 39 } 40 41 #if defined(_WIN64) 42 value ^= value >> 32; 43 #endif 44 45 return value; 46 } 47 #endif // _LIBCPP_ABI_MICROSOFT 48 49 // FIXME: Remove __APPLE__ default here once buildit is gone. 50 // FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration. 51 #if (!defined(LIBCXX_BUILDING_LIBCXXABI) && !defined(LIBCXXRT) && \ 52 !defined(__GLIBCXX__) && !defined(__APPLE__) && \ 53 !(defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME))) || \ 54 defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) ~type_info()55std::type_info::~type_info() 56 { 57 } 58 #endif 59