Module Clang__.Clang__utils
include sig ... end
include sig ... end
val string_of_language : Clang__.Clang__types.language -> string
val language_of_string : string -> Clang__.Clang__types.language
val language_of_string_opt : string -> Clang__.Clang__types.language option
val suffix_of_language : Clang__.Clang__types.language -> string
val extern_of_language : Clang__.Clang__types.language -> string
val string_of_cxx_access_specifier : Clang__.Clang__bindings.cx_cxxaccessspecifier -> string
Compatibility layer
include sig ... end
val predefined_expr_get_function_name : Clang__.Clang__bindings.cxcursor -> Clang__.Clang__bindings.cxcursor -> string
include sig ... end
Parsing files and strings
val parse_file : ?index:Clang__.Clang__bindings.cxindex -> ?command_line_args:string list -> ?unsaved_files:Clang__.Clang__bindings.cxunsavedfile list -> ?options:Clang__.Clang__bindings.Cxtranslationunit_flags.t -> string -> Clang__.Clang__bindings.cxtranslationunit
parse_file ?index ?command_line_args ?unsaved_files ?options filename
parses filefilename
and returns its translation unit. This function is equivalent toClang.parse_translation_unit2
, with, by default, a freshindex
(created byClang.create_index
true true
), an empty list forcommand_line_args
andunsaved_files
, and defaultoptions
(obtained byClang.default_editing_translation_unit_options
). See alsoClang.Ast.parse_file
which returns a pattern-matchable representation of the AST.
val parse_file_res : ?index:Clang__.Clang__bindings.cxindex -> ?command_line_args:string list -> ?unsaved_files:Clang__.Clang__bindings.cxunsavedfile list -> ?options:Clang__.Clang__bindings.Cxtranslationunit_flags.t -> string -> (Clang__.Clang__bindings.cxtranslationunit, Clang__.Clang__bindings.cxerrorcode) Stdcompat.result
Equivalent to
parse_file
but returns aresult
instead of raisingFailure _
if parsing fails.
val parse_string : ?index:Clang__.Clang__bindings.cxindex -> ?filename:string -> ?command_line_args:string list -> ?unsaved_files:Clang__.Clang__bindings.cxunsavedfile list -> ?options:Clang__.Clang__bindings.Cxtranslationunit_flags.t -> string -> Clang__.Clang__bindings.cxtranslationunit
parse_string ?index ?filename ?command_line_args ?unsaved_files ?options contents
parses stringcontents
and returns its translation unit. This function callsClang.parse_file
with an unsaved file calledfilename
(by default,<string>.c
) withcontents
: this unsaved file is consed to the listunsaved_files
(by default, an empty list). Note thatfilename
should have the.cpp
suffix to parse C++ code (for instance,<string>.cpp
). See alsoClang.Ast.parse_string
which returns a pattern-matchable representation of the AST.
val parse_string_res : ?index:Clang__.Clang__bindings.cxindex -> ?filename:string -> ?command_line_args:string list -> ?unsaved_files:Clang__.Clang__bindings.cxunsavedfile list -> ?options:Clang__.Clang__bindings.Cxtranslationunit_flags.t -> string -> (Clang__.Clang__bindings.cxtranslationunit, Clang__.Clang__bindings.cxerrorcode) Stdcompat.result
Equivalent to
parse_string
but returns aresult
instead of raisingFailure _
if parsing fails.
Iterators
val iter_children : (Clang__.Clang__bindings.cxcursor -> unit) -> Clang__.Clang__bindings.cxcursor -> unit
iter_children f cur
callsf
over all the direct child nodes ofcur
.
val list_of_children : Clang__.Clang__bindings.cxcursor -> Clang__.Clang__bindings.cxcursor list
list_of_children cur
returns the list of all the direct child nodes ofcur
.
val iter_type_fields : (Clang__.Clang__bindings.cxcursor -> unit) -> Clang__.Clang__bindings.cxtype -> unit
iter_type_fields f ty
callsf
over all the declaration nodes of the fields belonging to the record typety
(either a struct or union). See alsoClang.Type.iter_fields
for a higher-level interface.
val list_of_type_fields : Clang__.Clang__bindings.cxtype -> Clang__.Clang__bindings.cxcursor list
list_of_type_fields f ty
returns the list of all the declaration nodes of the fields belonging to the record typety
(either a struct or union).
val iter_decl_context : (Clang__.Clang__bindings.cxcursor -> unit) -> Clang__.Clang__bindings.cxcursor -> unit
iter_decl_context f c
callsf
over all the declaration nodes of declaration contextc
.
val list_of_decl_context : Clang__.Clang__bindings.cxcursor -> Clang__.Clang__bindings.cxcursor list
list_of_decl_context f ty
returns the list of all the declaration nodes of declaration contextc
.
val list_of_iter : (('a -> unit) -> unit) -> 'a list
list_of_iter iter
callsiter f
and returns all the values whichf
has been applied to.
val is_integer : Clang__.Clang__bindings.cxtypekind -> bool
Integer or floating point types
is_integer ty
returns true ifty
is a built-in integer type.
val is_unsigned_integer : Clang__.Clang__bindings.cxtypekind -> bool
is_unsigned_integer ty
returns true ifty
is a built-in integer type that is unsigned.
val is_signed_integer : Clang__.Clang__bindings.cxtypekind -> bool
is_signed_integer ty
returns true ifty
is a built-in integer type that is signed.
val is_floating_point : Clang__.Clang__bindings.cxtypekind -> bool
is_floating_point ty
returns true ifty
is a built-in floating-point type.
Integer conversions
val int64_of_cxint_opt : ?signed:bool -> Clang__.Clang__bindings.cxint -> Stdcompat.Int64.t option
int64_of_cxint_opt ~signed x
returnsSome i
ifx
is representable as a 64-bit integer valuei
, orNone
otherwise.signed
specifies ifx
is signed (default: true).
val int64_of_cxint : ?signed:bool -> Clang__.Clang__bindings.cxint -> Stdcompat.Int64.t
int64_of_cxint x
returnsi
ifx
is representable as a 64-bit integer valuei
, or raisesInvalid_argument _
otherwise.signed
specifies ifx
is signed (default: true).
val int_of_cxint_opt : ?signed:bool -> Clang__.Clang__bindings.cxint -> int option
int_of_cxint_opt x
returnsSome i
ifx
is representable as an integer valuei
, orNone
otherwise.signed
specifies ifx
is signed (default: true).
val int_of_cxint : ?signed:bool -> Clang__.Clang__bindings.cxint -> int
int_of_cxint x
returnsi
ifx
is representable as an integer valuei
, or raisesInvalid_argument _
otherwise.signed
specifies ifx
is signed (default: true).
val string_of_cxint : ?signed:bool -> Clang__.Clang__bindings.cxint -> string
string_of_cxint f
is an alias forClang__bindings.ext_int_to_string
, radix 10.signed
specifies ifx
is signed (default: true).
Floating conversions
val float_of_cxfloat_opt : Clang__.Clang__bindings.cxfloat -> float option
float_of_cxfloat_opt x
returnsSome f
ifx
is a floating-point value with either IEEE single or double semantics, orNone
otherwise.
val float_of_cxfloat : Clang__.Clang__bindings.cxfloat -> float
float_of_cxfloat x
returnsf
ifx
is a floating-point value with either IEEE single or double semantics, or raisesInvalid_argument _
otherwise.
val string_of_cxfloat : Clang__.Clang__bindings.cxfloat -> string
string_of_cxfloat f
is an alias forClang__bindings.ext_float_to_string
.
Error management
val string_of_cxerrorcode : Clang__.Clang__bindings.cxerrorcode -> string
string_of_cxerrorcode ec
returns a message describingec
.
val seq_of_diagnostics : Clang__.Clang__bindings.cxtranslationunit -> Clang__.Clang__bindings.cxdiagnostic Stdcompat.Seq.t
seq_of_diagnostics tu
returns the diagnostics (notes, warnings, errors, ...) produced for the given translation unit
val concrete_of_cxsourcelocation : Clang__.Clang__types.location_kind -> Clang__.Clang__bindings.cxsourcelocation -> Clang__.Clang__types.concrete_location
concrete_of_cxsourcelocation kind location
returns the concrete location associated tolocation
.kind
selects whetherClang.get_presumed_location
(which ignores#
line directive) orClang.get_expansion_location
(which honors#
line directive) is called.
val string_of_severity : Clang__.Clang__bindings.cxdiagnosticseverity -> string
string_of_severity severity
returns a string describing the severity: this string is used as prefix for the diagnostic inpp_diagnostic
.
val pp_diagnostic : ?options:Clang__.Clang__types.Diagnostic_display_options.t -> Stdcompat.Format.formatter -> Clang__.Clang__bindings.cxdiagnostic -> unit
pp_diagnostic ?options fmt diag
formats diagnosticdiag
, mimickingClang__bindings.format_diagnostic
behavior.Clang__types.Display_source_location.t.kind
supports various location kinds whereasClang__bindings.format_diagnostic
only displays spelling locations.
val format_diagnostics : ?pp:((Stdcompat.Format.formatter -> unit -> unit) -> Stdcompat.Format.formatter -> unit -> unit) -> ?options:Clang__.Clang__types.Diagnostic_display_options.t -> Clang__.Clang__bindings.cxdiagnosticseverity list -> Stdcompat.Format.formatter -> Clang__.Clang__bindings.cxtranslationunit -> unit
format_diagnostics ?pp severities fmt tu
formats the diagnostics produced for the given translation unit. Only the diagnostics, the severity of which is listed inseverities
are displayed. If there is a printer given inpp
, then this printer is called once if and only if there is at least one diagnostic to display, andpp
should call the printer passed in its first argument to display the diagnostics. In the case there is no diagnostic to display, nothing is printed.
val error : Clang__.Clang__bindings.cxdiagnosticseverity list
error
contains the severitiesError
andFatal
.
val warning_or_error : Clang__.Clang__bindings.cxdiagnosticseverity list
warning_or_error
contains the severitiesWarning
,Error
andFatal
.
val not_ignored_diagnostics : Clang__.Clang__bindings.cxdiagnosticseverity list
not_ignored_diagnostics
contains the severitiesNote
,Warning
,Error
andFatal
.
val all_diagnostics : Clang__.Clang__bindings.cxdiagnosticseverity list
all_diagnostics
contains the severitiesIgnored
,Note
,Warning
,Error
andFatal
.
val has_severity : Clang__.Clang__bindings.cxdiagnosticseverity list -> Clang__.Clang__bindings.cxtranslationunit -> bool
has_severity l tu
returns whether the translation unittu
produced a diagnostic, the severity of which belongs tol
.
val cursor_get_translation_unit : Clang__.Clang__bindings.cxcursor -> Clang__.Clang__bindings.cxtranslationunit
cursor_get_translation_unit cursor
returns the translation unit associated tocursor
.
val sourcelocation_get_translation_unit : Clang__.Clang__bindings.cxsourcelocation -> Clang__.Clang__bindings.cxtranslationunit
sourcelocation_get_translation_unit location
returns the translation unit associated tolocation
.
val binary_of_overloaded_operator_kind : Clang__.Clang__bindings.clang_ext_overloadedoperatorkind -> Clang__.Clang__bindings.clang_ext_binaryoperatorkind