File: add_assigns.ml

package info (click to toggle)
frama-c 20161101%2Bsilicon%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,324 kB
  • ctags: 35,695
  • sloc: ml: 200,142; ansic: 31,465; makefile: 2,334; sh: 1,643; lisp: 259; python: 85; asm: 26
file content (33 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
open Cil_types

let emitter =
  Emitter.(
    create "assigns" [ Property_status; Funspec ] ~correctness:[] ~tuning:[])

let computed = ref false
        
let main () =
  if not !computed then begin
    computed := true;
    Ast.compute ();
    let kf = Globals.Functions.find_by_name "f" in
    let y = Globals.Vars.find_from_astinfo "y" (VFormal kf) in
    let mem =
      Logic_const.(
        new_identified_term
          (term (TLval (TMem (tvar (Cil.cvar_to_lvar y)), TNoOffset))
             (Ctype Cil.intType)))
    in
    let assigns = Writes [mem, FromAny] in
    let bhv = Cil.mk_behavior ~assigns () in
    Annotations.add_behaviors emitter kf [bhv];
    let bhv =
      List.find
        (fun b -> b.b_name = Cil.default_behavior_name)
        (Annotations.behaviors kf)
    in
    let ip = Extlib.the (Property.ip_assigns_of_behavior kf Kglobal [] bhv) in
    Property_status.(emit emitter ~hyps:[] ip True)
  end

let () = Db.Main.extend main