GCC Middle and Back End API Reference
ubsan.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ubsan_null_ckind {
  UBSAN_LOAD_OF , UBSAN_STORE_OF , UBSAN_REF_BINDING , UBSAN_MEMBER_ACCESS ,
  UBSAN_MEMBER_CALL , UBSAN_CTOR_CALL , UBSAN_DOWNCAST_POINTER , UBSAN_DOWNCAST_REFERENCE ,
  UBSAN_UPCAST , UBSAN_CAST_TO_VBASE
}
 
enum  ubsan_print_style { UBSAN_PRINT_NORMAL , UBSAN_PRINT_POINTER , UBSAN_PRINT_ARRAY , UBSAN_PRINT_FORCE_INT }
 
enum  ubsan_encode_value_phase { UBSAN_ENCODE_VALUE_GENERIC , UBSAN_ENCODE_VALUE_GIMPLE , UBSAN_ENCODE_VALUE_RTL }
 

Functions

bool ubsan_expand_bounds_ifn (gimple_stmt_iterator *)
 
bool ubsan_expand_null_ifn (gimple_stmt_iterator *)
 
bool ubsan_expand_objsize_ifn (gimple_stmt_iterator *)
 
bool ubsan_expand_ptr_ifn (gimple_stmt_iterator *)
 
bool ubsan_expand_vptr_ifn (gimple_stmt_iterator *)
 
bool ubsan_instrument_unreachable (gimple_stmt_iterator *)
 
tree ubsan_create_data (const char *, int, const location_t *,...)
 
tree ubsan_type_descriptor (tree, ubsan_print_style=UBSAN_PRINT_NORMAL)
 
tree ubsan_encode_value (tree, ubsan_encode_value_phase=UBSAN_ENCODE_VALUE_GENERIC)
 
bool is_ubsan_builtin_p (tree)
 
tree ubsan_build_overflow_builtin (tree_code, location_t, tree, tree, tree, tree *)
 
tree ubsan_instrument_float_cast (location_t, tree, tree)
 
tree ubsan_get_source_location_type (void)
 
tree sanitize_unreachable_fn (tree *data, location_t loc)
 

Enumeration Type Documentation

◆ ubsan_encode_value_phase

This controls ubsan_encode_value behavior.   
Enumerator
UBSAN_ENCODE_VALUE_GENERIC 
UBSAN_ENCODE_VALUE_GIMPLE 
UBSAN_ENCODE_VALUE_RTL 

◆ ubsan_null_ckind

UndefinedBehaviorSanitizer, undefined behavior detector.
   Copyright (C) 2013-2024 Free Software Foundation, Inc.
   Contributed by Marek Polacek <polacek@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
The various kinds of NULL pointer checks.   
Enumerator
UBSAN_LOAD_OF 
UBSAN_STORE_OF 
UBSAN_REF_BINDING 
UBSAN_MEMBER_ACCESS 
UBSAN_MEMBER_CALL 
UBSAN_CTOR_CALL 
UBSAN_DOWNCAST_POINTER 
UBSAN_DOWNCAST_REFERENCE 
UBSAN_UPCAST 
UBSAN_CAST_TO_VBASE 

◆ ubsan_print_style

This controls how ubsan prints types.  Used in ubsan_type_descriptor.   
Enumerator
UBSAN_PRINT_NORMAL 
UBSAN_PRINT_POINTER 
UBSAN_PRINT_ARRAY 
UBSAN_PRINT_FORCE_INT 

Function Documentation

◆ is_ubsan_builtin_p()

bool is_ubsan_builtin_p ( tree t)
extern
Return true if T is a call to a libubsan routine.   

References BUILT_IN_NORMAL, DECL_NAME, fndecl_built_in_p(), ggc_alloc(), IDENTIFIER_POINTER, and TREE_CODE.

◆ sanitize_unreachable_fn()

tree sanitize_unreachable_fn ( tree * data,
location_t loc )
extern

◆ ubsan_build_overflow_builtin()

tree ubsan_build_overflow_builtin ( tree_code code,
location_t loc,
tree lhstype,
tree op0,
tree op1,
tree * datap )
extern
Build an ubsan builtin call for the signed-integer-overflow
sanitization.  CODE says what kind of builtin are we building,
LOC is a location, LHSTYPE is the type of LHS, OP0 and OP1
are operands of the binary operation.   

References build_call_expr_loc(), build_fold_addr_expr_loc(), builtin_decl_explicit(), gcc_unreachable, ggc_alloc(), NULL_TREE, SANITIZE_SI_OVERFLOW, ubsan_create_data(), ubsan_encode_value(), UBSAN_ENCODE_VALUE_RTL, and ubsan_type_descriptor().

Referenced by expand_addsub_overflow(), expand_mul_overflow(), and expand_neg_overflow().

◆ ubsan_create_data()

◆ ubsan_encode_value()

◆ ubsan_expand_bounds_ifn()

◆ ubsan_expand_null_ifn()

◆ ubsan_expand_objsize_ifn()

◆ ubsan_expand_ptr_ifn()

◆ ubsan_expand_vptr_ifn()

◆ ubsan_get_source_location_type()

◆ ubsan_instrument_float_cast()

◆ ubsan_instrument_unreachable()

bool ubsan_instrument_unreachable ( gimple_stmt_iterator * gsi)
extern
Rewrite a gcall to __builtin_unreachable for -fsanitize=unreachable.  Called
by the sanopt pass.   

References g, ggc_alloc(), gimple_build_builtin_unreachable(), gimple_location(), gsi_replace(), and gsi_stmt().

◆ ubsan_type_descriptor()

tree ubsan_type_descriptor ( tree type,
enum ubsan_print_style pstyle )
extern
Helper routine that returns ADDR_EXPR of a VAR_DECL of a type
descriptor.  It first looks into the hash table; if not found,
create the VAR_DECL, put it into the hash table and return the
ADDR_EXPR of it.  TYPE describes a particular type.  PSTYLE is
an enum controlling how we want to print the type.   

References wi::add(), build_array_type_nelts(), build_constructor_va(), build_decl(), build_fold_addr_expr, build_int_cst(), build_nonstandard_integer_type(), build_qualified_type(), build_string(), char_type_node, DECL_ARTIFICIAL, DECL_EXTERNAL, decl_for_type_insert(), decl_for_type_lookup(), DECL_IGNORED_P, DECL_INITIAL, DECL_NAME, DECL_SIZE, DECL_SIZE_UNIT, double_type_node, varpool_node::finalize_decl(), float_type_node, gcc_assert, varpool_node::get(), get_identifier(), get_ubsan_type_info_for_type(), ggc_alloc(), IDENTIFIER_POINTER, long_double_type_node, MAX_FIXED_MODE_SIZE, NULL, NULL_TREE, POINTER_TYPE_P, pp_formatted_text(), pp_left_bracket, pp_printf(), pp_quote, pp_right_bracket, pp_space, pp_star, pp_string(), pp_unsigned_wide_integer, pp_wide_int(), short_unsigned_type_node, size_binop, strip_array_types(), wi::to_widest(), TREE_CODE, TREE_CONSTANT, tree_fits_uhwi_p(), TREE_PUBLIC, TREE_READONLY, TREE_STATIC, tree_to_uhwi(), TREE_TYPE, type(), TYPE_ATOMIC, TYPE_DOMAIN, TYPE_MAIN_VARIANT, TYPE_MAX_VALUE, TYPE_METHOD_BASETYPE, TYPE_MODE, TYPE_NAME, TYPE_PRECISION, TYPE_QUAL_CONST, TYPE_READONLY, TYPE_RESTRICT, TYPE_SIGN, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_UNSIGNED, TYPE_VOLATILE, ubsan_get_type_descriptor_type(), ubsan_ids, UBSAN_PRINT_ARRAY, UBSAN_PRINT_FORCE_INT, UBSAN_PRINT_NORMAL, UBSAN_PRINT_POINTER, and UNKNOWN_LOCATION.

Referenced by instrument_bool_enum_load(), ubsan_build_overflow_builtin(), ubsan_expand_bounds_ifn(), ubsan_expand_null_ifn(), ubsan_expand_objsize_ifn(), ubsan_expand_vptr_ifn(), and ubsan_instrument_float_cast().