2 Given a file with data about the integer values that variables
3 x can take at certain positions, this patch identifies some
4 then-branches of if(x) ... statements.
6 Run this example from the coccinelle main directory using:
8 ./scripts/spatch --sp-file demos/external_ana.cocci demos/external_ana.c \
9 --external-analysis-file demos/external_ana.data
11 The analysis input was produced with a custom-made plugin for
12 frama-c that produced the external_ana.data file using the
15 frama-c -load-module ValueExport.cmxs -value-export \
16 -export-file ./external_ana.data external_ana.c
34 let p1 = Coccilib.basename_pos (List.hd p) in
35 Printf.printf "considering %s at position %s:(%d,%d)-(%d,%d):\n"
36 x p1.Coccilib.file p1.Coccilib.line p1.Coccilib.col
37 p1.Coccilib.line_end p1.Coccilib.col_end;
39 let rs = Coccilib.Ana.find p1 in
40 Printf.printf " results: %d\n" (List.length rs);
41 List.iter (fun r -> Printf.printf " value: %s\n" (Coccilib.Ana.show_result r)) rs;
43 let is_z = Coccilib.Ana.has_only_nul p1 in
44 Printf.printf " Always zero: %B\n" is_z;
46 Coccilib.include_match is_z