ubsan.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* UndefinedBehaviorSanitizer, undefined behavior detector.
  2. Copyright (C) 2013-2020 Free Software Foundation, Inc.
  3. Contributed by Marek Polacek <polacek@redhat.com>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_UBSAN_H
  17. #define GCC_UBSAN_H
  18. /* The various kinds of NULL pointer checks. */
  19. enum ubsan_null_ckind {
  20. UBSAN_LOAD_OF,
  21. UBSAN_STORE_OF,
  22. UBSAN_REF_BINDING,
  23. UBSAN_MEMBER_ACCESS,
  24. UBSAN_MEMBER_CALL,
  25. UBSAN_CTOR_CALL,
  26. UBSAN_DOWNCAST_POINTER,
  27. UBSAN_DOWNCAST_REFERENCE,
  28. UBSAN_UPCAST,
  29. UBSAN_CAST_TO_VBASE
  30. };
  31. /* This controls how ubsan prints types. Used in ubsan_type_descriptor. */
  32. enum ubsan_print_style {
  33. UBSAN_PRINT_NORMAL,
  34. UBSAN_PRINT_POINTER,
  35. UBSAN_PRINT_ARRAY
  36. };
  37. /* This controls ubsan_encode_value behavior. */
  38. enum ubsan_encode_value_phase {
  39. UBSAN_ENCODE_VALUE_GENERIC,
  40. UBSAN_ENCODE_VALUE_GIMPLE,
  41. UBSAN_ENCODE_VALUE_RTL
  42. };
  43. extern bool ubsan_expand_bounds_ifn (gimple_stmt_iterator *);
  44. extern bool ubsan_expand_null_ifn (gimple_stmt_iterator *);
  45. extern bool ubsan_expand_objsize_ifn (gimple_stmt_iterator *);
  46. extern bool ubsan_expand_ptr_ifn (gimple_stmt_iterator *);
  47. extern bool ubsan_expand_vptr_ifn (gimple_stmt_iterator *);
  48. extern bool ubsan_instrument_unreachable (gimple_stmt_iterator *);
  49. extern tree ubsan_create_data (const char *, int, const location_t *, ...);
  50. extern tree ubsan_type_descriptor (tree, ubsan_print_style
  51. = UBSAN_PRINT_NORMAL);
  52. extern tree ubsan_encode_value (tree, ubsan_encode_value_phase
  53. = UBSAN_ENCODE_VALUE_GENERIC);
  54. extern bool is_ubsan_builtin_p (tree);
  55. extern tree ubsan_build_overflow_builtin (tree_code, location_t, tree, tree,
  56. tree, tree *);
  57. extern tree ubsan_instrument_float_cast (location_t, tree, tree);
  58. extern tree ubsan_get_source_location_type (void);
  59. #endif /* GCC_UBSAN_H */