Module Ast_c

module Ast_c: sig .. end
Guards for #if conditionals * * Having #if guards in the AST is useful for cpp-aware analyses, or to * later add support for matching against #ifS. * * General #if guards are stored as a string in a Gif_str constructor. * A traversal of the syntax tree with a parsing function would transform * these into the parsed Gif form. * * NOTE that there is no actually guaranteee that a traversal will * eliminate all Gif_str constructors, since the parsing function may * fail. * * See Parsing #if guards to know why this design choice. * *
Author(s): Iago Abal

type posl = int * int 
type virtual_position = Common.parse_info * int 
type parse_info = 
| OriginTok of Common.parse_info
| FakeTok of string * virtual_position
| ExpandedTok of Common.parse_info * virtual_position
| AbstractLineTok of Common.parse_info
type danger = 
| DangerStart
| DangerEnd
| Danger
| NoDanger
type info = {
   pinfo : parse_info;
   cocci_tag : (Ast_cocci.mcodekind * metavars_binding list) option ref;
   comments_tag : comments_around ref;
   mutable annots_tag : Token_annot.annots;
   danger : danger ref;
}
type il = info list 
type 'a wrap = 'a * il 
type 'a wrap2 = 'a * il 
type 'a wrap3 = 'a * il 
type name = 
| RegularName of string wrap
| CppConcatenatedName of string wrap wrap2 list
| CppVariadicName of string wrap
| CppIdentBuilder of string wrap * string wrap wrap2 list
type fullType = typeQualifier * typeC 
type typeC = typeCbis wrap 
type typeCbis = 
| NoType
| BaseType of baseType
| Pointer of fullType
| Array of constExpression option * fullType
| Decimal of constExpression * constExpression option
| FunctionType of functionType
| Enum of string option * enumType
| StructUnion of structUnion * string option * structType
| EnumName of string
| StructUnionName of structUnion * string
| TypeName of name * fullType option
| ParenType of fullType
| TypeOfExpr of expression
| TypeOfType of fullType
type baseType = 
| Void
| IntType of intType
| FloatType of floatType
| SizeType
| SSizeType
| PtrDiffType
type intType = 
| CChar
| Si of signed
type signed = sign * base 
type base = 
| CChar2
| CShort
| CInt
| CLong
| CLongLong
type sign = 
| Signed
| UnSigned
type floatType = 
| CFloat
| CDouble
| CLongDouble
type structUnion = 
| Struct
| Union
type structType = field list 
type field = 
| DeclarationField of field_declaration
| EmptyField of info
| MacroDeclField of (string * argument wrap2 list) wrap
| CppDirectiveStruct of cpp_directive
| IfdefStruct of ifdef_directive
type field_declaration = 
| FieldDeclList of fieldkind wrap2 list wrap
type fieldkind = 
| Simple of name option * fullType
| BitField of name option * fullType * info * constExpression
type enumType = oneEnumType wrap2 list 
type oneEnumType = name * (info * constExpression) option 
type functionType = fullType * (parameterType wrap2 list * bool wrap) 
type parameterType = {
   p_namei : name option;
   p_register : bool wrap;
   p_type : fullType;
}
type typeQualifier = typeQualifierbis wrap 
type typeQualifierbis = {
   const : bool;
   volatile : bool;
}
type attribute = attributebis wrap 
type attributebis = 
| Attribute of string
type expression = (expressionbis * exp_info ref) wrap3 
type exp_info = exp_type option * test 
type exp_type = fullType * local 
type local = 
| LocalVar of parse_info
| StaticLocalVar of parse_info
| NotLocalVar
type test = 
| Test
| NotTest
type expressionbis = 
| Ident of name
| Constant of constant
| StringConstant of string_fragment list * string * isWchar
| FunCall of expression * argument wrap2 list
| CondExpr of expression * expression option * expression
| Sequence of expression * expression
| Assignment of expression * assignOp * expression
| Postfix of expression * fixOp
| Infix of expression * fixOp
| Unary of expression * unaryOp
| Binary of expression * binaryOp * expression
| ArrayAccess of expression * expression
| RecordAccess of expression * name
| RecordPtAccess of expression * name
| SizeOfExpr of expression
| SizeOfType of fullType
| Cast of fullType * expression
| StatementExpr of compound wrap
| Constructor of fullType * initialiser
| ParenExpr of expression
| New of argument wrap2 list option * argument
| Delete of expression
| Defined of name
type argument = (expression, weird_argument) Common.either 
type weird_argument = 
| ArgType of parameterType
| ArgAction of action_macro
type action_macro = 
| ActMisc of il
type constant = 
| String of (string * isWchar)
| MultiString of string list
| Char of (string * isWchar)
| Int of (string * intType)
| Float of (string * floatType)
| DecimalConst of (string * string * string)
type isWchar = 
| IsWchar
| IsChar
type unaryOp = 
| GetRef
| DeRef
| UnPlus
| UnMinus
| Tilde
| Not
| GetRefLabel
type assignOpbis = 
| SimpleAssign
| OpAssign of arithOp
type assignOp = assignOpbis wrap 
type fixOp = 
| Dec
| Inc
type binaryOpbis = 
| Arith of arithOp
| Logical of logicalOp
type binaryOp = binaryOpbis wrap 
type arithOp = 
| Plus
| Minus
| Mul
| Div
| Mod
| DecLeft
| DecRight
| And
| Or
| Xor
| Max
| Min
type logicalOp = 
| Inf
| Sup
| InfEq
| SupEq
| Eq
| NotEq
| AndLog
| OrLog
type constExpression = expression 
type string_fragment = string_fragment_bis wrap 
type string_fragment_bis = 
| ConstantFragment of string
| FormatFragment of string_format
type string_format = string_format_bis wrap 
type string_format_bis = 
| ConstantFormat of string
type statement = statementbis wrap3 
type statementbis = 
| Labeled of labeled
| Compound of compound
| ExprStatement of exprStatement
| Selection of selection
| Iteration of iteration
| Jump of jump
| Decl of declaration
| Asm of asmbody
| NestedFunc of definition
| MacroStmt
| Exec of exec_code list
type labeled = 
| Label of name * statement
| Case of expression * statement
| CaseRange of expression * expression * statement
| Default of statement
type compound = statement_sequencable list 
type statement_sequencable = 
| StmtElem of statement
| CppDirectiveStmt of cpp_directive
| IfdefStmt of ifdef_directive
| IfdefStmt2 of ifdef_directive list * statement_sequencable list list
type exprStatement = expression option 
type declOrExpr = 
| ForDecl of declaration
| ForExp of expression option wrap
type selection = 
| If of expression * statement * statement
| Switch of expression * statement
| Ifdef_Ite of expression * statement * statement
| Ifdef_Ite2 of expression * statement * statement * statement
type iteration = 
| While of expression * statement
| DoWhile of statement * expression
| For of declOrExpr * exprStatement wrap
* exprStatement wrap * statement
| MacroIteration of string * argument wrap2 list * statement
type jump = 
| Goto of name
| Continue
| Break
| Return
| ReturnExpr of expression
| GotoComputed of expression
type asmbody = il * colon wrap list 
type colon = 
| Colon of colon_option wrap2 list
type colon_option = colon_option_bis wrap 
type colon_option_bis = 
| ColonMisc
| ColonExpr of expression
type exec_code_bis = 
| ExecEval of expression
| ExecToken
type exec_code = exec_code_bis wrap 
type declaration = 
| DeclList of onedecl wrap2 list wrap
| MacroDecl of (storagebis * string * argument wrap2 list * bool)
wrap
| MacroDeclInit of (storagebis * string * argument wrap2 list *
initialiser)
wrap
type onedecl = {
   v_namei : (name * v_init) option;
   v_type : fullType;
   v_type_bis : fullType option ref;
   v_storage : storage;
   v_local : local_decl;
   v_attr : attribute list;
}
type v_init = 
| NoInit
| ValInit of info * initialiser
| ConstrInit of argument wrap2 list wrap
type storage = storagebis * bool 
type storagebis = 
| NoSto
| StoTypedef
| Sto of storageClass
type storageClass = 
| Auto
| Static
| Register
| Extern
type local_decl = 
| LocalDecl
| NotLocalDecl
type initialiser = initialiserbis wrap 
type initialiserbis = 
| InitExpr of expression
| InitList of initialiser wrap2 list
| InitDesignators of designator list * initialiser
| InitFieldOld of string * initialiser
| InitIndexOld of expression * initialiser
type designator = designatorbis wrap 
type designatorbis = 
| DesignatorField of string
| DesignatorIndex of expression
| DesignatorRange of expression * expression
type definition = definitionbis wrap 
type definitionbis = {
   f_name : name;
   f_type : functionType;
   f_storage : storage;
   f_body : compound;
   f_attr : attribute list;
   f_old_c_style : declaration list option;
}
type cpp_directive = 
| Define of define
| Include of includ
| Pragma of string wrap * pragmainfo
| OtherDirective of il
type define = string wrap * (define_kind * define_val) 
type define_kind = 
| DefineVar
| DefineFunc of string wrap wrap2 list wrap
| Undef
type define_val = 
| DefineExpr of expression
| DefineStmt of statement
| DefineType of fullType
| DefineDoWhileZero of (statement * expression) wrap
| DefineFunction of definition
| DefineInit of initialiser
| DefineMulti of statement list
| DefineText of string wrap
| DefineEmpty
| DefineTodo
type includ = {
   i_include : inc_file wrap;
   i_rel_pos : include_rel_pos option ref;
   i_overall_rel_pos : include_rel_pos option ref;
   i_is_in_ifdef : bool;
   i_content : (Common.filename * program) option;
}
type inc_file = 
| Local of inc_elem list
| NonLocal of inc_elem list
| Weird of string
type inc_elem = string 
type include_rel_pos = {
   first_of : string list list;
   last_of : string list list;
}
type pragmainfo = 
| PragmaTuple of argument wrap2 list wrap
| PragmaIdList of name wrap2 list
type ifdef_directive = 
| IfdefDirective of (ifdefkind * matching_tag) wrap
type ifdefkind = 
| Ifdef of ifdef_guard
| IfdefElseif of ifdef_guard
| IfdefElse
| IfdefEndif (*
Guards for #if conditionals * * Having #if guards in the AST is useful for cpp-aware analyses, or to * later add support for matching against #ifS. * * General #if guards are stored as a string in a Gif_str constructor. * A traversal of the syntax tree with a parsing function would transform * these into the parsed Gif form. * * NOTE that there is no actually guaranteee that a traversal will * eliminate all Gif_str constructors, since the parsing function may * fail. * * See Parsing #if guards to know why this design choice. * *
Author(s): Iago Abal
*)
type ifdef_guard = 
| Gifdef of macro_symbol
| Gifndef of macro_symbol
| Gif_str of string
| Gif of expression
| Gnone
type macro_symbol = string 
type matching_tag = 
| IfdefTag of (int * int)
type toplevel = 
| Declaration of declaration
| Definition of definition
| CppTop of cpp_directive
| IfdefTop of ifdef_directive
| MacroTop of string * argument wrap2 list * il
| EmptyDef of il
| NotParsedCorrectly of il
| FinalDef of info
| Namespace of toplevel list * il
type program = toplevel list 
type metavars_binding = (Ast_cocci.meta_name, metavar_binding_kind) Common.assoc 
type metavar_binding_kind = 
| MetaIdVal of string
| MetaFuncVal of string
| MetaLocalFuncVal of string
| MetaExprVal of expression * Ast_cocci.meta_name list * stripped
| MetaExprListVal of argument wrap2 list
| MetaParamVal of parameterType
| MetaParamListVal of parameterType wrap2 list
| MetaTypeVal of fullType
| MetaInitVal of initialiser
| MetaInitListVal of initialiser wrap2 list
| MetaDeclVal of declaration
| MetaFieldVal of field
| MetaFieldListVal of field list
| MetaStmtVal of statement * stripped
| MetaStmtListVal of statement_sequencable list * stripped
| MetaDParamListVal of string wrap wrap2 list
| MetaFmtVal of string_format
| MetaFragListVal of string_fragment list
| MetaAssignOpVal of assignOp
| MetaBinaryOpVal of binaryOp
| MetaPosVal of (Ast_cocci.fixpos * Ast_cocci.fixpos)
| MetaPosValList of (Common.filename * string * posl * posl) list
| MetaListlenVal of int
| MetaNoVal
type stripped = 
| WITH_TYPES
| WITHOUT_TYPES
type comments_around = {
   mbefore : Token_c.comment_like_token list;
   mafter : Token_c.comment_like_token list;
   mbefore2 : comment_and_relative_pos list;
   mafter2 : comment_and_relative_pos list;
}
type comment_and_relative_pos = {
   minfo : Common.parse_info;
   mpos : int;
}
type comment = Common.parse_info 
type com = comment list ref 
val nullQualif : typeQualifierbis * 'a list
val nQ : typeQualifierbis * 'a list
val defaultInt : typeCbis
val noType : unit -> ('a option * test) ref
Parameters:
() : unit
val noInstr : statementbis * 'a list
val noTypedefDef : unit -> 'a option
Parameters:
() : unit
val emptyMetavarsBinding : metavars_binding
val emptyAnnotCocci : Ast_cocci.mcodekind * metavars_binding list
val emptyAnnot : (Ast_cocci.mcodekind * metavars_binding list) option
val mcode_and_env_of_cocciref : (Ast_cocci.mcodekind * metavars_binding list) option ref ->
Ast_cocci.mcodekind * metavars_binding list
Parameters:
aref : (Ast_cocci.mcodekind * metavars_binding list) option ref
val emptyComments : comments_around
val noRelPos : unit -> include_rel_pos option ref
Parameters:
() : unit
val noInIfdef : unit -> bool ref
Parameters:
() : unit
val no_virt_pos : Common.parse_info * int
val fakeInfo : 'a -> info
Parameters:
pi : 'a
val noii : 'a list
val noattr : 'a list
val noi_content : (Common.filename * program) option
val unwrap : 'a * 'b -> 'a
val unwrap2 : 'a * 'b -> 'a
val unwrap_expr : ('a * 'b) * 'c -> 'a
Parameters:
((unwrap_e,typ),iie) : ('a * 'b) * 'c
val rewrap_expr : ('a * 'b) * 'c -> 'd -> ('d * 'b) * 'c
Parameters:
((_old_unwrap_e,typ),iie) : ('a * 'b) * 'c
newe : 'd
val unwrap_typeC : 'a * ('b * 'c) -> 'b
Parameters:
(qu,(typeC,ii)) : 'a * ('b * 'c)
val rewrap_typeC : 'a * ('b * 'c) -> 'd -> 'a * ('d * 'c)
Parameters:
(qu,(typeC,ii)) : 'a * ('b * 'c)
newtypeC : 'd
val unwrap_typeCbis : 'a * 'b -> 'a
Parameters:
(typeC,ii) : 'a * 'b
val unwrap_st : 'a * 'b -> 'a
Parameters:
(unwrap_st,ii) : 'a * 'b
val mk_e : 'a -> 'b -> ('a * ('c option * test) ref) * 'b
Parameters:
unwrap_e : 'a
ii : 'b
val mk_e_bis : 'a -> 'b -> 'c -> ('a * 'b) * 'c
Parameters:
unwrap_e : 'a
ty : 'b
ii : 'c
val mk_ty : 'a -> 'b -> (typeQualifierbis * 'c list) * ('a * 'b)
Parameters:
typeC : 'a
ii : 'b
val mk_tybis : 'a -> 'b -> 'a * 'b
Parameters:
typeC : 'a
ii : 'b
val mk_st : 'a -> 'b -> 'a * 'b
Parameters:
unwrap_st : 'a
ii : 'b
val get_ii_typeC_take_care : 'a * 'b -> 'b
Parameters:
(typeC,ii) : 'a * 'b
val get_ii_st_take_care : 'a * 'b -> 'b
Parameters:
(st,ii) : 'a * 'b
val get_ii_expr_take_care : 'a * 'b -> 'b
Parameters:
(e,ii) : 'a * 'b
val get_st_and_ii : 'a * 'b -> 'a * 'b
Parameters:
(st,ii) : 'a * 'b
val get_ty_and_ii : 'a * ('b * 'c) -> 'a * ('b * 'c)
Parameters:
(qu,(typeC,ii)) : 'a * ('b * 'c)
val get_e_and_ii : 'a * 'b -> 'a * 'b
Parameters:
(e,ii) : 'a * 'b
val get_type_expr : ('a * 'b ref) * 'c -> 'b
Parameters:
((unwrap_e,typ),iie) : ('a * 'b ref) * 'c
val set_type_expr : ('a * 'b ref) * 'c -> 'b -> unit
Parameters:
((unwrap_e,oldtyp),iie) : ('a * 'b ref) * 'c
newtyp : 'b
val get_onlytype_expr : ('a * (('b * 'c) option * 'd) ref) * 'e -> 'b option
Parameters:
((unwrap_e,typ),iie) : ('a * (('b * 'c) option * 'd) ref) * 'e
val get_onlylocal_expr : ('a * (('b * 'c) option * 'd) ref) * 'e -> 'c option
Parameters:
((unwrap_e,typ),iie) : ('a * (('b * 'c) option * 'd) ref) * 'e
val rewrap_str : string -> info -> info
Parameters:
s : string
ii : info
val rewrap_pinfo : parse_info -> info -> info
Parameters:
pi : parse_info
ii : info
val get_pi : parse_info -> Common.parse_info
Parameters:
?? : parse_info
val get_opi : parse_info -> Common.parse_info
Parameters:
?? : parse_info
val str_of_info : info -> string
Parameters:
ii : info
val get_info : (Common.parse_info -> 'a) -> info -> 'a
Parameters:
f : Common.parse_info -> 'a
ii : info
val get_orig_info : (Common.parse_info -> 'a) -> info -> 'a
Parameters:
f : Common.parse_info -> 'a
ii : info
val make_expanded : info -> info
Parameters:
ii : info
val pos_of_info : info -> int
Parameters:
ii : info
val opos_of_info : info -> int
Parameters:
ii : info
val line_of_info : info -> int
Parameters:
ii : info
val col_of_info : info -> int
Parameters:
ii : info
val file_of_info : info -> Common.filename
Parameters:
ii : info
val mcode_of_info : info -> Ast_cocci.mcodekind
Parameters:
ii : info
val pinfo_of_info : info -> parse_info
Parameters:
ii : info
val parse_info_of_info : info -> Common.parse_info
Parameters:
ii : info
val strloc_of_info : info -> string
Parameters:
ii : info
val is_fake : info -> bool
Parameters:
ii : info
val is_origintok : info -> bool
Parameters:
ii : info
type posrv = 
| Real of Common.parse_info
| Virt of virtual_position
val compare_pos : info -> info -> int
Parameters:
ii1 : info
ii2 : info
val equal_posl : 'a * 'b -> 'a * 'b -> bool
Parameters:
(l1,c1) : 'a * 'b
(l2,c2) : 'a * 'b
val compare_posl : int * int -> int * int -> int
Parameters:
(l1,c1) : int * int
(l2,c2) : int * int
val info_to_fixpos : info -> Ast_cocci.fixpos
Parameters:
ii : info
val is_test : expression -> bool
Parameters:
() : expression
val al_info : int -> info -> info
Parameters:
tokenindex : int
x : info
val semi_al_info : info -> info
Parameters:
x : info
val magic_real_number : int
val real_al_info : info -> info
Parameters:
x : info
val al_comments : comments_around -> comments_around
Parameters:
x : comments_around
val al_info_cpp : int -> info -> info
Parameters:
tokenindex : int
x : info
val semi_al_info_cpp : info -> info
Parameters:
x : info
val real_al_info_cpp : info -> info
Parameters:
x : info
val s_of_inc_file : inc_file -> string
Parameters:
inc_file : inc_file
val s_of_inc_file_bis : inc_file -> string
Parameters:
inc_file : inc_file
val fieldname_of_fieldkind : fieldkind -> name option
Parameters:
fieldkind : fieldkind
val s_of_attr : (attributebis * 'a) list -> string
Parameters:
attr : (attributebis * 'a) list
val str_of_name : name -> string
Parameters:
ident : name
val get_s_and_ii_of_name : name -> string * il
Parameters:
name : name
val get_s_and_info_of_name : name -> string * info
Parameters:
name : name
val info_of_name : name -> info
Parameters:
name : name
val ii_of_name : name -> il
Parameters:
name : name
val get_local_ii_of_expr_inlining_ii_of_name : (expressionbis * 'a) * il -> il
Parameters:
e : (expressionbis * 'a) * il
val get_local_ii_of_tybis_inlining_ii_of_name : typeCbis * il -> il
Parameters:
ty : typeCbis * il
val info_of_type : 'a * (typeCbis * il) -> parse_info option
Parameters:
ft : 'a * (typeCbis * il)
val get_local_ii_of_st_inlining_ii_of_name : statementbis * info list -> info list
Parameters:
st : statementbis * info list
val name_of_parameter : parameterType -> string option
Parameters:
param : parameterType
val put_annot_info : info -> Token_annot.annot_key -> Token_annot.annot_val -> unit
Parameters:
info : info
key : Token_annot.annot_key
value : Token_annot.annot_val
val get_annot_info : info -> Token_annot.annot_key -> Token_annot.annot_val option
Parameters:
info : info
key : Token_annot.annot_key
val get_comments_before : info -> Token_c.comment_like_token list
Parameters:
info : info
val get_comments_after : info -> Token_c.comment_like_token list
Parameters:
info : info
val string_of_toplevel : toplevel -> string
Parameters:
?? : toplevel
val string_of_inc_file : inc_file -> string
Parameters:
?? : inc_file