* use Ast_c.nQ, Ast_c.defaultInt, Ast_c.emptyAnnotCocci,
* Ast_c.emptyMetavarsBinding, Ast_c.emptyComments
*)
-let (int_type: Ast_c.fullType) =
- (* Lib_parsing_c.al_type (Parse_c.type_of_string "int")*)
+let mk_fulltype bt str =
Ast_c.mk_ty
- (Ast_c.BaseType (Ast_c.IntType (Ast_c.Si (Ast_c.Signed, Ast_c.CInt))))
+ (Ast_c.BaseType bt)
[Ast_c.al_info 0 (* al *)
{Ast_c.pinfo =
Ast_c.OriginTok
- {Common.str = "int"; Common.charpos = 0; Common.line = -1;
+ {Common.str = str; Common.charpos = 0; Common.line = -1;
Common.column = -1; Common.file = ""};
Ast_c.cocci_tag =
- {contents = Some (Ast_cocci.CONTEXT (Ast_cocci.NoPos, Ast_cocci.NOTHING), [])};
+ {contents =
+ Some (Ast_cocci.CONTEXT (Ast_cocci.NoPos, Ast_cocci.NOTHING), [])};
+ Ast_c.annots_tag = Token_annot.empty;
Ast_c.comments_tag = {contents =
{Ast_c.mbefore = []; Ast_c.mafter = [];
Ast_c.mbefore2 = []; Ast_c.mafter2 = []
}}}]
+let (int_type: Ast_c.fullType) =
+ (* Lib_parsing_c.al_type (Parse_c.type_of_string "int")*)
+ mk_fulltype (Ast_c.IntType (Ast_c.Si (Ast_c.Signed, Ast_c.CInt))) "int"
-
+let (ptr_diff_type: Ast_c.fullType) =
+ (* Lib_parsing_c.al_type (Parse_c.type_of_string "int")*)
+ mk_fulltype Ast_c.PtrDiffType "ptrdiff_t"
(* normally if the type annotated has done a good job, this should always
* return true. Cf type_annotater_c.typedef_fix.
*)
let rec is_completed_and_simplified ty =
match Ast_c.unwrap_typeC ty with
+ | NoType -> true
| BaseType x -> true
| Pointer t -> is_completed_and_simplified t
| Array (e, t) -> is_completed_and_simplified t
qu, Ast_c.mk_tybis (StructUnionName (su, s)) [i1;i2]
| None, _ ->
ty
- | x -> raise Impossible
+ | x -> raise (Impossible 126)
)
- | _ -> raise Impossible
+ | _ -> raise (Impossible 127)
(*****************************************************************************)
match decl with
| Ast_c.DeclList (xs,ii1) ->
(match xs with
- | [] -> raise Impossible
+ | [] -> raise (Impossible 128)
(* todo? for other xs ? *)
| (x,ii2)::xs ->
(* TODO normalize ? what if nested structure definition ? *)
v_type
)
- | Ast_c.MacroDecl _ ->
+ | Ast_c.MacroDecl _ | Ast_c.MacroDeclInit _ ->
pr2_once "not handling MacroDecl type yet";
raise Todo
match decl with
| Ast_c.DeclList (xs,ii1) ->
(match xs with
- | [] -> raise Impossible
+ | [] -> raise (Impossible 129)
(* todo? for other xs ? *)
| (x,ii2)::xs ->
(match Ast_c.unwrap_typeC v_type with
| Ast_c.StructUnion (su, _must_be_some, fields) ->
(su, fields)
- | _ -> raise Impossible
+ | _ -> raise (Impossible 130)
)
)
- | Ast_c.MacroDecl _ -> raise Impossible
+ | Ast_c.MacroDecl _ | Ast_c.MacroDeclInit _ -> raise (Impossible 131)
| Ast_c.FloatType(Ast_c.CFloat),_ -> Some t1
| _,Ast_c.FloatType(Ast_c.CFloat) -> Some t2
+ | Ast_c.PtrDiffType,_ -> Some t1
+ | _,Ast_c.PtrDiffType -> Some t2
+ | Ast_c.SSizeType,_ -> Some t1
+ | _,Ast_c.SSizeType -> Some t2
+ | Ast_c.SizeType,_ -> Some t1
+ | _,Ast_c.SizeType -> Some t2
+
| Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLongLong)),_ ->
Some t1
| _,Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLongLong)) ->
Some t1
| Ast_c.Minus,Ast_c.BaseType(Ast_c.IntType _),Ast_c.Pointer _ ->
Some t2
- | Ast_c.Minus,Ast_c.Pointer _,Ast_c.Pointer _ ->
- Some int_type
+ | Ast_c.Minus,(Ast_c.Pointer _ | Ast_c.Array _),
+ (Ast_c.Pointer _ | Ast_c.Array _) ->
+ Some ptr_diff_type
(* todo, Pointer, Typedef, etc *)
| _, _, _ -> Some t1
)
| None -> None, Ast_c.NotTest
| Some ft -> Some (ft, Ast_c.NotLocalVar), Ast_c.NotTest
-
-
(*****************************************************************************)
(* type lookup *)
(*****************************************************************************)