Skip to content
Snippets Groups Projects
Commit 45a7efd7 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

Merge branch 'fix/andre/obfuscate-crash' into 'master'

[Obfuscate] avoid crash when modifying global lemmas

See merge request frama-c/frama-c!3465
parents 577adfaa 56552fc3
No related branches found
No related tags found
No related merge requests found
...@@ -166,12 +166,13 @@ class visitor = object ...@@ -166,12 +166,13 @@ class visitor = object
Cil.DoChildren Cil.DoChildren
method! vannotation = function method! vannotation = function
| Daxiomatic(str, _, _, _) -> | Daxiomatic(str, globs, attrs, loc) ->
warn "axiomatic" str; let str' = Dictionary.fresh Obfuscator_kind.Axiomatic str in
Cil.DoChildren Cil.ChangeDoChildrenPost(Daxiomatic(str',globs,attrs,loc),Extlib.id)
| Dlemma(str, _, _, { tp_kind }, _, _) -> | Dlemma(str, labs, typs, pred, attrs, loc) ->
warn (Cil_printer.string_of_lemma tp_kind) str; let str' = Dictionary.fresh Obfuscator_kind.Lemma str in
Cil.DoChildren Cil.ChangeDoChildrenPost(
Dlemma(str',labs,typs, pred, attrs, loc),Extlib.id)
| _ -> | _ ->
Cil.DoChildren Cil.DoChildren
...@@ -290,7 +291,7 @@ end ...@@ -290,7 +291,7 @@ end
let obfuscate () = let obfuscate () =
Dictionary.mark_as_computed (); Dictionary.mark_as_computed ();
obfuscate_behaviors (); obfuscate_behaviors ();
Visitor.visitFramacFileSameGlobals Visitor.visitFramacFile
(new visitor :> Visitor.frama_c_visitor) (new visitor :> Visitor.frama_c_visitor)
(Ast.get ()); (Ast.get ());
Printer.update_printer (module UpdatePrinter: Printer.PrinterExtension) Printer.update_printer (module UpdatePrinter: Printer.PrinterExtension)
......
...@@ -36,6 +36,8 @@ type k = ...@@ -36,6 +36,8 @@ type k =
| Type | Type
| Logic_type | Logic_type
| Logic_constructor | Logic_constructor
| Axiomatic
| Lemma
let name_of_kind = function let name_of_kind = function
| Behavior -> "behavior" | Behavior -> "behavior"
...@@ -53,6 +55,8 @@ let name_of_kind = function ...@@ -53,6 +55,8 @@ let name_of_kind = function
| Type -> "type" | Type -> "type"
| Logic_type -> "logic type" | Logic_type -> "logic type"
| Logic_constructor -> "logic constructor" | Logic_constructor -> "logic constructor"
| Axiomatic -> "axiomatic"
| Lemma -> "lemma"
let prefix = function let prefix = function
| Behavior -> "B" | Behavior -> "B"
...@@ -70,6 +74,8 @@ let prefix = function ...@@ -70,6 +74,8 @@ let prefix = function
| Type -> "T" | Type -> "T"
| Logic_type -> "LT" | Logic_type -> "LT"
| Logic_constructor -> "LC" | Logic_constructor -> "LC"
| Axiomatic -> "A"
| Lemma -> "LE"
include Datatype.Make_with_collections include Datatype.Make_with_collections
(struct (struct
......
...@@ -36,6 +36,8 @@ type k = ...@@ -36,6 +36,8 @@ type k =
| Type | Type
| Logic_type | Logic_type
| Logic_constructor | Logic_constructor
| Axiomatic
| Lemma
include Datatype.S_with_collections with type t = k include Datatype.S_with_collections with type t = k
val prefix: t -> string val prefix: t -> string
......
...@@ -72,3 +72,9 @@ void implem(int c, int d) { }; ...@@ -72,3 +72,9 @@ void implem(int c, int d) { };
struct S example_struct = { .my_func = implem }; struct S example_struct = { .my_func = implem };
void test_func(struct S* s) { s->my_func(3,4); example_struct.my_func(5,6); } void test_func(struct S* s) { s->my_func(3,4); example_struct.my_func(5,6); }
// Check that these definitions do not make obfuscate crash
/*@ axiomatic A { predicate P(void (*galois_fp_old)()); } */
/*@ axiomatic A1 { predicate P1(void (*galois_fp_old)()); } */
void my_f() {}
/*@ lemma OK: P(my_f) && P1(my_f); */
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/* *********************************** */ /* *********************************** */
/* start of dictionary for obfuscation */ /* start of dictionary for obfuscation */
/* *********************************** */ /* *********************************** */
// axiomatics
#define A1 A
#define A2 A1
// behaviors // behaviors
#define B1 bhv #define B1 bhv
// enums // enums
...@@ -18,6 +21,7 @@ ...@@ -18,6 +21,7 @@
#define F4 builtin_and_stdlib #define F4 builtin_and_stdlib
#define F5 implem #define F5 implem
#define F6 test_func #define F6 test_func
#define F7 my_f
// global variables // global variables
#define G1 my_var #define G1 my_var
#define G2 example_struct #define G2 example_struct
...@@ -27,11 +31,17 @@ ...@@ -27,11 +31,17 @@
// logic constructors // logic constructors
#define LC1 T #define LC1 T
#define LC2 F #define LC2 F
// lemmas
#define LE1 OK
// logic types // logic types
#define LT1 t #define LT1 t
// logic variables // logic variables
#define LV1 I #define LV1 I
#define LV2 x #define LV2 x
#define LV3 P
#define LV4 galois_fp_old
#define LV5 P1
#define LV6 galois_fp_old
// fields // fields
#define M1 my_func #define M1 my_func
// predicates // predicates
...@@ -164,4 +174,23 @@ void F6(struct T2 *f6) ...@@ -164,4 +174,23 @@ void F6(struct T2 *f6)
return; return;
} }
/*@ axiomatic A1 {
predicate LV3(void (*LV4)()) ;
}
*/
/*@ axiomatic A2 {
predicate LV5(void (*LV6)()) ;
}
*/
void F7(void)
{
return;
}
/*@ lemma LE1{L}: LV3((void (*)())(&F7)) ∧ LV5((void (*)())(&F7));
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment