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

Go to the source code of this file.

Data Structures

class  ssa_name_limit_t
 
struct  access_ref
 
class  pointer_query
 
struct  pointer_query::cache_type
 
struct  access_data
 

Enumerations

enum  size_range_flags { SR_ALLOW_ZERO = 1 , SR_USE_LARGEST = 2 }
 

Functions

bool get_size_range (tree, tree[2], int=0)
 
bool get_size_range (range_query *, tree, gimple *, tree[2], int=0)
 
tree gimple_call_alloc_size (gimple *, wide_int[2]=nullptr, range_query *=nullptr)
 
tree compute_objsize (tree, gimple *, int, access_ref *, range_query *=nullptr)
 
tree compute_objsize (tree, gimple *, int, access_ref *, pointer_query *)
 
tree compute_objsize (tree ptr, int ostype, access_ref *pref)
 
tree compute_objsize (tree, gimple *, int, tree *=nullptr, tree *=nullptr, range_query *=nullptr)
 
tree compute_objsize (tree ptr, int ostype, tree *pdecl=nullptr, tree *poff=nullptr, range_query *rvals=nullptr)
 
tree field_at_offset (tree, tree, HOST_WIDE_INT, HOST_WIDE_INT *=nullptr, HOST_WIDE_INT *=nullptr)
 
tree array_elt_at_offset (tree, HOST_WIDE_INT, HOST_WIDE_INT *=nullptr, HOST_WIDE_INT *=nullptr)
 
tree build_printable_array_type (tree, unsigned HOST_WIDE_INT)
 

Enumeration Type Documentation

◆ size_range_flags

Enumerator
SR_ALLOW_ZERO 
SR_USE_LARGEST 

Function Documentation

◆ array_elt_at_offset()

tree array_elt_at_offset ( tree artype,
HOST_WIDE_INT off,
HOST_WIDE_INT * eltoff,
HOST_WIDE_INT * subar_size )
extern
Return the array at the constant offset.   
Determine the offset *ELTOFF of the first byte of the array element
of array ARTYPE into which the byte offset OFF points.  On success
set *ELTOFF to the offset of the first byte and return type.
Otherwise, if no such element can be found, return null.   

References char_type_node, gcc_assert, ggc_alloc(), int_size_in_bytes(), NULL_TREE, RECORD_OR_UNION_TYPE_P, TREE_CODE, TREE_TYPE, and TYPE_MODE.

Referenced by field_at_offset().

◆ build_printable_array_type()

tree build_printable_array_type ( tree eltype,
unsigned HOST_WIDE_INT nelts )
extern
Helper to build an array type that can be printed.   
Wrapper around build_array_type_nelts that makes sure the array
can be created at all and handles zero sized arrays specially.   

References bitsize_zero_node, build_array_type(), build_array_type_nelts(), build_distinct_type_copy(), build_range_type(), ffs_hwi(), ggc_alloc(), HOST_WIDE_INT_MAX, integer_zerop(), NULL_TREE, size_zero_node, sizetype, wi::to_wide(), TREE_CODE, TYPE_ALIGN_UNIT, TYPE_MAIN_VARIANT, TYPE_SIZE, TYPE_SIZE_UNIT, and wi::zext().

Referenced by array_bounds_checker::check_mem_ref().

◆ compute_objsize() [1/5]

tree compute_objsize ( tree ptr,
int ostype,
access_ref * pref )
inline

References compute_objsize(), and pref.

◆ compute_objsize() [2/5]

tree compute_objsize ( tree ptr,
int ostype,
tree * pdecl = nullptr,
tree * poff = nullptr,
range_query * rvals = nullptr )
inline

References compute_objsize(), and ggc_alloc().

◆ compute_objsize() [3/5]

tree compute_objsize ( tree ptr,
gimple * stmt,
int ostype,
access_ref * pref,
pointer_query * ptr_qry )
extern

◆ compute_objsize() [4/5]

tree compute_objsize ( tree ptr,
gimple * stmt,
int ostype,
access_ref * pref,
range_query * rvals )
extern
Compute the size of an object referenced by the first argument in
a statement given by second argument, using Object Size Type given
by third argument.  Store result in an access_ref.   
Transitional wrapper.  The function should be removed once callers
transition to the pointer_query API.   

References compute_objsize(), ggc_alloc(), and pref.

Referenced by compute_objsize(), compute_objsize(), pointer_query::get_ref(), and access_ref::inform_access().

◆ compute_objsize() [5/5]

tree compute_objsize ( tree ptr,
gimple * stmt,
int ostype,
tree * pdecl,
tree * poff,
range_query * rvals )
extern
Legacy/transitional API.  Should not be used in new code.   
Legacy wrapper around the above.  The function should be removed
once callers transition to one of the two above.   

References access_ref::base0, compute_objsize(), ggc_alloc(), NULL_TREE, access_ref::offrng, ptrdiff_type_node, access_ref::ref, and wide_int_to_tree().

◆ field_at_offset()

tree field_at_offset ( tree type,
tree start_after,
HOST_WIDE_INT off,
HOST_WIDE_INT * fldoff,
HOST_WIDE_INT * nextoff )
extern
Return the field at the constant offset.   
Determine the offset *FLDOFF of the first byte of a struct member
of TYPE (possibly recursively) into which the byte offset OFF points,
starting after the field START_AFTER if it's non-null.  On success,
if nonnull, set *FLDOFF to the offset of the first byte, and return
the field decl.  If nonnull, set *NEXTOFF to the offset of the next
field (which reflects any padding between the returned field and
the next).  Otherwise, if no such member can be found, return null.   

References array_elt_at_offset(), byte_position(), DECL_ARTIFICIAL, field_at_offset(), ggc_alloc(), HOST_WIDE_INT_MAX, int_byte_position(), NULL_TREE, TREE_CHAIN, TREE_CODE, tree_fits_shwi_p(), tree_fits_uhwi_p(), tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_FIELDS, and TYPE_SIZE_UNIT.

Referenced by field_at_offset(), and get_maxbound().

◆ get_size_range() [1/2]

bool get_size_range ( range_query * query,
tree exp,
gimple * stmt,
tree range[2],
int flags )
extern
Return true when EXP's range can be determined and set RANGE[] to it
after adjusting it if necessary to make EXP a represents a valid size
of object, or a valid size argument to an allocation function declared
with attribute alloc_size (whose argument may be signed), or to a string
manipulation function like memset.
When ALLOW_ZERO is set in FLAGS, allow returning a range of [0, 0] for
a size in an anti-range [1, N] where N > PTRDIFF_MAX.  A zero range is
a (nearly) invalid argument to allocation functions like malloc but it
is a valid argument to functions like memset.
When USE_LARGEST is set in FLAGS set RANGE to the largest valid subrange
in a multi-range, otherwise to the smallest valid subrange.   

References cfun, wi::eq_p(), exp(), wide_int_storage::from(), get_legacy_range(), get_range_query(), ggc_alloc(), INTEGRAL_TYPE_P, wi::les_p(), wi::leu_p(), wi::ltu_p(), max_object_size(), NULL_TREE, range_query::range_of_expr(), irange::set_varying(), SR_ALLOW_ZERO, SR_USE_LARGEST, wi::to_wide(), tree_fits_uhwi_p(), TREE_TYPE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, TYPE_UNSIGNED, vrange::undefined_p(), UNSIGNED, VR_ANTI_RANGE, VR_VARYING, wide_int_to_tree(), and wi::zero().

Referenced by get_size_range(), and gimple_call_alloc_size().

◆ get_size_range() [2/2]

bool get_size_range ( tree exp,
tree range[2],
int flags = 0 )
extern

References exp(), get_size_range(), and NULL.

Referenced by access_data::set_bound().

◆ gimple_call_alloc_size()

tree gimple_call_alloc_size ( gimple * stmt,
wide_int rng1[2],
range_query * qry )
extern
If STMT is a call to an allocation function, returns the constant
maximum size of the object allocated by the call represented as
sizetype.  If nonnull, sets RNG1[] to the range of the size.
When nonnull, uses RVALS for range information, otherwise gets global
range info.
Returns null when STMT is not a call to a valid allocation function.   

References ADDR_MAX_PRECISION, fold_convert, get_size_range(), ggc_alloc(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_fndecl(), gimple_call_fntype(), gimple_call_num_args(), wi::gtu_p(), integer_one_node, is_gimple_call(), lookup_attribute(), NULL_TREE, r, sizetype, SR_ALLOW_ZERO, SR_USE_LARGEST, wi::to_wide(), TREE_CHAIN, TREE_CODE, TREE_INT_CST_LOW, TREE_TYPE, TREE_VALUE, TYPE_ATTRIBUTES, TYPE_MAX_VALUE, UINT_MAX, and wide_int_to_tree().

Referenced by strlen_pass::handle_builtin_stxncpy_strncat(), and handle_ssa_name().