Skip to content
Snippets Groups Projects
Commit 331edb4f authored by Valentin Perrelle's avatar Valentin Perrelle Committed by David Bühler
Browse files

[Studia] Include global initializations in Ivette's results

Fix #1416
parent 94ad38ae
No related branches found
No related tags found
No related merge requests found
...@@ -21,12 +21,14 @@ ...@@ -21,12 +21,14 @@
(**************************************************************************) (**************************************************************************)
open Server open Server
open Cil_types
let package = let package =
Package.package ~plugin:"studia" ~name:"studia" ~title:"Studia" () Package.package ~plugin:"studia" ~name:"studia" ~title:"Studia" ()
type effects = { direct: stmt list; indirect: stmt list } type effects = {
direct: Printer_tag.localizable list;
indirect: Printer_tag.localizable list
}
let empty = { direct = []; indirect = []; } let empty = { direct = []; indirect = []; }
...@@ -51,26 +53,28 @@ module Effects = struct ...@@ -51,26 +53,28 @@ module Effects = struct
let jtype = R.jtype let jtype = R.jtype
let to_json effects = let to_json effects =
let markers = Printer_tag.localizable_of_stmt in
R.default |> R.default |>
R.set direct (List.map markers effects.direct) |> R.set direct effects.direct |>
R.set indirect (List.map markers effects.indirect) |> R.set indirect effects.indirect |>
R.to_json R.to_json
end end
let stmt_marker = Printer_tag.localizable_of_stmt
let global_marker vi = Printer_tag.localizable_of_declaration (SGlobal vi)
let compute_writes zone = let compute_writes zone =
try try
let reads = Writes.compute zone in let reads = Writes.compute zone in
let add acc = function let add acc = function
| Writes.Assign stmt | CallDirect stmt -> | Writes.Assign stmt | CallDirect stmt ->
{ acc with direct = stmt :: acc.direct } { acc with direct = stmt_marker stmt :: acc.direct }
| CallIndirect stmt -> | CallIndirect stmt ->
{ acc with indirect = stmt :: acc.indirect } { acc with indirect = stmt_marker stmt :: acc.indirect }
| FormalInit (_vi, callsites) -> | FormalInit (_vi, callsites) ->
let calls = List.flatten (List.map snd callsites) in let calls = List.concat_map snd callsites in
{ acc with direct = calls @ acc.direct } { acc with direct = List.map stmt_marker calls @ acc.direct }
| GlobalInit (_vi, _initinfo) -> | GlobalInit (vi, _initinfo) ->
acc (* for now ignore global initializations *) { acc with direct = global_marker vi :: acc.direct }
in in
List.fold_left add empty reads List.fold_left add empty reads
with exn -> with exn ->
...@@ -82,8 +86,10 @@ let compute_reads zone = ...@@ -82,8 +86,10 @@ let compute_reads zone =
try try
let reads = Reads.compute zone in let reads = Reads.compute zone in
let add acc = function let add acc = function
| Reads.Direct stmt -> { acc with direct = stmt :: acc.direct } | Reads.Direct stmt ->
| Indirect stmt -> { acc with indirect = stmt :: acc.indirect } { acc with direct = stmt_marker stmt :: acc.direct }
| Indirect stmt ->
{ acc with indirect = stmt_marker stmt :: acc.indirect }
in in
List.fold_left add empty reads List.fold_left add empty reads
with exn -> with exn ->
......
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