aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ubsan/ubsan_type_hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ubsan/ubsan_type_hash.cpp')
-rw-r--r--lib/ubsan/ubsan_type_hash.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/ubsan/ubsan_type_hash.cpp b/lib/ubsan/ubsan_type_hash.cpp
new file mode 100644
index 000000000000..8f4b9aee50bb
--- /dev/null
+++ b/lib/ubsan/ubsan_type_hash.cpp
@@ -0,0 +1,33 @@
+//===-- ubsan_type_hash.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation of a hash table for fast checking of inheritance
+// relationships. This file is only linked into C++ compilations, and is
+// permitted to use language features which require a C++ ABI library.
+//
+// Most of the implementation lives in an ABI-specific source file
+// (ubsan_type_hash_{itanium,win}.cpp).
+//
+//===----------------------------------------------------------------------===//
+
+#include "ubsan_platform.h"
+#if CAN_SANITIZE_UB
+#include "ubsan_type_hash.h"
+
+#include "sanitizer_common/sanitizer_common.h"
+
+/// A cache of recently-checked hashes. Mini hash table with "random" evictions.
+__ubsan::HashValue
+__ubsan::__ubsan_vptr_type_cache[__ubsan::VptrTypeCacheSize];
+
+__ubsan::DynamicTypeInfo __ubsan::getDynamicTypeInfoFromObject(void *Object) {
+ void *VtablePtr = *reinterpret_cast<void **>(Object);
+ return getDynamicTypeInfoFromVtable(VtablePtr);
+}
+
+#endif // CAN_SANITIZE_UB