X-Git-Url: http://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/3a31414346dd7d7e8baa4cb8b804a2d5e1797962..17ba07880e1838028b4516ba7a2db2147b3aa1c9:/parsing_c/ast_c.ml diff --git a/parsing_c/ast_c.ml b/parsing_c/ast_c.ml index d2776d5..b62c388 100644 --- a/parsing_c/ast_c.ml +++ b/parsing_c/ast_c.ml @@ -172,6 +172,7 @@ and fullType = typeQualifier * typeC and typeC = typeCbis wrap (* todo reput wrap3 *) and typeCbis = + NoType (* for c++ only *) | BaseType of baseType | Pointer of fullType @@ -290,7 +291,8 @@ and attribute = attributebis wrap and expression = (expressionbis * exp_info ref (* semantic: *)) wrap3 and exp_info = exp_type option * test and exp_type = fullType (* Type_c.completed_and_simplified *) * local - and local = LocalVar of parse_info | NotLocalVar (* cocci: *) + and local = LocalVar of parse_info | StaticLocalVar of parse_info + | NotLocalVar (* cocci: *) and test = Test | NotTest (* cocci: *) and expressionbis = @@ -329,14 +331,18 @@ and expression = (expressionbis * exp_info ref (* semantic: *)) wrap3 (* gccext: *) | StatementExpr of compound wrap (* ( ) new scope *) - | Constructor of fullType * initialiser wrap2 (* , *) list + | Constructor of fullType * initialiser (* for unparser: *) | ParenExpr of expression + (* for C++: *) + | New of argument + | Delete of expression + (* cppext: IfdefExpr TODO *) - (* cppext: normmally just expression *) + (* cppext: normally just expression *) and argument = (expression, weird_argument) Common.either and weird_argument = | ArgType of parameterType @@ -383,7 +389,6 @@ and expression = (expressionbis * exp_info ref (* semantic: *)) wrap3 and constExpression = expression (* => int *) - (* ------------------------------------------------------------------------- *) (* C statement *) (* ------------------------------------------------------------------------- *) @@ -510,10 +515,13 @@ and statement = statementbis wrap3 and declaration = | DeclList of onedecl wrap2 (* , *) list wrap (* ; fakestart sto *) (* cppext: *) - | MacroDecl of (string * argument wrap2 list) wrap (* fakestart *) + (* bool is true if there is a ; at the end *) + | MacroDecl of (string * argument wrap2 list * bool) wrap (* fakestart *) + | MacroDeclInit of + (string * argument wrap2 list * initialiser) wrap (* fakestart *) and onedecl = - { v_namei: (name * (info (* = *) * initialiser) option) option; + { v_namei: (name * v_init) option; v_type: fullType; (* semantic: set in type annotated and used in cocci_vs_c * when we transform some initialisation into affectation @@ -523,6 +531,9 @@ and declaration = v_local: local_decl; (* cocci: *) v_attr: attribute list; (* gccext: *) } + and v_init = + NoInit | ValInit of info * initialiser + | ConstrInit of argument wrap2 (* , *) list wrap and storage = storagebis * bool (* gccext: inline or not *) and storagebis = NoSto | StoTypedef | Sto of storageClass and storageClass = Auto | Static | Register | Extern @@ -702,8 +713,10 @@ and metavars_binding = (Ast_cocci.meta_name, metavar_binding_kind) assoc | MetaTypeVal of fullType | MetaInitVal of initialiser + | MetaInitListVal of initialiser wrap2 list | MetaDeclVal of declaration | MetaFieldVal of field + | MetaFieldListVal of field list | MetaStmtVal of statement (* Could also be in Lib_engine.metavars_binding2 with the ParenVal, @@ -1205,8 +1218,8 @@ let info_of_type ft = (* bugfix: because of string->name, the ii can be deeper *) let ii = get_local_ii_of_tybis_inlining_ii_of_name ty in match ii with - | ii::_ -> ii.pinfo - | [] -> failwith "type has no text; need to think again" + | ii::_ -> Some ii.pinfo + | [] -> None (* only Label and Goto have name *) let get_local_ii_of_st_inlining_ii_of_name st =