ubsan_type_hash.h revision 26a725f0b2fd30b98adae6353b432d0c955e10bd
1//===-- ubsan_type_hash.h ---------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// Hashing of types for Clang's undefined behavior checker. 11// 12//===----------------------------------------------------------------------===// 13#ifndef UBSAN_TYPE_HASH_H 14#define UBSAN_TYPE_HASH_H 15 16#include "sanitizer_common/sanitizer_common.h" 17 18namespace __ubsan { 19 20typedef uptr HashValue; 21 22/// \brief Check whether the dynamic type of \p Object has a \p Type subobject 23/// at offset 0. 24/// \return \c true if the type matches, \c false if not. 25bool checkDynamicType(void *Object, void *Type, HashValue Hash); 26 27const unsigned VptrTypeCacheSize = 128; 28 29/// \brief A cache of the results of checkDynamicType. \c checkDynamicType would 30/// return \c true (modulo hash collisions) if 31/// \code 32/// __ubsan_vptr_type_cache[Hash % VptrTypeCacheSize] == Hash 33/// \endcode 34extern "C" HashValue __ubsan_vptr_type_cache[VptrTypeCacheSize]; 35 36} // namespace __ubsan 37 38#endif // UBSAN_TYPE_HASH_H 39