Module Clang.Type

AST types as ordered types.

type t = Ast.qual_type
val equal : t -> t -> bool
val compare : t -> t -> int
module Set : Stdcompat.Set.S with type Set.elt = t
module Map : Stdcompat.Map.S with type Map.key = t
val of_node : ?⁠options:Ast.Options.t -> 'a Ast.node -> t

of_node ?options node returns the type associated to node. If node comes from libclang's AST, the function calls get_cursor_type to the associated cursor. If node has been constructed and decorated with a type ty, ty is returned. If node has been constructed without type decoration, Invalid_arg _ is raised. It is equivalent to Clang.Type.of_decoration ?options (Clang.Ast.decoration_of_node node).

val make : ?⁠const:bool -> ?⁠volatile:bool -> ?⁠restrict:bool -> Ast.type_desc -> t

make ?const ?volatile ?restrict desc returns a type from a description, associated to an invalid libclang's type. This function can be useful to construct types from OCaml programs, for instance to describe a program transformation.

val of_cxtype : ?⁠options:Ast.Options.t -> cxtype -> t

of_cxtype ?options ty translates ty into its high-level representation.

val of_cursor : ?⁠options:Ast.Options.t -> cxcursor -> t

of_cxcursor ?options cu returns the type associated to cu.

val of_decoration : ?⁠options:Ast.Options.t -> Ast.decoration -> t

of_decoration ?options d returns the type associated to d.

val iter_fields : ?⁠options:Ast.Options.t -> (Ast.decl -> unit) -> t -> unit

iter_fields ?options f ty calls f over all the declaration nodes of the fields belonging to the record type ty (either a struct or union). It is equivalent to Clang.iter_type_fields (fun d -> f (Clang.Decl.of_cursor ?options d)) ty.cxtype.

val list_of_fields : ?⁠options:Ast.Options.t -> t -> Ast.decl list

list_of_fields ?options f ty returns the list of all the declaration nodes of the fields belonging to the record type ty (either a struct or union). It is equivalent to List.map (Clang.Decl.of_cursor ?options) (Clang.list_of_type_fields ty.cxtype).

val get_declaration : ?⁠options:Ast.Options.t -> t -> Ast.decl

get_declaration ?options ty returns the declaration node of ty. It is equivalent to Clang.Decl.of_cxcursor ?options (Clang.get_type_declaration ty.cxtype).

val get_typedef_underlying_type : ?⁠options:Ast.Options.t -> t -> t

get_declaration ?options ty returns the underlying type of a typedef ty. It is equivalent to Clang.Type.of_cxtype ?options (Clang.get_typedef_decl_underlying_type (Clang.get_type_declaration ty.cxtype)).

val get_align_of : t -> int

get_align_of ty returns the alignment of ty in bytes. It is equivalent to Clang.type_get_align_of ty.cxtype.

val get_size_of : t -> int

get_align_of ty returns the size of ty in bytes. It is equivalent to Clang.type_get_size_of ty.cxtype.