Coccilib.3cocci man page

Coccilib — Library of functions for use with Coccinelle OCaml script code

Module

Module Coccilib

Documentation

Module Coccilib
: sig end

=== Positions ===

type pos = {
current_element : string ;
file : string ;
line : int ;
col : int ;
line_end : int ;
col_end : int ;
}

A value of type pos describes a position in a source file. current_element is the name of the function containing the matched position; file is the name of the file containing the matched position; line is the number of the line containing the first character of the matched position; col is the (0-based) column containing the first character of the matched position; line_end is the number of the line containing the last character of the matched position; col_end is the (0-based) column containing the last character of the matched position.

=== Abstract Syntax Tree ===

type param_type
=
| Pos of pos list
| Str of string
| Type of Ast_c.fullType
| Init of Ast_c.initialiser
| InitList of Ast_c.initialiser Ast_c.wrap2 list
| Int of int
| Param of Ast_c.parameterType
| ParamList of Ast_c.parameterType Ast_c.wrap2 list
| Expr of Ast_c.expression
| ExprList of Ast_c.argument Ast_c.wrap2 list
| Decl of Ast_c.declaration
| Field of Ast_c.field
| FieldList of Ast_c.field list
| Stmt of Ast_c.statement

val make_ident : string -> Ast_c.metavar_binding_kind

Make an identifier

val make_expr : string -> Ast_c.metavar_binding_kind

Make an expression

val make_expr_with_env : string -> string -> Ast_c.metavar_binding_kind

Make an expression in a type environment. The first argument is a string containing any C variable declarations needed to make the environment and the second argument is a string containing the expression.

val make_stmt : string -> Ast_c.metavar_binding_kind

Make a single statement

val make_stmt_in_env : string -> Ast_c.metavar_binding_kind

Make a single statement in a type environment. The first argument is a string containing any C variable declarations needed to make the environment and the second argument is a string containing the statement.

val make_type : string -> Ast_c.metavar_binding_kind

Make a type

val make_listlen : int -> Ast_c.metavar_binding_kind

Make a list length, for parameter lists, expression lists, etc.

val make_position : string -> string -> int -> int -> int -> int -> Ast_c.metavar_binding_kind

Make a position. The arguments are the file name, the function or other toplevel element containing the position, the starting line, the starting column, the ending line, and the ending column. Lines start at 1. Columns start at 0. The ending line is the one that contains the last character of what is to be matched. The ending character is one past the last character of the thing to be matched.

=== Match management functions ===

val include_match : bool -> unit

If the argument is true, retain the environment with respect to which the ocaml script code is being executed for use in subsequent rules. If the argument is false, discard this environment. By default, the environment is retained.

val exit : unit -> unit

If called, aborts the treatment of the current file. All previous changes take effect.

val dir : unit -> string

Returns the directory on which spatch was launched.

val files : unit -> string list

Returns the list of files on which spatch is currently working. The result is the empty list if spatch is not currently working on any file (eg, in an initialize or finalize rule).

val cocci_version : unit -> string

Returns a string indicating the current version. Note that if Coccinelle has been modified since a release, the version number will be postfixed with "-dirty".

val print_main : ?color:string -> string -> pos list -> unit

Print information about a main position using org mode.

val print_sec : ?color:string -> string -> pos list -> unit

Print information about a single secondary position using org mode.

val print_secs : ?color:string -> string -> pos list -> unit

Print information about a list of secondary positions using org mode.

References

Y. Padioleau, J.L. Lawall, R.R Hansen, G. Muller "Documenting and Automating Collateral Evolutions in Linux Device Driver" EuroSys 2008, Glasgow, Scotland (April 2008) pp. 247-260.

Author

This manual page was written by Julia Lawall <Julia.Lawall@lip6.fr>.

Reporting Bugs

Send a mail to <cocci@systeme.lip6.fr>

Info

Jul 26, 2015