Frama-C API - Visitor

Frama-C visitors dealing with projects.

class type frama_c_visitor = object ... end

Class type for a database-aware visitor. This is done by defining auxiliary methods that can be redefined in inherited classes, while the corresponding ones from Cil.cilVisitor must retain their values as defined here. Otherwise, annotations may not be visited properly. The replaced functions are

in-place visitor; always act in the current project.

Copying visitor. The Project.t argument specifies in which project the visitor creates the new values. (Technically, the method fill_global_tables is called inside this project.) See File.init_project_from_visitor and create_project_from_visitor for possible uses.

Similar to frama_c_copy, but ids will be refreshed in the copy.

Generic class that abstracts over frama_c_inplace and frama_c_copy.

val visitFramacFileCopy : frama_c_visitor -> Cil_types.file -> Cil_types.file

Visit a file. This will re-cons all globals TWICE (so that it is tail-recursive). Use Cil.visitCilFileSameGlobals if your visitor will not change the list of globals.

val visitFramacFile : frama_c_visitor -> Cil_types.file -> unit

Same thing, but the result is ignored. The given visitor must thus be an inplace visitor. Nothing is done if the visitor is a copy visitor.

val visitFramacFileSameGlobals : frama_c_visitor -> Cil_types.file -> unit

A visitor for the whole file that does not change the globals (but maybe changes things inside the globals). Use this function instead of Visitor.visitFramacFile whenever appropriate because it is more efficient for long files.

val visitFramacFileFunctions : frama_c_visitor -> Cil_types.file -> unit

Visit all function definitions of a file. Use this function instead of Visitor.visitFramacFile or Visitor.visitFramacFileSameGlobals if your visitor only needs function bodies to avoid visiting other globals, including libc functions and their specifications.

  • since 25.0-Manganese
val visitFramacGlobal : frama_c_visitor -> -> list

Visit a global.

Warning Do not call this function during another visit using the same visitor, as it is not reentrant: the inner visit will leave the visitor in an inconsistent state for the outer visit.

Visit a kernel_function. More precisely, the entry point for the visit will be the global corresponding to the last declaration/definition of the kf. The returned kf is the one that has the varinfo associated to the varinfo of the original kf. If this is a new kf, it is however the responsibility of the visitor to insert it in the AST at the appropriate place.

  • since Aluminium-20160501
val visitFramacExpr : frama_c_visitor -> Cil_types.exp -> Cil_types.exp

Visit an expression

val visitFramacLval : frama_c_visitor -> Cil_types.lval -> Cil_types.lval

Visit an lvalue

val visitFramacOffset : frama_c_visitor -> Cil_types.offset -> Cil_types.offset

Visit an lvalue or recursive offset

val visitFramacInitOffset : frama_c_visitor -> Cil_types.offset -> Cil_types.offset

Visit an initializer offset

val visitFramacInstr : frama_c_visitor -> Cil_types.instr -> Cil_types.instr list

Visit an instruction

val visitFramacStmt : frama_c_visitor -> Cil_types.stmt -> Cil_types.stmt

Visit a statement

val visitFramacBlock : frama_c_visitor -> Cil_types.block -> Cil_types.block

Visit a block

val visitFramacType : frama_c_visitor -> Cil_types.typ -> Cil_types.typ

Visit a type

val visitFramacVarDecl : frama_c_visitor -> Cil_types.varinfo -> Cil_types.varinfo

Visit a variable declaration

val visitFramacLogicVarDecl : frama_c_visitor -> Cil_types.logic_var -> Cil_types.logic_var

Visit a logic variable declaration

  • since Magnesium-20151001

Visit an initializer, pass also the global to which this belongs and the offset.

val visitFramacAttributes : frama_c_visitor -> Cil_types.attribute list -> Cil_types.attribute list

Visit a list of attributes

val visitFramacAssigns : frama_c_visitor -> Cil_types.assigns -> Cil_types.assigns
val visitFramacFrom : frama_c_visitor -> Cil_types.from -> Cil_types.from
val visitFramacDeps : frama_c_visitor -> Cil_types.deps -> Cil_types.deps
val visitFramacFunspec : frama_c_visitor -> Cil_types.funspec -> Cil_types.funspec

visit identified_term.

  • since Oxygen-20120901
val visitFramacTerm : frama_c_visitor -> Cil_types.term -> Cil_types.term
val visitFramacBehaviors : frama_c_visitor -> Cil_types.funbehavior list -> Cil_types.funbehavior list