1 //===-- ubsan_type_hash.cpp -----------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Implementation of a hash table for fast checking of inheritance 10 // relationships. This file is only linked into C++ compilations, and is 11 // permitted to use language features which require a C++ ABI library. 12 // 13 // Most of the implementation lives in an ABI-specific source file 14 // (ubsan_type_hash_{itanium,win}.cpp). 15 // 16 //===----------------------------------------------------------------------===// 17 18 #include "ubsan_platform.h" 19 #if CAN_SANITIZE_UB 20 #include "ubsan_type_hash.h" 21 22 #include "sanitizer_common/sanitizer_common.h" 23 24 /// A cache of recently-checked hashes. Mini hash table with "random" evictions. 25 __ubsan::HashValue 26 __ubsan::__ubsan_vptr_type_cache[__ubsan::VptrTypeCacheSize]; 27 getDynamicTypeInfoFromObject(void * Object)28__ubsan::DynamicTypeInfo __ubsan::getDynamicTypeInfoFromObject(void *Object) { 29 void *VtablePtr = *reinterpret_cast<void **>(Object); 30 return getDynamicTypeInfoFromVtable(VtablePtr); 31 } 32 33 #endif // CAN_SANITIZE_UB 34