ubsan_handlers_cxx.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //===-- ubsan_handlers_cxx.h ------------------------------------*- C++ -*-===//
  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. // Entry points to the runtime library for Clang's undefined behavior sanitizer,
  10. // for C++-specific checks. This code is not linked into C binaries.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef UBSAN_HANDLERS_CXX_H
  14. #define UBSAN_HANDLERS_CXX_H
  15. #include "ubsan_value.h"
  16. namespace __ubsan {
  17. struct DynamicTypeCacheMissData {
  18. SourceLocation Loc;
  19. const TypeDescriptor &Type;
  20. void *TypeInfo;
  21. unsigned char TypeCheckKind;
  22. };
  23. /// \brief Handle a runtime type check failure, caused by an incorrect vptr.
  24. /// When this handler is called, all we know is that the type was not in the
  25. /// cache; this does not necessarily imply the existence of a bug.
  26. extern "C" SANITIZER_INTERFACE_ATTRIBUTE
  27. void __ubsan_handle_dynamic_type_cache_miss(
  28. DynamicTypeCacheMissData *Data, ValueHandle Pointer, ValueHandle Hash);
  29. extern "C" SANITIZER_INTERFACE_ATTRIBUTE
  30. void __ubsan_handle_dynamic_type_cache_miss_abort(
  31. DynamicTypeCacheMissData *Data, ValueHandle Pointer, ValueHandle Hash);
  32. struct FunctionTypeMismatchData {
  33. SourceLocation Loc;
  34. const TypeDescriptor &Type;
  35. };
  36. extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
  37. __ubsan_handle_function_type_mismatch_v1(FunctionTypeMismatchData *Data,
  38. ValueHandle Val,
  39. ValueHandle calleeRTTI,
  40. ValueHandle fnRTTI);
  41. extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
  42. __ubsan_handle_function_type_mismatch_v1_abort(FunctionTypeMismatchData *Data,
  43. ValueHandle Val,
  44. ValueHandle calleeRTTI,
  45. ValueHandle fnRTTI);
  46. }
  47. #endif // UBSAN_HANDLERS_CXX_H