diff --git a/src/plugins/obfuscator/obfuscate.ml b/src/plugins/obfuscator/obfuscate.ml index 5b6799903acaa869ff816152cb3feec33fb8aa8a..4b48f22da13fe4c02b96e4cd25f8ab7747d34536 100644 --- a/src/plugins/obfuscator/obfuscate.ml +++ b/src/plugins/obfuscator/obfuscate.ml @@ -36,12 +36,27 @@ class visitor = object val logic_vars_visited = Logic_var.Hashtbl.create 7 val id_pred_visited = Identified_predicate.Hashtbl.create 7 + method! vtype = function + | TFun(t, args, variadic, attrs) -> + let args' = + match args with + | None -> None + | Some l -> + Some + (List.map + (fun (s,t,a) -> + (Dictionary.fresh Obfuscator_kind.Formal_in_type s, t, a)) l) + in + Cil.ChangeDoChildrenPost(TFun(t,args',variadic,attrs), Extlib.id) + | _ -> Cil.DoChildren + method! vglob_aux = function | GType (ty,_) -> if not (Cil.typeHasAttribute "fc_stdlib" ty.ttype) then ty.tname <- Dictionary.fresh Obfuscator_kind.Type ty.tname; Cil.DoChildren - | GVarDecl (v, _) | GVar (v, _, _) | GFun ({svar = v}, _) | GFunDecl (_, v, _) + | GVarDecl (v, _) | GVar (v, _, _) + | GFun ({svar = v}, _) | GFunDecl (_, v, _) when Cil.is_unused_builtin v -> Cil.SkipChildren | _ -> diff --git a/src/plugins/obfuscator/obfuscator_kind.ml b/src/plugins/obfuscator/obfuscator_kind.ml index 47633a9a28a574c381913a693849d2664462df63..80ba427b2ba5ef53abf1579b52139b7d692f0a07 100644 --- a/src/plugins/obfuscator/obfuscator_kind.ml +++ b/src/plugins/obfuscator/obfuscator_kind.ml @@ -25,6 +25,7 @@ type k = | Enum | Field | Formal_var + | Formal_in_type | Function | Global_var | Label @@ -41,6 +42,7 @@ let name_of_kind = function | Enum -> "enum" | Field -> "field" | Formal_var -> "formal variable" + | Formal_in_type -> "formal variable in fun type" | Function -> "function" | Global_var -> "global variable" | Label -> "label" @@ -57,6 +59,7 @@ let prefix = function | Enum -> "E" | Field -> "M" | Formal_var -> "f" + | Formal_in_type -> "ft" | Function -> "F" | Global_var -> "G" | Label -> "L" diff --git a/src/plugins/obfuscator/obfuscator_kind.mli b/src/plugins/obfuscator/obfuscator_kind.mli index 25685566b8843a4848c14a17bfd4fb2e0e6bc89c..ac5fc7d838411d16310a92345ebc2fc2adf6b57e 100644 --- a/src/plugins/obfuscator/obfuscator_kind.mli +++ b/src/plugins/obfuscator/obfuscator_kind.mli @@ -25,6 +25,7 @@ type k = | Enum | Field | Formal_var + | Formal_in_type | Function | Global_var | Label diff --git a/tests/misc/oracle/long_ident.res.oracle b/tests/misc/oracle/long_ident.res.oracle index 5b634422ab18e8328dfdf3aca5895bc9dd3f6472..bfe69779d745bfeadc18175605691a13965fa6b1 100644 --- a/tests/misc/oracle/long_ident.res.oracle +++ b/tests/misc/oracle/long_ident.res.oracle @@ -18,6 +18,10 @@ #define f1 q #define f2 X_9999999999999999999999999999999999999999999999999999_0 #define f3 p +// formal variable in fun types +#define ft1 q +#define ft2 X_9999999999999999999999999999999999999999999999999999_0 +#define ft3 p /*********************************** */ /* end of dictionary for obfuscation */ /*********************************** */ diff --git a/tests/misc/oracle/obfuscate.res.oracle b/tests/misc/oracle/obfuscate.res.oracle index 0618abc8f7a548f5bc5c8409f06af06a8a4e9049..124447020ca076a79b8ea78a720bd642a027255f 100644 --- a/tests/misc/oracle/obfuscate.res.oracle +++ b/tests/misc/oracle/obfuscate.res.oracle @@ -53,6 +53,15 @@ #define f4 c #define f5 d #define f6 s +// formal variable in fun types +#define ft1 x +#define ft2 y +#define ft3 p +#define ft4 f1 +#define ft5 p +#define ft6 c +#define ft7 d +#define ft8 s /*********************************** */ /* end of dictionary for obfuscation */ /*********************************** */ @@ -74,7 +83,7 @@ enum T1 { E3 = 4 }; struct T2 { - void (*M1)(int x, int y) ; + void (*M1)(int ft1, int ft2) ; }; int G1 = 0; /*@ global invariant LV1: G1 ≥ 0;