Richard Smith | 2f0d7d5 | 2012-10-25 02:07:02 +0000 | [diff] [blame] | 1 | //===-- ubsan_handlers_cxx.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 | // Entry points to the runtime library for Clang's undefined behavior sanitizer, |
| 11 | // for C++-specific checks. This code is not linked into C binaries. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #ifndef UBSAN_HANDLERS_CXX_H |
| 15 | #define UBSAN_HANDLERS_CXX_H |
| 16 | |
| 17 | #include "ubsan_value.h" |
| 18 | |
| 19 | namespace __ubsan { |
| 20 | |
| 21 | struct DynamicTypeCacheMissData { |
| 22 | SourceLocation Loc; |
| 23 | const TypeDescriptor &Type; |
| 24 | void *TypeInfo; |
| 25 | unsigned char TypeCheckKind; |
| 26 | }; |
| 27 | |
Peter Collingbourne | 175d633 | 2015-06-19 01:52:55 +0000 | [diff] [blame] | 28 | struct CFIBadTypeData { |
| 29 | SourceLocation Loc; |
| 30 | const TypeDescriptor &Type; |
| 31 | unsigned char TypeCheckKind; |
| 32 | }; |
| 33 | |
Richard Smith | 2f0d7d5 | 2012-10-25 02:07:02 +0000 | [diff] [blame] | 34 | /// \brief Handle a runtime type check failure, caused by an incorrect vptr. |
| 35 | /// When this handler is called, all we know is that the type was not in the |
| 36 | /// cache; this does not necessarily imply the existence of a bug. |
Will Dietz | ad5180d | 2013-01-10 17:01:13 +0000 | [diff] [blame] | 37 | extern "C" SANITIZER_INTERFACE_ATTRIBUTE |
| 38 | void __ubsan_handle_dynamic_type_cache_miss( |
Richard Smith | 2f0d7d5 | 2012-10-25 02:07:02 +0000 | [diff] [blame] | 39 | DynamicTypeCacheMissData *Data, ValueHandle Pointer, ValueHandle Hash); |
Will Dietz | ad5180d | 2013-01-10 17:01:13 +0000 | [diff] [blame] | 40 | extern "C" SANITIZER_INTERFACE_ATTRIBUTE |
| 41 | void __ubsan_handle_dynamic_type_cache_miss_abort( |
Will Dietz | 2c36c71 | 2012-12-02 19:47:29 +0000 | [diff] [blame] | 42 | DynamicTypeCacheMissData *Data, ValueHandle Pointer, ValueHandle Hash); |
Richard Smith | 2f0d7d5 | 2012-10-25 02:07:02 +0000 | [diff] [blame] | 43 | |
Peter Collingbourne | 175d633 | 2015-06-19 01:52:55 +0000 | [diff] [blame] | 44 | /// \brief Handle a control flow integrity check failure by printing a |
| 45 | /// diagnostic. |
| 46 | extern "C" SANITIZER_INTERFACE_ATTRIBUTE void |
| 47 | __ubsan_handle_cfi_bad_type(CFIBadTypeData *Data, ValueHandle Vtable); |
| 48 | extern "C" SANITIZER_INTERFACE_ATTRIBUTE void |
| 49 | __ubsan_handle_cfi_bad_type_abort(CFIBadTypeData *Data, ValueHandle Vtable); |
| 50 | |
Richard Smith | 2f0d7d5 | 2012-10-25 02:07:02 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | #endif // UBSAN_HANDLERS_H |