Frama-C:
Plug-ins:
Libraries:

Frama-C API - Ast_types

This file contains types related types/functions/values.

  • before 31.0-Gallium

    Most of these functions were in Cil

module C : sig ... end

Type Attributes

val get_attributes : Cil_types.typ -> Cil_types.attributes

Returns all the attributes contained in a type. This requires a traversal of the type structure, in case of composite, enumeration and named types

  • deprecated Use Ast_types.C.get_attributes instead.
val add_attributes : ?push_qualifiers:bool -> Cil_types.attribute list -> Cil_types.typ -> Cil_types.typ

Add some attributes to a type. push_qualifiers determines if type qualifiers are pushed to the elements type. It defaults to true and should not be set to false unless you known what you are doing. In Frama-C this is useful for formals (see C11 6.7.6.3#7), so push_qualifiers is turned off when typing array formals before they are changed into pointers.

  • before 31.0-Gallium

    In Cil push_qualifiers was not present, which caused a bug in cabs2cil. Also combine was present and allowed to chose the function used to combine attributes, now it only uses Ast_attributes.add_list.

  • deprecated Use Ast_types.C.add_attributes instead.
val has_attribute : string -> Cil_types.typ -> bool

Does the type have the given attribute. Does not recurse through pointer types, nor inside function prototypes.

  • deprecated Use Ast_types.C.has_attribute instead.
val has_qualifier : string -> Cil_types.typ -> bool

Does the type have the given qualifier. Handles the case of arrays, for which the qualifiers are actually carried by the type of the elements. It is always correct to call this function instead of has_attribute. For l-values, both functions return the same results, as l-values cannot have array type.

  • deprecated Use Ast_types.C.has_qualifier instead.
val has_attribute_memory_block : string -> Cil_types.typ -> bool

has_attribute_memory_block attr t is true iff at least one component of an object of type t has attribute attr. In other words, it searches for attr under aggregates, but not under pointers.

  • deprecated Use Ast_types.C.has_attribute_memory_block instead.
val remove_attributes : string list -> Cil_types.typ -> Cil_types.typ

Remove all attributes with the given names from a type. Note that this does not remove attributes from typedef and tag definitions, just from their uses (unfolding the type definition when needed). It only removes attributes of topmost type, i.e. does not recurse under pointers, arrays, ...

  • deprecated Use Ast_types.C.remove_attributes instead.
val remove_all_attributes : Cil_types.typ -> Cil_types.typ

Same as remove_attributes, but remove any existing attribute from the type.

  • deprecated Use Ast_types.C.remove_all_attributes instead.
val remove_attributes_deep : string list -> Cil_types.typ -> Cil_types.typ

Same as remove_attributes, but recursively removes the given attributes from inner types as well. Mainly useful to check whether two types are equal modulo some attributes. See also Cil.typeDeepDropAllAttributes, which will strip every single attribute from a type.

  • deprecated Use Ast_types.C.remove_attributes_deep instead.
val remove_qualifiers : Cil_types.typ -> Cil_types.typ

Remove all attributes relative to const, volatile and restrict attributes.

  • deprecated Use Ast_types.C.remove_qualifiers instead.
val remove_qualifiers_deep : Cil_types.typ -> Cil_types.typ

Remove also qualifiers under Ptr and Arrays.

  • deprecated Use Ast_types.C.remove_qualifiers_deep instead.
val remove_attributes_for_c_cast : Cil_types.typ -> Cil_types.typ

Remove all attributes relative to const, volatile and restrict attributes when building a C cast

  • deprecated Use Ast_types.C.remove_attributes_for_c_cast instead.
val remove_attributes_for_logic_type : Cil_types.typ -> Cil_types.typ

Remove all attributes relative to const, volatile and restrict attributes when building a logic cast

  • deprecated Use Ast_types.C.remove_attributes_for_logic_type instead.

Utils functions

Unroll a type until it exposes a non TNamed. Will collect all attributes appearing in TNamed and add them to the final type using add_attributes.

  • deprecated Use Ast_types.C.unroll instead.
val unroll_node : Cil_types.typ -> Cil_types.typ_node

Same than unroll but discard the final type attributes and only return its node.

  • deprecated Use Ast_types.C.unroll_node instead.
val unroll_skel : Cil_types.typ -> Cil_types.typ_node

Unroll typedefs, discarding all intermediate attribute. To be used only when one is interested in the shape of the type

  • deprecated Use Ast_types.C.unroll_skel instead.
val unroll_deep : Cil_types.typ -> Cil_types.typ

Unroll all the TNamed in a type (even under type constructors such as TPtr, TFun or TArray. Does not unroll the types of fields in TComp types. Will collect all attributes

  • deprecated Use Ast_types.C.unroll_deep instead.
val unroll_deep_node : Cil_types.typ -> Cil_types.typ_node

Same than unroll_deep but discard the final type attributes and only return its node.

  • deprecated Use Ast_types.C.unroll_deep_node instead.

Const Attribute

val is_const : Cil_types.typ -> bool

Check for "const" qualifier from the type of an l-value using has_attribute_memory_block.

  • deprecated Use Ast_types.C.is_const instead.

Volatile Attribute

val is_volatile : Cil_types.typ -> bool

Check for "volatile" qualifier from the type of an l-value using has_attribute_memory_block.

  • deprecated Use Ast_types.C.is_volatile instead.

Ghost Attribute

val add_ghost : Cil_types.typ -> Cil_types.typ

Add the ghost attribute to a type (does nothing if the type is already ghost).

  • deprecated Use Ast_types.C.add_ghost instead.
val is_ghost : Cil_types.typ -> bool

Check for "ghost" qualifier from the type of an l-value (do not follow pointer)

  • deprecated Use Ast_types.C.is_ghost instead.
val is_wellformed_ghost : Cil_types.typ -> bool

Check if the received type is well-formed according to \ghost semantics, that is once the type is not ghost anymore, \ghost cannot appear again.

  • deprecated Use Ast_types.C.is_wellformed_ghost instead.

Type checkers

val is_void : Cil_types.typ -> bool

is the given type "void"?

  • deprecated Use Ast_types.C.is_void instead.
val is_void_ptr : Cil_types.typ -> bool

is the given type "void *"?

  • deprecated Use Ast_types.C.is_void_ptr instead.
val is_bool : Cil_types.typ -> bool

True if the argument is _Bool.

  • deprecated Use Ast_types.C.is_bool instead.
val is_char : Cil_types.typ -> bool

True if the argument is a plain character type (but neither signed char nor unsigned char).

  • deprecated Use Ast_types.C.is_char instead.
val is_any_char : Cil_types.typ -> bool

True if the argument is a character type (i.e. plain, signed or unsigned).

  • deprecated Use Ast_types.C.is_any_char instead.
val is_char_ptr : Cil_types.typ -> bool

True if the argument is a pointer to a plain character type (but neither signed char nor unsigned char).

  • deprecated Use Ast_types.C.is_char_ptr instead.
val is_any_char_ptr : Cil_types.typ -> bool

True if the argument is a pointer to a character type (i.e. plain, signed or unsigned).

  • deprecated Use Ast_types.C.is_any_char_ptr instead.
val is_char_const_ptr : Cil_types.typ -> bool

True if the argument is a pointer to a constant character type, e.g. a string literal.

  • deprecated Use Ast_types.C.is_char_const_ptr instead.
val is_short : Cil_types.typ -> bool

True if the argument is a short type (i.e. signed or unsigned).

  • deprecated Use Ast_types.C.is_short instead.
val is_integral : Cil_types.typ -> bool

True if the argument is an integral type (i.e. integer or enum).

  • deprecated Use Ast_types.C.is_integral instead.
val is_intptr_t : Cil_types.typ -> bool

True if the argument is intptr_t (but _not_ its underlying integer type).

  • deprecated Use Ast_types.C.is_intptr_t instead.
val is_uintptr_t : Cil_types.typ -> bool

True if the argument is uintptr_t (but _not_ its underlying integer type).

  • deprecated Use Ast_types.C.is_uintptr_t instead.
val is_float : Cil_types.typ -> bool

True if the argument is a floating point type.

  • deprecated Use Ast_types.C.is_float instead.
val is_long_double : Cil_types.typ -> bool

True if the argument is a long double type.

  • deprecated Use Ast_types.C.is_long_double instead.
val is_arithmetic : Cil_types.typ -> bool

True if the argument is an arithmetic type (i.e. integer, enum or floating point.

  • deprecated Use Ast_types.C.is_arithmetic instead.
val is_ptr : Cil_types.typ -> bool

True if the argument is a pointer type.

  • deprecated Use Ast_types.C.is_ptr instead.
val is_integral_or_pointer : Cil_types.typ -> bool

True if the argument is an integral or pointer type.

  • deprecated Use Ast_types.C.is_integral_or_pointer instead.
val is_array : Cil_types.typ -> bool

True if the argument is an array type.

  • deprecated Use Ast_types.C.is_array instead.
val is_unsized_array : Cil_types.typ -> bool

True if the argument is an array type without size.

  • deprecated Use Ast_types.C.is_unsized_array instead.
val is_sized_array : Cil_types.typ -> bool

True if the argument is a sized array type.

  • deprecated Use Ast_types.C.is_sized_array instead.
val is_char_array : Cil_types.typ -> bool

True if the argument is an array of a character type (i.e. plain, signed or unsigned).

  • deprecated Use Ast_types.C.is_char_array instead.
val is_any_char_array : Cil_types.typ -> bool

True if the argument is an array of a character type (i.e. plain, signed or unsigned).

  • deprecated Use Ast_types.C.is_any_char_array instead.
val is_wchar_array : Cil_types.typ -> bool

True if the argument is an array of wchar_t. Can only be used after Machdep has been set.

  • since 32.0-Germanium
  • deprecated Use Ast_types.C.is_wchar_array instead.
val is_fun : Cil_types.typ -> bool

True if the argument is a function type.

  • deprecated Use Ast_types.C.is_fun instead.
val is_variadic : Cil_types.typ -> bool

True if the argument is a variadic function type.

  • since 33.0-Arsenic
  • deprecated Use Ast_types.C.is_variadic instead.
val is_fun_ptr : Cil_types.typ -> bool

True if the argument is a function pointer type.

  • deprecated Use Ast_types.C.is_fun_ptr instead.
val is_fun_or_ptr : Cil_types.typ -> bool

True if the argument is a pointer or a function type.

  • since 33.0-Arsenic
  • deprecated Use Ast_types.C.is_fun_or_ptr instead.
val is_scalar : Cil_types.typ -> bool

True if the argument is a scalar type (i.e. integral, enum, floating point or pointer.

  • deprecated Use Ast_types.C.is_scalar instead.
val is_object : Cil_types.typ -> bool

True if the argument is an object type (i.e. not a function type).

  • deprecated Use Ast_types.C.is_object instead.
val is_object_ptr : Cil_types.typ -> bool

True if the argument is an object pointer type.

  • since 33.0-Arsenic
  • deprecated Use Ast_types.C.is_object_ptr instead.
val is_struct : Cil_types.typ -> bool

True if the argument is a struct.

  • deprecated Use Ast_types.C.is_struct instead.
val has_bitfield : Cil_types.typ -> bool

True if the argument is a type that directly (modulo name) contains a bitfield.

  • since 32.0-Germanium
  • deprecated Use Ast_types.C.has_bitfield instead.
val is_union : Cil_types.typ -> bool

True if the argument is a union type.

  • deprecated Use Ast_types.C.is_union instead.
val is_struct_or_union : Cil_types.typ -> bool

True if the argument is a struct or union type.

  • deprecated Use Ast_types.C.is_struct_or_union instead.
val is_transparent_union : Cil_types.typ -> Cil_types.fieldinfo option

Check if a type is a transparent union, and return the first field.

  • deprecated Use Ast_types.C.is_transparent_union instead.
val is_variadic_list : Cil_types.typ -> bool

True if the argument denotes the type of ... in a variadic function.

  • deprecated Use Ast_types.C.is_variadic_list instead.

Type access

val direct_element_type : Cil_types.typ -> Cil_types.typ

Returns the type of the array elements of the given type.

  • raises AbortFatal

    if argument is not an array type.

  • deprecated Use Ast_types.C.direct_array_element instead.
val element_type : Cil_types.typ -> Cil_types.typ

Returns the elements type using direct_element_type, but if the resulting type is an array, recursively call element_type.

  • deprecated Use Ast_types.C.array_element instead.
val direct_pointed_type : Cil_types.typ -> Cil_types.typ

Returns the type directly pointed by the given type.

  • raises AbortFatal

    it is not a pointer type.

  • deprecated Use Ast_types.C.direct_pointed instead.
val pointed_type : Cil_types.typ -> Cil_types.typ

Returns the pointed type using direct_pointed, but if the resulting type is an array, returns the element type instead using element_type

  • deprecated Use Ast_types.C.pointed instead.
val array_elem_type_and_size : Cil_types.typ -> Cil_types.typ * Cil_types.exp option

Returns the type of the array elements of the given type, and the size of the array, if any.

  • raises AbortFatal

    it is not an array type.

  • before 31.0-Gallium

    In Cil this function applied Cil.constFoldToInt on array's size and returned a Z.t option.

  • deprecated Use Ast_types.C.array_elem_type_and_size instead.

Logic Types

module Acsl : sig ... end

This module contains all functions related to logic types. Most of these functions where moved from Logic_const or Logic_utils and renamed for better consistency.

val unroll_logic : ?unroll_typedef:bool -> Cil_types.logic_type -> Cil_types.logic_type

Expands logic type definitions. If the unroll_typedef flag is set to true (this is the default), C typedef will be expanded as well using Ast_types.Acsl.unroll_ltdef.

  • deprecated Use Ast_types.Acsl.unroll instead
val is_logic_volatile : Cil_types.logic_type -> bool

Check for "volatile" qualifier from a logic type using is_volatile.

  • deprecated Use Ast_types.Acsl.is_plain_volatile instead
val is_logic_typetag : Cil_types.logic_type -> bool

True if the argument is the type for reified C types.

  • deprecated Use Ast_types.Acsl.is_plain_typetag instead
val is_logic_boolean : Cil_types.logic_type -> bool

True if the argument is a boolean type, either integral C type or mathematical boolean one.

  • deprecated Use Ast_types.Acsl.is_plain_boolean instead
val is_logic_pure_boolean : Cil_types.logic_type -> bool

True if the argument is _Bool or Lboolean.

  • deprecated Use Ast_types.Acsl.is_plain_pure_boolean instead
val is_logic_integral : Cil_types.logic_type -> bool

True if the argument is an integral type (i.e. integer or enum), either C or mathematical one.

  • deprecated Use Ast_types.Acsl.is_plain_integral instead
val is_logic_float : Cil_types.logic_type -> bool

True if the argument is a floating point type.

  • deprecated Use Ast_types.Acsl.is_plain_float instead
val is_logic_real : Cil_types.logic_type -> bool

True if the argument is the logic 'real' type.

  • deprecated Use Ast_types.Acsl.is_plain_real instead
val is_logic_real_or_float : Cil_types.logic_type -> bool

True if the argument is a C floating point type or logic 'real' type.

  • deprecated Use Ast_types.Acsl.is_plain_real_or_float instead
val is_logic_arithmetic : Cil_types.logic_type -> bool

True if the argument is a logic arithmetic type (i.e. integer, enum or floating point, either C or mathematical one.

  • deprecated Use Ast_types.Acsl.is_plain_arithmetic instead
val is_logic_ptr : Cil_types.logic_type -> bool

True if the argument is a pointer type. Expands the logic type definition if necessary.

  • since 33.0-Arsenic
  • deprecated Use Ast_types.Acsl.is_plain_ptr instead
val is_logic_fun : Cil_types.logic_type -> bool

True if the argument is the logic function type. Expands the logic type definition if necessary.

  • deprecated Use Ast_types.Acsl.is_plain_fun instead
val is_logic_fun_ptr : Cil_types.logic_type -> bool

True if the argument is the logic function pointer type. Expands the logic type definition if necessary.

  • deprecated Use Ast_types.Acsl.is_plain_fun_ptr instead
val is_logic_fun_or_ptr : Cil_types.logic_type -> bool

True if the argument is a pointer or function type. Expands the logic type definition if necessary.

  • since 33.0-Arsenic
  • deprecated Use Ast_types.Acsl.is_plain_fun_or_ptr instead