From a2d47fc541cc4cd18c97fc1b90956ac684832207 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 5 Oct 2022 14:50:46 +0300 Subject: [PATCH 01/40] Add yamlWitnessStrip testing utility --- src/witness/yamlWitnessType.ml | 14 ++++++++++ tests/util/dune | 11 ++++++++ tests/util/yamlWitnessStrip.ml | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/util/dune create mode 100644 tests/util/yamlWitnessStrip.ml diff --git a/src/witness/yamlWitnessType.ml b/src/witness/yamlWitnessType.ml index de9fa151d88..1630e05b698 100644 --- a/src/witness/yamlWitnessType.ml +++ b/src/witness/yamlWitnessType.ml @@ -111,6 +111,7 @@ struct column: int; function_: string; } + [@@deriving ord] let to_yaml {file_name; file_hash; line; column; function_} = `O [ @@ -138,6 +139,7 @@ struct type_: string; format: string; } + [@@deriving ord] let to_yaml {string; type_; format} = `O [ @@ -160,6 +162,7 @@ struct location: Location.t; loop_invariant: Invariant.t; } + [@@deriving ord] let entry_type = "loop_invariant" @@ -182,6 +185,7 @@ struct location: Location.t; location_invariant: Invariant.t; } + [@@deriving ord] let entry_type = "location_invariant" @@ -203,6 +207,7 @@ struct type t = { flow_insensitive_invariant: Invariant.t; } + [@@deriving ord] let entry_type = "flow_insensitive_invariant" @@ -224,6 +229,7 @@ struct loop_invariant: Invariant.t; precondition: Invariant.t; } + [@@deriving ord] let entry_type = "precondition_loop_invariant" @@ -251,6 +257,7 @@ struct value: string; format: string; } + [@@deriving ord] let invariant_type = "loop_invariant" @@ -282,6 +289,7 @@ struct type t = | LocationInvariant of LocationInvariant.t | LoopInvariant of LoopInvariant.t + [@@deriving ord] let invariant_type = function | LocationInvariant _ -> LocationInvariant.invariant_type @@ -309,6 +317,7 @@ struct type t = { invariant_type: InvariantType.t; } + [@@deriving ord] let to_yaml {invariant_type} = `O [ @@ -327,6 +336,7 @@ struct type t = { content: Invariant.t list; } + [@@deriving ord] let entry_type = "invariant_set" @@ -346,6 +356,7 @@ struct type_: string; file_hash: string; } + [@@deriving ord] let to_yaml {uuid; type_; file_hash} = `O [ @@ -369,6 +380,7 @@ struct type_: string; format: string; } + [@@deriving ord] let to_yaml {string; type_; format} = `O [ @@ -391,6 +403,7 @@ struct target: Target.t; certification: Certification.t; } + [@@deriving ord] let entry_type = "loop_invariant_certificate" @@ -424,6 +437,7 @@ struct | LoopInvariantCertificate of LoopInvariantCertificate.t | PreconditionLoopInvariantCertificate of PreconditionLoopInvariantCertificate.t | InvariantSet of InvariantSet.t + [@@deriving ord] let entry_type = function | LocationInvariant _ -> LocationInvariant.entry_type diff --git a/tests/util/dune b/tests/util/dune new file mode 100644 index 00000000000..66372176512 --- /dev/null +++ b/tests/util/dune @@ -0,0 +1,11 @@ +(executable + (name yamlWitnessStrip) + (libraries + batteries.unthreaded + goblint_std + goblint_lib + yaml + goblint.sites.dune + goblint.build-info.dune) + (flags :standard -open Goblint_std) + (preprocess (pps ppx_deriving.std))) diff --git a/tests/util/yamlWitnessStrip.ml b/tests/util/yamlWitnessStrip.ml new file mode 100644 index 00000000000..02cd3c57b96 --- /dev/null +++ b/tests/util/yamlWitnessStrip.ml @@ -0,0 +1,48 @@ +open Goblint_lib +open YamlWitnessType + +module StrippedEntry = +struct + type t = { + entry_type: EntryType.t; + } + [@@deriving ord] + + let to_yaml {entry_type} = + `O ([ + ("entry_type", `String (EntryType.entry_type entry_type)); + ] @ EntryType.to_yaml' entry_type) +end + +(* Use set for output, so order is deterministic regardless of Goblint. *) +module StrippedEntrySet = Set.Make (StrippedEntry) + +let main () = + let yaml_str = Batteries.input_all stdin in + let yaml = Yaml.of_string_exn yaml_str in + let yaml_entries = yaml |> GobYaml.list |> BatResult.get_ok in + + let stripped_entries = List.fold_left (fun stripped_entries yaml_entry -> + match YamlWitnessType.Entry.of_yaml yaml_entry with + | Ok {entry_type; _} -> + let stripped_entry: StrippedEntry.t = {entry_type} in + StrippedEntrySet.add stripped_entry stripped_entries + | Error (`Msg e) -> + Format.eprintf "couldn't parse entry: %s" e; + stripped_entries + ) StrippedEntrySet.empty yaml_entries + in + let stripped_yaml_entries = + StrippedEntrySet.elements stripped_entries + |> List.rev_map StrippedEntry.to_yaml + in + + let stripped_yaml = `A stripped_yaml_entries in + (* to_file/to_string uses a fixed-size buffer... *) + let stripped_yaml_str = match GobYaml.to_string' stripped_yaml with + | Ok text -> text + | Error (`Msg m) -> failwith ("Yaml.to_string: " ^ m) + in + Batteries.output_string Batteries.stdout stripped_yaml_str + +let () = main () From 11c16bc960de657c7e8c5e9a7ef5a1a1f44a11da Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 5 Oct 2022 15:10:49 +0300 Subject: [PATCH 02/40] Strip file hashes from YAML witness cram tests --- tests/util/yamlWitnessStrip.ml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/util/yamlWitnessStrip.ml b/tests/util/yamlWitnessStrip.ml index 02cd3c57b96..8a5046d6ffd 100644 --- a/tests/util/yamlWitnessStrip.ml +++ b/tests/util/yamlWitnessStrip.ml @@ -8,6 +8,43 @@ struct } [@@deriving ord] + let strip_file_hashes {entry_type} = + let stripped_file_hash = "$FILE_HASH" in + let location_strip_file_hash location: Location.t = + {location with file_hash = stripped_file_hash} + in + let target_strip_file_hash target: Target.t = + {target with file_hash = stripped_file_hash} + in + let invariant_strip_file_hash ({invariant_type}: InvariantSet.Invariant.t): InvariantSet.Invariant.t = + let invariant_type: InvariantSet.InvariantType.t = + match invariant_type with + | LocationInvariant x -> + LocationInvariant {x with location = location_strip_file_hash x.location} + | LoopInvariant x -> + LoopInvariant {x with location = location_strip_file_hash x.location} + in + {invariant_type} + in + let entry_type: EntryType.t = + match entry_type with + | LocationInvariant x -> + LocationInvariant {x with location = location_strip_file_hash x.location} + | LoopInvariant x -> + LoopInvariant {x with location = location_strip_file_hash x.location} + | FlowInsensitiveInvariant x -> + FlowInsensitiveInvariant x (* no location to strip *) + | PreconditionLoopInvariant x -> + PreconditionLoopInvariant {x with location = location_strip_file_hash x.location} + | LoopInvariantCertificate x -> + LoopInvariantCertificate {x with target = target_strip_file_hash x.target} + | PreconditionLoopInvariantCertificate x -> + PreconditionLoopInvariantCertificate {x with target = target_strip_file_hash x.target} + | InvariantSet x -> + InvariantSet {content = List.map invariant_strip_file_hash x.content} + in + {entry_type} + let to_yaml {entry_type} = `O ([ ("entry_type", `String (EntryType.entry_type entry_type)); @@ -34,6 +71,7 @@ let main () = in let stripped_yaml_entries = StrippedEntrySet.elements stripped_entries + |> List.map StrippedEntry.strip_file_hashes |> List.rev_map StrippedEntry.to_yaml in From 6c9d719475797fc3bb8bec2f9c86a1d3bec19cc9 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 5 Oct 2022 14:51:14 +0300 Subject: [PATCH 03/40] Add cram witness test to 56-witness/05-prec-problem --- tests/regression/56-witness/05-prec-problem.c | 4 +- tests/regression/56-witness/05-prec-problem.t | 89 +++++++++++++++++++ tests/regression/56-witness/dune | 6 ++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 tests/regression/56-witness/05-prec-problem.t create mode 100644 tests/regression/56-witness/dune diff --git a/tests/regression/56-witness/05-prec-problem.c b/tests/regression/56-witness/05-prec-problem.c index 132ba6b466e..276adec0938 100644 --- a/tests/regression/56-witness/05-prec-problem.c +++ b/tests/regression/56-witness/05-prec-problem.c @@ -1,4 +1,4 @@ -//PARAM: --enable witness.yaml.enabled --enable ana.int.interval --set witness.yaml.entry-types[+] precondition_loop_invariant +//PARAM: --enable witness.yaml.enabled --enable ana.int.interval --set witness.yaml.entry-types '["precondition_loop_invariant"]' #include #include @@ -9,7 +9,7 @@ int foo(int* ptr1, int* ptr2){ } else { result = 1; } - // Look at the generated witness.yml to check whether there are contradictory precondition_loop_invariant[s] + // cram test checks for precondition invariant soundness return result; } diff --git a/tests/regression/56-witness/05-prec-problem.t b/tests/regression/56-witness/05-prec-problem.t new file mode 100644 index 00000000000..829ddd1ab8b --- /dev/null +++ b/tests/regression/56-witness/05-prec-problem.t @@ -0,0 +1,89 @@ + $ goblint --enable witness.yaml.enabled --enable ana.int.interval --set witness.yaml.entry-types '["precondition_loop_invariant"]' 05-prec-problem.c + [Success][Assert] Assertion "y != z" will succeed (05-prec-problem.c:21:5-21:28) + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 12 + dead: 0 + total lines: 12 + [Info][Witness] witness generation summary: + total generation entries: 10 + +Witness shouldn't contain two unsound precondition_loop_invariant-s with precondition `*ptr1 == 5 && *ptr2 == 5`, +and separately invariants `result == 0` and `result == 1`. +The sound invariant is `result == 1 || result == 0`. + + $ yamlWitnessStrip < witness.yml + - entry_type: precondition_loop_invariant + location: + file_name: 05-prec-problem.c + file_hash: $FILE_HASH + line: 13 + column: 4 + function: foo + loop_invariant: + string: result == 1 || result == 0 + type: assertion + format: C + precondition: + string: '*ptr1 == 5 && *ptr2 == 5' + type: assertion + format: C + - entry_type: precondition_loop_invariant + location: + file_name: 05-prec-problem.c + file_hash: $FILE_HASH + line: 13 + column: 4 + function: foo + loop_invariant: + string: '*ptr2 == 5' + type: assertion + format: C + precondition: + string: '*ptr1 == 5 && *ptr2 == 5' + type: assertion + format: C + - entry_type: precondition_loop_invariant + location: + file_name: 05-prec-problem.c + file_hash: $FILE_HASH + line: 13 + column: 4 + function: foo + loop_invariant: + string: '*ptr1 == 5' + type: assertion + format: C + precondition: + string: '*ptr1 == 5 && *ptr2 == 5' + type: assertion + format: C + - entry_type: precondition_loop_invariant + location: + file_name: 05-prec-problem.c + file_hash: $FILE_HASH + line: 7 + column: 7 + function: foo + loop_invariant: + string: '*ptr2 == 5' + type: assertion + format: C + precondition: + string: '*ptr1 == 5 && *ptr2 == 5' + type: assertion + format: C + - entry_type: precondition_loop_invariant + location: + file_name: 05-prec-problem.c + file_hash: $FILE_HASH + line: 7 + column: 7 + function: foo + loop_invariant: + string: '*ptr1 == 5' + type: assertion + format: C + precondition: + string: '*ptr1 == 5 && *ptr2 == 5' + type: assertion + format: C diff --git a/tests/regression/56-witness/dune b/tests/regression/56-witness/dune new file mode 100644 index 00000000000..05fce8ddece --- /dev/null +++ b/tests/regression/56-witness/dune @@ -0,0 +1,6 @@ +(env + (_ + (binaries ../../util/yamlWitnessStrip.exe))) + +(cram + (deps (glob_files *.c) %{bin:yamlWitnessStrip})) From 990cf0c892ea54da5fd8d559033444f0d77fab11 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 8 Feb 2024 16:03:19 +0200 Subject: [PATCH 04/40] Add test for synthetic YAML witness invariant locations (PR #758) --- tests/regression/56-witness/dune | 6 +- tests/regression/dune | 9 ++- tests/regression/pr-758.t/pr-758.c | 22 ++++++ tests/regression/pr-758.t/run.t | 119 +++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 tests/regression/pr-758.t/pr-758.c create mode 100644 tests/regression/pr-758.t/run.t diff --git a/tests/regression/56-witness/dune b/tests/regression/56-witness/dune index 05fce8ddece..23c0dd32901 100644 --- a/tests/regression/56-witness/dune +++ b/tests/regression/56-witness/dune @@ -1,6 +1,2 @@ -(env - (_ - (binaries ../../util/yamlWitnessStrip.exe))) - (cram - (deps (glob_files *.c) %{bin:yamlWitnessStrip})) + (deps (glob_files *.c))) diff --git a/tests/regression/dune b/tests/regression/dune index fdb1d941c2b..f68053ef63e 100644 --- a/tests/regression/dune +++ b/tests/regression/dune @@ -1,3 +1,10 @@ +(env + (_ + (binaries ../util/yamlWitnessStrip.exe))) + (cram (applies_to :whole_subtree) - (deps %{bin:goblint} (package goblint))) ; need entire package for includes/ + (deps + %{bin:goblint} + (package goblint) ; need entire package for includes/ + %{bin:yamlWitnessStrip})) diff --git a/tests/regression/pr-758.t/pr-758.c b/tests/regression/pr-758.t/pr-758.c new file mode 100644 index 00000000000..87aa41889d6 --- /dev/null +++ b/tests/regression/pr-758.t/pr-758.c @@ -0,0 +1,22 @@ +// Code from https://github.com/goblint/cil/pull/98 + +int main() { + // for loop + int x = 42; + for (x = 0; x < 10; x++) { // there shouldn't be invariants x <= 9, x <= 10 and 0 <= x before this line + // ... + } + + // expression with side effect + int i, k; + i = k = 0; // there shouldn't be invariant k == 0 before this line + + // compound initializers + struct kala { + int kaal; + int hind; + }; + + struct kala a = {2, 3}; // there shouldn't be invariant a.kaal == 2 before this line + return 0; +} diff --git a/tests/regression/pr-758.t/run.t b/tests/regression/pr-758.t/run.t new file mode 100644 index 00000000000..23c327aeb2f --- /dev/null +++ b/tests/regression/pr-758.t/run.t @@ -0,0 +1,119 @@ + $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["loop_invariant", "location_invariant"]' pr-758.c + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 6 + dead: 0 + total lines: 6 + [Info][Witness] witness generation summary: + total generation entries: 10 + + $ yamlWitnessStrip < witness.yml + - entry_type: loop_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 6 + column: 2 + function: main + loop_invariant: + string: (0 <= x && (x <= 9 || x <= 10)) + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: i == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: a.kaal == 2 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: a.hind == 3 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: i == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 12 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C From 066e11a2bd3aecb7bc968ffebb7483e165e6c9fe Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 8 Feb 2024 16:16:27 +0200 Subject: [PATCH 05/40] Add test for incorrect YAML witness invariant locations from CIL transformations (issue #1356) --- tests/regression/issue-1356.t/issue-1356.c | 20 ++++++++++++++++++++ tests/regression/issue-1356.t/run.t | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/regression/issue-1356.t/issue-1356.c create mode 100644 tests/regression/issue-1356.t/run.t diff --git a/tests/regression/issue-1356.t/issue-1356.c b/tests/regression/issue-1356.t/issue-1356.c new file mode 100644 index 00000000000..b773f6cf668 --- /dev/null +++ b/tests/regression/issue-1356.t/issue-1356.c @@ -0,0 +1,20 @@ +extern int __VERIFIER_nondet_int(void); + +extern void abort(void); +void assume_abort_if_not(int cond) { + if(!cond) {abort();} +} + +int minus(int a, int b) { + assume_abort_if_not(b <= 0 || a >= b - 2147483648); // there shouldn't be invariants 1 <= b and b != 0 before this line + assume_abort_if_not(b >= 0 || a <= b + 2147483647); // there shouldn't be invariants b <= -1 and b != 0 before this line + return a - b; +} + +int main() { + int x, y; + x = __VERIFIER_nondet_int(); + y = __VERIFIER_nondet_int(); + minus(x, y); + return 0; +} diff --git a/tests/regression/issue-1356.t/run.t b/tests/regression/issue-1356.t/run.t new file mode 100644 index 00000000000..7765c02b8d0 --- /dev/null +++ b/tests/regression/issue-1356.t/run.t @@ -0,0 +1,12 @@ + $ goblint --enable ana.sv-comp.functions --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant"]' issue-1356.c + [Warning][Integer > Overflow][CWE-190] Signed integer overflow (issue-1356.c:10:3-10:53) + [Warning][Integer > Overflow][CWE-190][CWE-191] Signed integer overflow and underflow (issue-1356.c:11:3-11:15) + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 13 + dead: 0 + total lines: 13 + [Info][Witness] witness generation summary: + total generation entries: 0 + + $ yamlWitnessStrip < witness.yml + [] From c743366504bd368036c87144142febe9ea413b04 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 14 Feb 2024 17:19:13 +0200 Subject: [PATCH 06/40] Add expression location to return --- goblint.opam | 2 +- goblint.opam.locked | 2 +- goblint.opam.template | 2 +- src/common/framework/cfgTools.ml | 6 +- src/common/util/cilLocation.ml | 2 +- src/common/util/cilfacade.ml | 2 +- src/common/util/cilfacade0.ml | 2 +- src/incremental/compareAST.ml | 4 +- tests/regression/00-sanity/19-if-0.t | 36 ++++---- tests/regression/00-sanity/20-if-0-realnode.t | 40 ++++----- tests/regression/cfg/foo.t/run.t | 90 +++++++++---------- tests/regression/cfg/issue-1356.t/run.t | 2 +- tests/regression/cfg/pr-758.t/run.t | 2 +- 13 files changed, 96 insertions(+), 96 deletions(-) diff --git a/goblint.opam b/goblint.opam index 8ccde7c6ba2..f05cb5ad168 100644 --- a/goblint.opam +++ b/goblint.opam @@ -77,7 +77,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git" available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/goblint.opam.locked b/goblint.opam.locked index 5224d5aa188..4e5e4d50bbe 100644 --- a/goblint.opam.locked +++ b/goblint.opam.locked @@ -133,7 +133,7 @@ post-messages: [ pin-depends: [ [ "goblint-cil.2.0.3" - "git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5" + "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" ] [ "ppx_deriving.5.2.1" diff --git a/goblint.opam.template b/goblint.opam.template index 1364586310c..a9bb491ce51 100644 --- a/goblint.opam.template +++ b/goblint.opam.template @@ -3,7 +3,7 @@ available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/src/common/framework/cfgTools.ml b/src/common/framework/cfgTools.ml index 6a2540fd187..23dfe3ad6c7 100644 --- a/src/common/framework/cfgTools.ml +++ b/src/common/framework/cfgTools.ml @@ -254,7 +254,7 @@ let createCFG (file: file) = let pseudo_return = lazy ( if Messages.tracing then Messages.trace "cfg" "adding pseudo-return to the function %s.\n" fd.svar.vname; let fd_end_loc = {fd_loc with line = fd_loc.endLine; byte = fd_loc.endByte; column = fd_loc.endColumn} in - let newst = mkStmt (Return (None, fd_end_loc)) in + let newst = mkStmt (Return (None, fd_end_loc, locUnknown)) in newst.sid <- Cilfacade.get_pseudo_return_id fd; Cilfacade.StmtH.add Cilfacade.pseudo_return_to_fun newst fd; Cilfacade.IntH.replace Cilfacade.pseudo_return_stmt_sids newst.sid newst; @@ -340,8 +340,8 @@ let createCFG (file: file) = (* CIL's xform_switch_stmt (via prepareCFG) always adds both continue and break statements to all Loops. *) failwith "MyCFG.createCFG: unprepared Loop" - | Return (exp, loc) -> - addEdge (Statement stmt) (loc, Ret (exp, fd)) (Function fd) + | Return (exp, loc, eloc) -> + addEdge (Statement stmt) (Cilfacade.eloc_fallback ~eloc ~loc, Ret (exp, fd)) (Function fd) | Goto (_, loc) -> (* Gotos are generally unnecessary and unwanted because find_real_stmt skips over these. *) diff --git a/src/common/util/cilLocation.ml b/src/common/util/cilLocation.ml index 6f9a3ce7c45..ae01b6b62a6 100644 --- a/src/common/util/cilLocation.ml +++ b/src/common/util/cilLocation.ml @@ -41,7 +41,7 @@ let rec get_stmtLoc stmt: locs = {loc = locUnknown; eloc = locUnknown} | Instr (hd :: _) -> get_instrLoc hd - | Return (_, loc) -> {loc; eloc = locUnknown} + | Return (_, loc, eloc) -> {loc; eloc} | Goto (_, loc) -> {loc; eloc = locUnknown} | ComputedGoto (_, loc) -> {loc; eloc = locUnknown} | Break loc -> {loc; eloc = locUnknown} diff --git a/src/common/util/cilfacade.ml b/src/common/util/cilfacade.ml index 9d2f8b2d3a3..40d55e62e81 100644 --- a/src/common/util/cilfacade.ml +++ b/src/common/util/cilfacade.ml @@ -469,7 +469,7 @@ class countFnVisitor = object inherit nopCilVisitor method! vstmt s = match s.skind with - | Return (_, loc) + | Return (_, loc, _) | Goto (_, loc) | ComputedGoto (_, loc) | Break loc diff --git a/src/common/util/cilfacade0.ml b/src/common/util/cilfacade0.ml index 35fd5fb7067..5748d9166c8 100644 --- a/src/common/util/cilfacade0.ml +++ b/src/common/util/cilfacade0.ml @@ -42,7 +42,7 @@ let rec get_stmtLoc stmt = get_labelsLoc stmt.labels | Instr (hd :: _) -> get_instrLoc hd - | Return (_, loc) -> loc + | Return (_, loc, eloc) -> eloc_fallback ~eloc ~loc | Goto (_, loc) -> loc | ComputedGoto (_, loc) -> loc | Break loc -> loc diff --git a/src/incremental/compareAST.ml b/src/incremental/compareAST.ml index c79735c2b1e..b1300b628ac 100644 --- a/src/incremental/compareAST.ml +++ b/src/incremental/compareAST.ml @@ -339,8 +339,8 @@ let rec eq_stmtkind ?(cfg_comp = false) ((a, af): stmtkind * fundec) ((b, bf): s let eq_block' = fun x y ~(rename_mapping:rename_mapping) -> if cfg_comp then true, rename_mapping else eq_block (x, af) (y, bf) ~rename_mapping in match a, b with | Instr is1, Instr is2 -> forward_list_equal eq_instr is1 is2 ~rename_mapping - | Return (Some exp1, _l1), Return (Some exp2, _l2) -> eq_exp exp1 exp2 ~rename_mapping - | Return (None, _l1), Return (None, _l2) -> true, rename_mapping + | Return (Some exp1, _l1, _el1), Return (Some exp2, _l2, _el2) -> eq_exp exp1 exp2 ~rename_mapping + | Return (None, _l1, _el1), Return (None, _l2, _el2) -> true, rename_mapping | Return _, Return _ -> false, rename_mapping | Goto (st1, _l1), Goto (st2, _l2) -> eq_stmt_with_location (!st1, af) (!st2, bf), rename_mapping | Break _, Break _ -> if cfg_comp then failwith "CompareCFG: Invalid stmtkind in CFG" else true, rename_mapping diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index f847d75446b..37082625f4a 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -1,33 +1,33 @@ $ cfgDot 19-if-0.c $ graph-easy --as=boxart main.dot - ┌────────────────────────┐ - │ main() │ - └────────────────────────┘ + ┌─────────────────────────┐ + │ main() │ + └─────────────────────────┘ │ │ (body) ▼ - ┌────────────────────────┐ ┌────────────────────────┐ - │ 19-if-0.c:15:9-15:27 │ Neg(0) │ 19-if-0.c:9:5-16:5 │ - │ (19-if-0.c:15:9-15:27) │ ◀──────────────────── │ (19-if-0.c:9:9-9:10) │ - └────────────────────────┘ └────────────────────────┘ + ┌────────────────────────┐ ┌─────────────────────────┐ + │ 19-if-0.c:15:9-15:27 │ Neg(0) │ 19-if-0.c:9:5-16:5 │ + │ (19-if-0.c:15:9-15:27) │ ◀──────────────────── │ (19-if-0.c:9:9-9:10) │ + └────────────────────────┘ └─────────────────────────┘ │ │ │ │ Pos(0) │ ▼ - │ ┌────────────────────────┐ - │ │ 19-if-0.c:11:9-11:16 │ - │ │ (19-if-0.c:11:9-11:16) │ - │ └────────────────────────┘ + │ ┌─────────────────────────┐ + │ │ 19-if-0.c:11:9-11:16 │ + │ │ (19-if-0.c:11:9-11:16) │ + │ └─────────────────────────┘ │ │ │ │ stuff() │ ▼ - │ ┌────────────────────────┐ - │ __goblint_check(1) │ 19-if-0.c:17:5-17:13 │ - └────────────────────────────────────────────▶ │ (unknown) │ - └────────────────────────┘ + │ ┌─────────────────────────┐ + │ __goblint_check(1) │ 19-if-0.c:17:5-17:13 │ + └────────────────────────────────────────────▶ │ (19-if-0.c:17:12-17:13) │ + └─────────────────────────┘ │ │ return 0 ▼ - ┌────────────────────────┐ - │ return of main() │ - └────────────────────────┘ + ┌─────────────────────────┐ + │ return of main() │ + └─────────────────────────┘ diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index 06a0bba865b..f17c87a897e 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -1,35 +1,35 @@ $ cfgDot 20-if-0-realnode.c $ graph-easy --as=boxart main.dot - ┌─────────────────────────────────┐ - │ main() │ - └─────────────────────────────────┘ + ┌──────────────────────────────────┐ + │ main() │ + └──────────────────────────────────┘ │ │ (body) ▼ - ┌─────────────────────────────────┐ - │ 20-if-0-realnode.c:8:5-14:5 │ Neg(0) - │ (20-if-0-realnode.c:8:9-8:10) │ ─────────┐ - │ [20-if-0-realnode.c:7:5-8:5 │ │ - │ (unknown)] │ ◀────────┘ - └─────────────────────────────────┘ + ┌──────────────────────────────────┐ + │ 20-if-0-realnode.c:8:5-14:5 │ Neg(0) + │ (20-if-0-realnode.c:8:9-8:10) │ ─────────┐ + │ [20-if-0-realnode.c:7:5-8:5 │ │ + │ (unknown)] │ ◀────────┘ + └──────────────────────────────────┘ │ │ Pos(0) ▼ - ┌─────────────────────────────────┐ - │ 20-if-0-realnode.c:10:9-10:16 │ - │ (20-if-0-realnode.c:10:9-10:16) │ - └─────────────────────────────────┘ + ┌──────────────────────────────────┐ + │ 20-if-0-realnode.c:10:9-10:16 │ + │ (20-if-0-realnode.c:10:9-10:16) │ + └──────────────────────────────────┘ │ │ stuff() ▼ - ┌─────────────────────────────────┐ - │ 20-if-0-realnode.c:15:5-15:13 │ - │ (unknown) │ - └─────────────────────────────────┘ + ┌──────────────────────────────────┐ + │ 20-if-0-realnode.c:15:5-15:13 │ + │ (20-if-0-realnode.c:15:12-15:13) │ + └──────────────────────────────────┘ │ │ return 0 ▼ - ┌─────────────────────────────────┐ - │ return of main() │ - └─────────────────────────────────┘ + ┌──────────────────────────────────┐ + │ return of main() │ + └──────────────────────────────────┘ diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index a9f91bf4a6d..b64bd58dc84 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -1,48 +1,48 @@ $ cfgDot foo.c $ graph-easy --as=boxart main.dot - ┌───────────────────────────────┐ - │ main() │ - └───────────────────────────────┘ - │ - │ (body) - ▼ - ┌───────────────────────────────┐ - │ foo.c:2:7-2:12 │ - │ (foo.c:2:7-2:12) │ - └───────────────────────────────┘ - │ - │ a = 1 - ▼ - ┌───────────────────────────────┐ - │ foo.c:2:14-2:19 │ - │ (foo.c:2:14-2:19) │ - └───────────────────────────────┘ - │ - │ b = 1 - ▼ - ┌──────────────────┐ ┌───────────────────────────────┐ - │ foo.c:7:3-7:11 │ Neg(a > 0) │ foo.c:3:3-6:3 (synthetic) │ - ┌──────▶ │ (unknown) │ ◀──────────── │ (foo.c:3:10-3:20 (synthetic)) │ ◀┐ - │ └──────────────────┘ └───────────────────────────────┘ │ - │ │ │ │ - │ │ return 0 │ Pos(a > 0) │ - │ ▼ ▼ │ - │ Neg(b) ┌──────────────────┐ ┌───────────────────────────────┐ │ - │ │ return of main() │ │ foo.c:3:3-6:3 (synthetic) │ │ - │ │ │ ┌─────────── │ (foo.c:3:10-3:20 (synthetic)) │ │ - │ └──────────────────┘ │ └───────────────────────────────┘ │ - │ │ │ │ - └──────────────────────────────┘ │ Pos(b) │ b = b - 1 - ▼ │ - ┌───────────────────────────────┐ │ - │ foo.c:4:5-4:8 │ │ - │ (foo.c:4:5-4:8) │ │ - └───────────────────────────────┘ │ - │ │ - │ a = a + 1 │ - ▼ │ - ┌───────────────────────────────┐ │ - │ foo.c:5:5-5:8 │ │ - │ (foo.c:5:5-5:8) │ ─┘ - └───────────────────────────────┘ + ┌───────────────────────────────┐ + │ main() │ + └───────────────────────────────┘ + │ + │ (body) + ▼ + ┌───────────────────────────────┐ + │ foo.c:2:7-2:12 │ + │ (foo.c:2:7-2:12) │ + └───────────────────────────────┘ + │ + │ a = 1 + ▼ + ┌───────────────────────────────┐ + │ foo.c:2:14-2:19 │ + │ (foo.c:2:14-2:19) │ + └───────────────────────────────┘ + │ + │ b = 1 + ▼ + ┌───────────────────┐ ┌───────────────────────────────┐ + │ foo.c:7:3-7:11 │ Neg(a > 0) │ foo.c:3:3-6:3 (synthetic) │ + ┌──────▶ │ (foo.c:7:10-7:11) │ ◀──────────── │ (foo.c:3:10-3:20 (synthetic)) │ ◀┐ + │ └───────────────────┘ └───────────────────────────────┘ │ + │ │ │ │ + │ │ return 0 │ Pos(a > 0) │ + │ ▼ ▼ │ + │ Neg(b) ┌───────────────────┐ ┌───────────────────────────────┐ │ + │ │ return of main() │ │ foo.c:3:3-6:3 (synthetic) │ │ + │ │ │ ┌─────────── │ (foo.c:3:10-3:20 (synthetic)) │ │ + │ └───────────────────┘ │ └───────────────────────────────┘ │ + │ │ │ │ + └───────────────────────────────┘ │ Pos(b) │ b = b - 1 + ▼ │ + ┌───────────────────────────────┐ │ + │ foo.c:4:5-4:8 │ │ + │ (foo.c:4:5-4:8) │ │ + └───────────────────────────────┘ │ + │ │ + │ a = a + 1 │ + ▼ │ + ┌───────────────────────────────┐ │ + │ foo.c:5:5-5:8 │ │ + │ (foo.c:5:5-5:8) │ ─┘ + └───────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 78a81aff686..b8fcf7cfcc2 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -68,7 +68,7 @@ ▼ ┌─────────────────────────────────────────┐ │ issue-1356.c:11:3-11:15 │ - │ (unknown) │ + │ (issue-1356.c:11:10-11:15) │ └─────────────────────────────────────────┘ │ │ return a - b diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index d87d9128c7a..e1272f38856 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -61,7 +61,7 @@ ▼ ┌────────────────────────────────────┐ │ pr-758.c:21:3-21:11 │ - │ (unknown) │ + │ (pr-758.c:21:10-21:11) │ └────────────────────────────────────┘ │ │ return 0 From 854f47d5a2fc1cc3206ff3a1ee4d23831fcb9b0d Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 15 Feb 2024 10:40:43 +0200 Subject: [PATCH 07/40] Fix initializer locations --- goblint.opam | 2 +- goblint.opam.locked | 2 +- goblint.opam.template | 2 +- tests/regression/cfg/foo.t/run.t | 8 ++++---- tests/regression/cfg/pr-758.t/run.t | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/goblint.opam b/goblint.opam index f05cb5ad168..114ef449d94 100644 --- a/goblint.opam +++ b/goblint.opam @@ -77,7 +77,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git" available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/goblint.opam.locked b/goblint.opam.locked index 4e5e4d50bbe..35ca1583f6e 100644 --- a/goblint.opam.locked +++ b/goblint.opam.locked @@ -133,7 +133,7 @@ post-messages: [ pin-depends: [ [ "goblint-cil.2.0.3" - "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" + "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" ] [ "ppx_deriving.5.2.1" diff --git a/goblint.opam.template b/goblint.opam.template index a9bb491ce51..13727b6adbb 100644 --- a/goblint.opam.template +++ b/goblint.opam.template @@ -3,7 +3,7 @@ available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#da9e00f53bd306ef2546836ccf2dc91bc72fa318" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index b64bd58dc84..161f2d36558 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -8,15 +8,15 @@ │ (body) ▼ ┌───────────────────────────────┐ - │ foo.c:2:7-2:12 │ - │ (foo.c:2:7-2:12) │ + │ foo.c:2:3-2:19 │ + │ (foo.c:2:7-2:12 (synthetic)) │ └───────────────────────────────┘ │ │ a = 1 ▼ ┌───────────────────────────────┐ - │ foo.c:2:14-2:19 │ - │ (foo.c:2:14-2:19) │ + │ foo.c:2:3-2:19 (synthetic) │ + │ (foo.c:2:14-2:19 (synthetic)) │ └───────────────────────────────┘ │ │ b = 1 diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index e1272f38856..877cee2e0ec 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -11,8 +11,8 @@ │ │ (body) │ │ ▼ │ │ ┌────────────────────────────────────┐ │ - │ │ pr-758.c:5:7-5:13 │ │ - │ │ (pr-758.c:5:7-5:13) │ │ + │ │ pr-758.c:5:3-5:13 │ │ + │ │ (pr-758.c:5:7-5:13 (synthetic)) │ │ │ └────────────────────────────────────┘ │ │ │ │ x = x + 1 │ │ x = 42 │ @@ -46,14 +46,14 @@ │ i = k ▼ ┌────────────────────────────────────┐ - │ pr-758.c:20:15-20:24 │ - │ (pr-758.c:20:15-20:24) │ + │ pr-758.c:20:3-20:25 │ + │ (pr-758.c:20:15-20:24 (synthetic)) │ └────────────────────────────────────┘ │ │ a.kaal = 2 ▼ ┌────────────────────────────────────┐ - │ pr-758.c:20:15-20:24 (synthetic) │ + │ pr-758.c:20:3-20:25 (synthetic) │ │ (pr-758.c:20:15-20:24 (synthetic)) │ └────────────────────────────────────┘ │ From 8dfd8fa76e117146981966a8944bb6422a643c5d Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 15 Feb 2024 12:02:15 +0200 Subject: [PATCH 08/40] Move YAML witness node predicates to WitnessUtil --- src/witness/witnessUtil.ml | 21 +++++++++++++++++++++ src/witness/yamlWitness.ml | 31 ++++++------------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index 12bc598be52..661fefaa9ef 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -81,6 +81,27 @@ struct emit_other end +module YamlInvariant (FileCfg: MyCFG.FileCfg) = +struct + include Invariant (FileCfg) + + let is_stub_node n = + let fundec = Node.find_fundec n in + Cil.hasAttribute "goblint_stub" fundec.svar.vattr + + let is_invariant_node (n : Node.t) = + let loc = Node.location n in + match n with + | Statement _ -> + not loc.synthetic && is_invariant_node n && not (is_stub_node n) + | FunctionEntry _ | Function _ -> + (* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *) + false + + let is_loop_head_node n = + NH.mem loop_heads n && not (is_stub_node n) +end + module InvariantExp = struct module ES = SetDomain.Make (CilType.Exp) diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index d9d39ccee19..988a8bfd0e1 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -165,7 +165,7 @@ struct open SpecSys module NH = BatHashtbl.Make (Node) - module WitnessInvariant = WitnessUtil.Invariant (FileCfg) + module WitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) module FMap = BatHashtbl.Make (CilType.Fundec) module FCMap = BatHashtbl.Make (Printable.Prod (CilType.Fundec) (Spec.C)) type con_inv = {node: Node.t; context: Spec.C.t; invariant: Invariant.t; state: Spec.D.t} @@ -193,25 +193,6 @@ struct in let task = Entry.task ~input_files ~data_model ~specification in - let is_stub_node n = - let fundec = Node.find_fundec n in - Cil.hasAttribute "goblint_stub" fundec.svar.vattr - in - - let is_invariant_node (n : Node.t) = - let loc = Node.location n in - match n with - | Statement _ -> - not loc.synthetic && WitnessInvariant.is_invariant_node n && not (is_stub_node n) - | FunctionEntry _ | Function _ -> - (* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *) - false - in - - let is_loop_head_node n = - WitnessUtil.NH.mem WitnessInvariant.loop_heads n && not (is_stub_node n) - in - let local_lvals n local = if GobConfig.get_bool "witness.invariant.accessed" then ( match R.ask_local_node n ~local MayAccessed with @@ -254,7 +235,7 @@ struct let entries = if entry_type_enabled YamlWitnessType.LocationInvariant.entry_type then ( LH.fold (fun loc ns acc -> - if List.exists is_invariant_node ns then ( + if List.exists WitnessInvariant.is_invariant_node ns then ( let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in let lvals = local_lvals n local in @@ -287,7 +268,7 @@ struct let entries = if entry_type_enabled YamlWitnessType.LoopInvariant.entry_type then ( LH.fold (fun loc ns acc -> - if WitnessInvariant.emit_loop_head && List.exists is_loop_head_node ns then ( + if WitnessInvariant.emit_loop_head && List.exists WitnessInvariant.is_loop_head_node ns then ( let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) @@ -392,7 +373,7 @@ struct (* 3. Generate precondition invariants *) LHT.fold (fun ((n, c) as lvar) local acc -> - if is_invariant_node n then ( + if WitnessInvariant.is_invariant_node n then ( let fundec = Node.find_fundec n in let pre_lvar = (Node.FunctionEntry fundec, c) in let query = Queries.Invariant Invariant.default_context in @@ -449,7 +430,7 @@ struct let invariants = if invariant_type_enabled YamlWitnessType.InvariantSet.LocationInvariant.invariant_type then ( LH.fold (fun loc ns acc -> - if List.exists is_invariant_node ns then ( + if List.exists WitnessInvariant.is_invariant_node ns then ( let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in let lvals = local_lvals n local in @@ -482,7 +463,7 @@ struct let invariants = if invariant_type_enabled YamlWitnessType.InvariantSet.LoopInvariant.invariant_type then ( LH.fold (fun loc ns acc -> - if WitnessInvariant.emit_loop_head && List.exists is_loop_head_node ns then ( + if WitnessInvariant.emit_loop_head && List.exists WitnessInvariant.is_loop_head_node ns then ( let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) From 39f05354f52693d3aeb69d7dc1d30e42b9d93973 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 15 Feb 2024 12:21:22 +0200 Subject: [PATCH 09/40] Move YAML witness validation node predicates to WitnessUtil --- src/analyses/unassumeAnalysis.ml | 6 ++---- src/witness/witnessUtil.ml | 13 +++++++++++++ src/witness/yamlWitness.ml | 9 ++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/analyses/unassumeAnalysis.ml b/src/analyses/unassumeAnalysis.ml index 5895f242c9f..5194d1c45c6 100644 --- a/src/analyses/unassumeAnalysis.ml +++ b/src/analyses/unassumeAnalysis.ml @@ -48,18 +48,16 @@ struct let file = !Cilfacade.current_file module Cfg = (val !MyCFG.current_cfg) end in - let module WitnessInvariant = WitnessUtil.Invariant (FileCfg) in + let module WitnessInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in (* DFS, copied from CfgTools.find_backwards_reachable *) let reachable = NH.create 100 in let rec iter_node node = if not (NH.mem reachable node) then begin NH.replace reachable node (); - (* TODO: filter synthetic? - See YamlWitness. *) if WitnessInvariant.is_invariant_node node then Locator.add locator (Node.location node) node; - if WitnessUtil.NH.mem WitnessInvariant.loop_heads node then + if WitnessInvariant.is_loop_head_node node then Locator.add loop_locator (Node.location node) node; List.iter (fun (_, prev_node) -> iter_node prev_node diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index 661fefaa9ef..f15e6e19ca8 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -102,6 +102,19 @@ struct NH.mem loop_heads n && not (is_stub_node n) end +module YamlInvariantValidate (FileCfg: MyCFG.FileCfg) = +struct + include Invariant (FileCfg) + + (* TODO: filter synthetic? + + Almost all loops are transformed by CIL, so the loop constructs all get synthetic locations. Filtering them from the locator could give some odd behavior: if the location is right before the loop and all the synthetic loop head stuff is filtered, then the first non-synthetic node is already inside the loop, not outside where the location actually was. + Similarly, if synthetic locations are then filtered, witness.invariant.loop-head becomes essentially useless. + I guess at some point during testing and benchmarking I achieved better results with the filtering removed. *) + + let is_loop_head_node = NH.mem loop_heads +end + module InvariantExp = struct module ES = SetDomain.Make (CilType.Exp) diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index 988a8bfd0e1..8ce012974cf 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -546,7 +546,7 @@ struct module Locator = WitnessUtil.Locator (EQSys.LVar) module LvarS = Locator.ES - module WitnessInvariant = WitnessUtil.Invariant (FileCfg) + module WitnessInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) module InvariantParser = WitnessUtil.InvariantParser module VR = ValidationResult @@ -566,14 +566,9 @@ struct let loop_locator = Locator.create () in LHT.iter (fun ((n, _) as lvar) _ -> let loc = Node.location n in - (* TODO: filter synthetic? - - Almost all loops are transformed by CIL, so the loop constructs all get synthetic locations. Filtering them from the locator could give some odd behavior: if the location is right before the loop and all the synthetic loop head stuff is filtered, then the first non-synthetic node is already inside the loop, not outside where the location actually was. - Similarly, if synthetic locations are then filtered, witness.invariant.loop-head becomes essentially useless. - I guess at some point during testing and benchmarking I achieved better results with the filtering removed. *) if WitnessInvariant.is_invariant_node n then Locator.add locator loc lvar; - if WitnessUtil.NH.mem WitnessInvariant.loop_heads n then + if WitnessInvariant.is_loop_head_node n then Locator.add loop_locator loc lvar ) lh; From cfaeda39c5483c842a55437c9a116fbacf6ad180 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 15 Feb 2024 12:32:27 +0200 Subject: [PATCH 10/40] Extract Server.is_server_node --- src/util/server.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/server.ml b/src/util/server.ml index 31e10366527..1781d88b760 100644 --- a/src/util/server.ml +++ b/src/util/server.ml @@ -121,6 +121,10 @@ let serve serv = |> Seq.map Packet.t_of_yojson |> Seq.iter (handle_packet serv) +let is_server_node cfgnode = + let loc = UpdateCil.getLoc cfgnode in + not loc.synthetic + let arg_wrapper: (module ArgWrapper) ResettableLazy.t = ResettableLazy.from_fun (fun () -> let module Arg = (val (Option.get_exn !ArgTools.current_arg Response.Error.(E (make ~code:RequestFailed ~message:"not analyzed or arg disabled" ())))) in @@ -133,7 +137,7 @@ let arg_wrapper: (module ArgWrapper) ResettableLazy.t = Arg.iter_nodes (fun n -> let cfgnode = Arg.Node.cfgnode n in let loc = UpdateCil.getLoc cfgnode in - if not loc.synthetic then + if is_server_node cfgnode then Locator.add locator loc n; StringH.replace ids (Arg.Node.to_string n) n; StringH.add cfg_nodes (Node.show_id cfgnode) n (* add for find_all *) @@ -248,7 +252,7 @@ let node_locator: Locator.t ResettableLazy.t = if not (NH.mem reachable node) then begin NH.replace reachable node (); let loc = UpdateCil.getLoc node in - if not loc.synthetic then + if is_server_node node then Locator.add locator loc node; List.iter (fun (_, prev_node) -> iter_node prev_node From 994d28730ff2b9102b22aedb3248c2808c49ff0a Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 15 Feb 2024 12:36:23 +0200 Subject: [PATCH 11/40] Add node predicate output to cfgDot --- tests/regression/00-sanity/19-if-0.t | 69 +++--- tests/regression/00-sanity/20-if-0-realnode.t | 17 +- tests/regression/00-sanity/21-empty-loops.t | 225 ++++++++++++------ tests/regression/cfg/foo.t/run.t | 108 +++++---- tests/regression/cfg/issue-1356.t/run.t | 49 +++- tests/regression/cfg/pr-758.t/run.t | 28 ++- tests/regression/cfg/util/cfgDot.ml | 29 ++- tests/regression/cfg/util/dune | 1 + 8 files changed, 364 insertions(+), 162 deletions(-) diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index f847d75446b..ffe07ec75bf 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -1,33 +1,42 @@ $ cfgDot 19-if-0.c $ graph-easy --as=boxart main.dot - ┌────────────────────────┐ - │ main() │ - └────────────────────────┘ - │ - │ (body) - ▼ - ┌────────────────────────┐ ┌────────────────────────┐ - │ 19-if-0.c:15:9-15:27 │ Neg(0) │ 19-if-0.c:9:5-16:5 │ - │ (19-if-0.c:15:9-15:27) │ ◀──────────────────── │ (19-if-0.c:9:9-9:10) │ - └────────────────────────┘ └────────────────────────┘ - │ │ - │ │ Pos(0) - │ ▼ - │ ┌────────────────────────┐ - │ │ 19-if-0.c:11:9-11:16 │ - │ │ (19-if-0.c:11:9-11:16) │ - │ └────────────────────────┘ - │ │ - │ │ stuff() - │ ▼ - │ ┌────────────────────────┐ - │ __goblint_check(1) │ 19-if-0.c:17:5-17:13 │ - └────────────────────────────────────────────▶ │ (unknown) │ - └────────────────────────┘ - │ - │ return 0 - ▼ - ┌────────────────────────┐ - │ return of main() │ - └────────────────────────┘ + ┌────────────────────────────────┐ + │ main() │ + └────────────────────────────────┘ + │ + │ (body) + ▼ + ┌────────────────────────────────┐ ┌────────────────────────────────┐ + │ 19-if-0.c:15:9-15:27 │ │ 19-if-0.c:9:5-16:5 │ + │ (19-if-0.c:15:9-15:27) │ │ (19-if-0.c:9:9-9:10) │ + │ YAML loc: true, loop: false │ │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ Neg(0) │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ ◀──────────────────── │ GraphML: true; server: true │ + └────────────────────────────────┘ └────────────────────────────────┘ + │ │ + │ │ Pos(0) + │ ▼ + │ ┌────────────────────────────────┐ + │ │ 19-if-0.c:11:9-11:16 │ + │ │ (19-if-0.c:11:9-11:16) │ + │ │ YAML loc: true, loop: false │ + │ │ YAMLval loc: true, loop: false │ + │ │ GraphML: true; server: true │ + │ └────────────────────────────────┘ + │ │ + │ │ stuff() + │ ▼ + │ ┌────────────────────────────────┐ + │ │ 19-if-0.c:17:5-17:13 │ + │ │ (unknown) │ + │ │ YAML loc: true, loop: false │ + │ __goblint_check(1) │ YAMLval loc: true, loop: false │ + └────────────────────────────────────────────────────▶ │ GraphML: true; server: true │ + └────────────────────────────────┘ + │ + │ return 0 + ▼ + ┌────────────────────────────────┐ + │ return of main() │ + └────────────────────────────────┘ diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index 06a0bba865b..f80eebb6ee8 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -8,10 +8,13 @@ │ (body) ▼ ┌─────────────────────────────────┐ - │ 20-if-0-realnode.c:8:5-14:5 │ Neg(0) - │ (20-if-0-realnode.c:8:9-8:10) │ ─────────┐ - │ [20-if-0-realnode.c:7:5-8:5 │ │ - │ (unknown)] │ ◀────────┘ + │ 20-if-0-realnode.c:8:5-14:5 │ + │ (20-if-0-realnode.c:8:9-8:10) │ + │ [20-if-0-realnode.c:7:5-8:5 │ + │ (unknown)] │ Neg(0) + │ YAML loc: true, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ └─────────────────────────────────┘ │ │ Pos(0) @@ -19,6 +22,9 @@ ┌─────────────────────────────────┐ │ 20-if-0-realnode.c:10:9-10:16 │ │ (20-if-0-realnode.c:10:9-10:16) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └─────────────────────────────────┘ │ │ stuff() @@ -26,6 +32,9 @@ ┌─────────────────────────────────┐ │ 20-if-0-realnode.c:15:5-15:13 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └─────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 202a4d10717..4fa5878b768 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -1,31 +1,37 @@ $ cfgDot 21-empty-loops.c $ graph-easy --as=boxart f_empty_goto_loop.dot - ┌───────────────────────────────┐ - │ f_empty_goto_loop() │ - └───────────────────────────────┘ + ┌────────────────────────────────┐ + │ f_empty_goto_loop() │ + └────────────────────────────────┘ │ │ (body) ▼ - ┌───────────────────────────────┐ - │ 21-empty-loops.c:57:3-57:31 │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:56:1-57:3 │ │ - │ (unknown)] │ ◀──────┘ - └───────────────────────────────┘ + ┌────────────────────────────────┐ + │ 21-empty-loops.c:57:3-57:31 │ + │ (unknown) │ + │ [21-empty-loops.c:56:1-57:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ + └────────────────────────────────┘ │ │ Neg(1) ▼ - ┌───────────────────────────────┐ - │ 21-empty-loops.c:58:1-58:1 │ - │ (unknown) │ - └───────────────────────────────┘ + ┌────────────────────────────────┐ + │ 21-empty-loops.c:58:1-58:1 │ + │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └────────────────────────────────┘ │ │ return ▼ - ┌───────────────────────────────┐ - │ return of f_empty_goto_loop() │ - └───────────────────────────────┘ + ┌────────────────────────────────┐ + │ return of f_empty_goto_loop() │ + └────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop.dot ┌────────────────────────────────────────────┐ @@ -34,10 +40,12 @@ │ │ (body) ▼ - ┌────────────────────────────────────────────┐ Pos(1) - │ 21-empty-loops.c:62:3-62:14 (synthetic) │ ─────────┐ - │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ │ - │ │ ◀────────┘ + ┌────────────────────────────────────────────┐ + │ 21-empty-loops.c:62:3-62:14 (synthetic) │ + │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ Pos(1) + │ YAML loc: false, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ ◀────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -45,6 +53,9 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:63:1-63:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ │ return @@ -57,13 +68,19 @@ ┌──────────────────────────────────────┐ │ 21-empty-loops.c:75:3-75:11 │ │ (21-empty-loops.c:75:3-75:11) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────┘ │ │ suffix() ▼ ┌──────────────────────────────────────┐ │ 21-empty-loops.c:76:1-76:1 │ - │ (unknown) │ ◀┐ + │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ ◀┐ └──────────────────────────────────────┘ │ │ │ │ return │ @@ -78,10 +95,13 @@ │ (body) │ ▼ │ ┌──────────────────────────────────────┐ │ - skip │ 21-empty-loops.c:73:3-73:38 │ │ - ┌─────── │ (unknown) │ │ - │ │ [21-empty-loops.c:72:1-73:3 │ │ - └──────▶ │ (unknown)] │ ─┘ + │ 21-empty-loops.c:73:3-73:38 │ │ + │ (unknown) │ │ + │ [21-empty-loops.c:72:1-73:3 │ │ + skip │ (unknown)] │ │ + ┌─────── │ YAML loc: true, loop: true │ │ + │ │ YAMLval loc: true, loop: true │ │ + └──────▶ │ GraphML: true; server: true │ ─┘ └──────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop_suffix.dot @@ -91,10 +111,12 @@ │ │ (body) ▼ - ┌────────────────────────────────────────────┐ Pos(1) - │ 21-empty-loops.c:80:3-80:14 (synthetic) │ ─────────┐ - │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ │ - │ │ ◀────────┘ + ┌────────────────────────────────────────────┐ + │ 21-empty-loops.c:80:3-80:14 (synthetic) │ + │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ Pos(1) + │ YAML loc: false, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ ◀────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -102,6 +124,9 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:82:3-82:11 │ │ (21-empty-loops.c:82:3-82:11) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ │ suffix() @@ -109,6 +134,9 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:83:1-83:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ │ return @@ -124,10 +152,12 @@ │ │ (body) ▼ - ┌──────────────────────────────────┐ body() - │ 21-empty-loops.c:93:3-93:9 │ ─────────┐ - │ (21-empty-loops.c:93:3-93:9) │ │ - │ │ ◀────────┘ + ┌──────────────────────────────────┐ + │ 21-empty-loops.c:93:3-93:9 │ + │ (21-empty-loops.c:93:3-93:9) │ body() + │ YAML loc: true, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────┘ │ │ Neg(1) @@ -135,6 +165,9 @@ ┌──────────────────────────────────┐ │ 21-empty-loops.c:95:1-95:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────┘ │ │ return @@ -154,8 +187,11 @@ │ │ (body) │ │ ▼ │ ┌─────────────────────────────────┐ ┌────────────────────────────────────────────┐ │ - │ 21-empty-loops.c:101:5-101:11 │ Pos(1) │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ - │ (21-empty-loops.c:101:5-101:11) │ ◀──────── │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ ◀┘ + │ 21-empty-loops.c:101:5-101:11 │ │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ + │ (21-empty-loops.c:101:5-101:11) │ │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ │ + │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ YAMLval loc: true, loop: false │ Pos(1) │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────── │ GraphML: true; server: false │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -163,6 +199,9 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:103:1-103:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ │ return @@ -182,15 +221,21 @@ ┌──────────────────────────────────────┐ │ 21-empty-loops.c:112:3-112:11 │ │ (21-empty-loops.c:112:3-112:11) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────┘ │ │ prefix() ▼ ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:115:3-115:38 │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:114:1-115:3 │ │ - │ (unknown)] │ ◀──────┘ + │ 21-empty-loops.c:115:3-115:38 │ + │ (unknown) │ + │ [21-empty-loops.c:114:1-115:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └──────────────────────────────────────┘ │ │ Neg(1) @@ -198,6 +243,9 @@ ┌──────────────────────────────────────┐ │ 21-empty-loops.c:116:1-116:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────┘ │ │ return @@ -216,14 +264,19 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:120:3-120:11 │ │ (21-empty-loops.c:120:3-120:11) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ │ prefix() ▼ - ┌──────────────────────────────────────────────┐ Pos(1) - │ 21-empty-loops.c:122:3-122:14 (synthetic) │ ─────────┐ - │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ │ - │ │ ◀────────┘ + ┌──────────────────────────────────────────────┐ + │ 21-empty-loops.c:122:3-122:14 (synthetic) │ + │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ Pos(1) + │ YAML loc: false, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ ◀────────┘ └──────────────────────────────────────────────┘ │ │ Neg(1) @@ -231,6 +284,9 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:123:1-123:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ │ return @@ -247,10 +303,13 @@ │ (body) ▼ ┌─────────────────────────────────────────┐ - │ unknown │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:127:1-128:3 │ │ - │ (unknown)] │ ◀──────┘ + │ unknown │ + │ (unknown) │ + │ [21-empty-loops.c:127:1-128:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ │ │ Neg(1) @@ -258,6 +317,9 @@ ┌─────────────────────────────────────────┐ │ 21-empty-loops.c:131:1-131:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ │ return @@ -273,10 +335,12 @@ │ │ (body) ▼ - ┌──────────────────────────────────────────────┐ Pos(1) - │ 21-empty-loops.c:135:3-137:3 (synthetic) │ ─────────┐ - │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ │ - │ │ ◀────────┘ + ┌──────────────────────────────────────────────┐ + │ 21-empty-loops.c:135:3-137:3 (synthetic) │ + │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ Pos(1) + │ YAML loc: false, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ ◀────────┘ └──────────────────────────────────────────────┘ │ │ Neg(1) @@ -284,6 +348,9 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:138:1-138:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ │ return @@ -300,10 +367,13 @@ │ (body) ▼ ┌────────────────────────────────────────┐ - │ 21-empty-loops.c:143:3-143:42 │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:142:1-143:3 │ │ - │ (unknown)] │ ◀──────┘ + │ 21-empty-loops.c:143:3-143:42 │ + │ (unknown) │ + │ [21-empty-loops.c:142:1-143:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────┘ │ │ Neg(1) @@ -311,6 +381,9 @@ ┌────────────────────────────────────────┐ │ 21-empty-loops.c:146:1-146:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────┘ │ │ return @@ -327,10 +400,13 @@ │ (body) ▼ ┌────────────────────────────────────────────────────────┐ - │ unknown │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:150:1-151:3 │ │ - │ (unknown)] │ ◀──────┘ + │ unknown │ + │ (unknown) │ + │ [21-empty-loops.c:150:1-151:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -338,6 +414,9 @@ ┌────────────────────────────────────────────────────────┐ │ 21-empty-loops.c:155:1-155:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────────────────────────┘ │ │ return @@ -354,10 +433,13 @@ │ (body) ▼ ┌─────────────────────────────────────────────────────────┐ - │ 21-empty-loops.c:160:3-160:59 │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:159:1-160:3 │ │ - │ (unknown)] │ ◀──────┘ + │ 21-empty-loops.c:160:3-160:59 │ + │ (unknown) │ + │ [21-empty-loops.c:159:1-160:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -365,6 +447,9 @@ ┌─────────────────────────────────────────────────────────┐ │ 21-empty-loops.c:164:1-164:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └─────────────────────────────────────────────────────────┘ │ │ return @@ -381,10 +466,13 @@ │ (body) ▼ ┌───────────────────────────────────────────────────────┐ - │ unknown │ skip - │ (unknown) │ ───────┐ - │ [21-empty-loops.c:168:1-169:3 │ │ - │ (unknown)] │ ◀──────┘ + │ unknown │ + │ (unknown) │ + │ [21-empty-loops.c:168:1-169:3 │ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -392,6 +480,9 @@ ┌───────────────────────────────────────────────────────┐ │ 21-empty-loops.c:174:1-174:1 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └───────────────────────────────────────────────────────┘ │ │ return diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index a9f91bf4a6d..34fa6cae3dd 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -1,48 +1,66 @@ $ cfgDot foo.c $ graph-easy --as=boxart main.dot - ┌───────────────────────────────┐ - │ main() │ - └───────────────────────────────┘ - │ - │ (body) - ▼ - ┌───────────────────────────────┐ - │ foo.c:2:7-2:12 │ - │ (foo.c:2:7-2:12) │ - └───────────────────────────────┘ - │ - │ a = 1 - ▼ - ┌───────────────────────────────┐ - │ foo.c:2:14-2:19 │ - │ (foo.c:2:14-2:19) │ - └───────────────────────────────┘ - │ - │ b = 1 - ▼ - ┌──────────────────┐ ┌───────────────────────────────┐ - │ foo.c:7:3-7:11 │ Neg(a > 0) │ foo.c:3:3-6:3 (synthetic) │ - ┌──────▶ │ (unknown) │ ◀──────────── │ (foo.c:3:10-3:20 (synthetic)) │ ◀┐ - │ └──────────────────┘ └───────────────────────────────┘ │ - │ │ │ │ - │ │ return 0 │ Pos(a > 0) │ - │ ▼ ▼ │ - │ Neg(b) ┌──────────────────┐ ┌───────────────────────────────┐ │ - │ │ return of main() │ │ foo.c:3:3-6:3 (synthetic) │ │ - │ │ │ ┌─────────── │ (foo.c:3:10-3:20 (synthetic)) │ │ - │ └──────────────────┘ │ └───────────────────────────────┘ │ - │ │ │ │ - └──────────────────────────────┘ │ Pos(b) │ b = b - 1 - ▼ │ - ┌───────────────────────────────┐ │ - │ foo.c:4:5-4:8 │ │ - │ (foo.c:4:5-4:8) │ │ - └───────────────────────────────┘ │ - │ │ - │ a = a + 1 │ - ▼ │ - ┌───────────────────────────────┐ │ - │ foo.c:5:5-5:8 │ │ - │ (foo.c:5:5-5:8) │ ─┘ - └───────────────────────────────┘ + ┌────────────────────────────────┐ + │ main() │ + └────────────────────────────────┘ + │ + │ (body) + ▼ + ┌────────────────────────────────┐ + │ foo.c:2:7-2:12 │ + │ (foo.c:2:7-2:12) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └────────────────────────────────┘ + │ + │ a = 1 + ▼ + ┌────────────────────────────────┐ + │ foo.c:2:14-2:19 │ + │ (foo.c:2:14-2:19) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └────────────────────────────────┘ + │ + │ b = 1 + ▼ + ┌────────────────────────────────┐ ┌────────────────────────────────┐ + │ foo.c:7:3-7:11 │ │ foo.c:3:3-6:3 (synthetic) │ + │ (unknown) │ │ (foo.c:3:10-3:20 (synthetic)) │ + │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ + │ YAMLval loc: true, loop: false │ Neg(a > 0) │ YAMLval loc: true, loop: true │ + ┌──────▶ │ GraphML: true; server: true │ ◀──────────── │ GraphML: true; server: false │ ◀┐ + │ └────────────────────────────────┘ └────────────────────────────────┘ │ + │ │ │ │ + │ │ return 0 │ Pos(a > 0) │ + │ ▼ ▼ │ + │ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ + │ │ │ │ foo.c:3:3-6:3 (synthetic) │ │ + │ Neg(b) │ │ │ (foo.c:3:10-3:20 (synthetic)) │ │ + │ │ return of main() │ │ YAML loc: false, loop: false │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ + │ │ │ ┌─────────── │ GraphML: true; server: false │ │ + │ └────────────────────────────────┘ │ └────────────────────────────────┘ │ + │ │ │ │ + └────────────────────────────────────────────┘ │ Pos(b) │ b = b - 1 + ▼ │ + ┌────────────────────────────────┐ │ + │ foo.c:4:5-4:8 │ │ + │ (foo.c:4:5-4:8) │ │ + │ YAML loc: true, loop: false │ │ + │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: true │ │ + └────────────────────────────────┘ │ + │ │ + │ a = a + 1 │ + ▼ │ + ┌────────────────────────────────┐ │ + │ foo.c:5:5-5:8 │ │ + │ (foo.c:5:5-5:8) │ │ + │ YAML loc: true, loop: false │ │ + │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: true │ ─┘ + └────────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 78a81aff686..db32a3b1074 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -11,15 +11,21 @@ │ Pos((long )a >= (long )b - 2147483648) │ (body) │ ▼ ▼ │ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ - │ issue-1356.c:9:3-9:53 (synthetic) │ Pos(b <= 0) │ issue-1356.c:9:3-9:53 │ │ - │ (issue-1356.c:9:3-9:53 (synthetic)) │ ◀────────────────────────── │ (issue-1356.c:9:3-9:53) │ │ + │ issue-1356.c:9:3-9:53 (synthetic) │ │ issue-1356.c:9:3-9:53 │ │ + │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ (issue-1356.c:9:3-9:53) │ │ + │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ + │ YAMLval loc: true, loop: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: true │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Neg(b <= 0) │ │ ▼ │ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ - │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ ─┘ + │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ + │ │ YAML loc: false, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: false │ ─┘ │ └─────────────────────────────────────────┘ │ │ │ │ Neg((long )a >= (long )b - 2147483648) @@ -27,41 +33,59 @@ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ + │ │ YAML loc: false, loop: false │ + │ │ YAMLval loc: true, loop: false │ + │ │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ │ │ │ │ tmp = 0 │ ▼ │ ┌─────────────────────────────────────────┐ - │ tmp = 1 │ issue-1356.c:9:3-9:53 (synthetic) │ - └───────────────────────────────────────────────────────────────────▶ │ (issue-1356.c:9:3-9:53 (synthetic)) │ + │ │ issue-1356.c:9:3-9:53 (synthetic) │ + │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ + │ │ YAML loc: false, loop: false │ + │ tmp = 1 │ YAMLval loc: true, loop: false │ + └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp) ▼ ┌─────────────────────────────────────────┐ │ issue-1356.c:10:3-10:53 │ - │ (issue-1356.c:10:3-10:53) │ ─┐ + │ (issue-1356.c:10:3-10:53) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ ─┐ └─────────────────────────────────────────┘ │ │ │ │ Neg(b >= 0) │ ▼ │ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ - │ issue-1356.c:10:3-10:53 (synthetic) │ Neg(a <= b + 2147483647) │ issue-1356.c:10:3-10:53 (synthetic) │ │ - │ (issue-1356.c:10:3-10:53 (synthetic)) │ ◀────────────────────────── │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ Pos(b >= 0) + │ issue-1356.c:10:3-10:53 (synthetic) │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ + │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ + │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ Pos(b >= 0) + │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Pos(a <= b + 2147483647) │ │ ▼ │ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ - │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ ◀┘ + │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ + │ │ YAML loc: false, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: false │ ◀┘ │ └─────────────────────────────────────────┘ │ │ │ │ tmp___0 = 1 │ ▼ │ ┌─────────────────────────────────────────┐ - │ tmp___0 = 0 │ issue-1356.c:10:3-10:53 (synthetic) │ - └───────────────────────────────────────────────────────────────────▶ │ (issue-1356.c:10:3-10:53 (synthetic)) │ + │ │ issue-1356.c:10:3-10:53 (synthetic) │ + │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ + │ │ YAML loc: false, loop: false │ + │ tmp___0 = 0 │ YAMLval loc: true, loop: false │ + └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp___0) @@ -69,6 +93,9 @@ ┌─────────────────────────────────────────┐ │ issue-1356.c:11:3-11:15 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ │ return a - b diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index d87d9128c7a..d200302dcae 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -13,6 +13,9 @@ │ ┌────────────────────────────────────┐ │ │ │ pr-758.c:5:7-5:13 │ │ │ │ (pr-758.c:5:7-5:13) │ │ + │ │ YAML loc: true, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: true │ │ │ └────────────────────────────────────┘ │ │ │ │ x = x + 1 │ │ x = 42 │ @@ -20,13 +23,19 @@ │ ┌────────────────────────────────────┐ │ │ │ pr-758.c:6:3-8:3 (synthetic) │ │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ + │ │ YAML loc: false, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ │ │ │ │ │ x = 0 │ │ ▼ │ ┌─────────────────────────────────┐ ┌────────────────────────────────────┐ │ - │ pr-758.c:6:3-8:3 (synthetic) │ Pos(x < 10) │ pr-758.c:6:3-8:3 (synthetic) │ │ - │ (pr-758.c:6:7-6:26 (synthetic)) │ ◀───────────── │ (pr-758.c:6:7-6:26 (synthetic)) │ ◀┘ + │ pr-758.c:6:3-8:3 (synthetic) │ │ pr-758.c:6:3-8:3 (synthetic) │ │ + │ (pr-758.c:6:7-6:26 (synthetic)) │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ + │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ + │ YAMLval loc: true, loop: false │ Pos(x < 10) │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────┘ │ │ Neg(x < 10) @@ -34,6 +43,9 @@ ┌────────────────────────────────────┐ │ pr-758.c:12:3-12:12 │ │ (pr-758.c:12:3-12:12) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────┘ │ │ k = 0 @@ -41,6 +53,9 @@ ┌────────────────────────────────────┐ │ pr-758.c:12:3-12:12 (synthetic) │ │ (pr-758.c:12:3-12:12 (synthetic)) │ + │ YAML loc: false, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: false │ └────────────────────────────────────┘ │ │ i = k @@ -48,6 +63,9 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:15-20:24 │ │ (pr-758.c:20:15-20:24) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────┘ │ │ a.kaal = 2 @@ -55,6 +73,9 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:15-20:24 (synthetic) │ │ (pr-758.c:20:15-20:24 (synthetic)) │ + │ YAML loc: false, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: false │ └────────────────────────────────────┘ │ │ a.hind = 3 @@ -62,6 +83,9 @@ ┌────────────────────────────────────┐ │ pr-758.c:21:3-21:11 │ │ (unknown) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ └────────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index 3d823d39635..ec59b65ab4e 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -1,3 +1,5 @@ +open Goblint_lib + (* Part of CilCfg *) class allBBVisitor = object (* puts every instruction into its own basic block *) inherit GoblintCil.nopCilVisitor @@ -19,9 +21,13 @@ end let main () = Goblint_logs.Logs.Level.current := Info; Cilfacade.init (); + GobConfig.set_bool "witness.invariant.loop-head" true; + GobConfig.set_bool "witness.invariant.after-lock" true; + GobConfig.set_bool "witness.invariant.other" true; let ast = Cilfacade.getAST (Fpath.v Sys.argv.(1)) in GoblintCil.visitCilFileSameGlobals (new allBBVisitor) ast; + Cilfacade.current_file := ast; (* Part of CilCfg.createCFG *) GoblintCil.iterGlobals ast (function | GFun (fd, _) -> @@ -30,6 +36,16 @@ let main () = | _ -> () ); let (module Cfg) = CfgTools.compute_cfg ast in + let module FileCfg = + struct + let file = ast + module Cfg = Cfg + end + in + + let module GraphmlWitnessInvariant = WitnessUtil.Invariant (FileCfg) in + let module YamlWitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in + let module YamlWitnessValidateInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in let module LocationExtraNodeStyles = struct @@ -48,12 +64,19 @@ let main () = let pp_label_locs ppf label = let locs = CilLocation.get_labelLoc label in - Format.fprintf ppf "[%a]" pp_locs locs + Format.fprintf ppf "@;[%a]" pp_locs locs let extraNodeStyles = function - | Node.Statement stmt -> + | Node.Statement stmt as n -> let locs: CilLocation.locs = CilLocation.get_stmtLoc stmt in - let label = Format.asprintf "@[%a@;%a@]" pp_locs locs (Format.pp_print_list ~pp_sep:Format.pp_print_cut pp_label_locs) stmt.labels in + let label = + Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B@]" + pp_locs locs + (Format.pp_print_list ~pp_sep:GobFormat.pp_print_nothing pp_label_locs) stmt.labels + (YamlWitnessInvariant.is_invariant_node n) (YamlWitnessInvariant.is_loop_head_node n) + (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) + (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) + in [Printf.sprintf "label=\"%s\"" (Str.global_replace (Str.regexp "\n") "\\n" label)] | _ -> [] end diff --git a/tests/regression/cfg/util/dune b/tests/regression/cfg/util/dune index 8528aca3846..21ca60b47be 100644 --- a/tests/regression/cfg/util/dune +++ b/tests/regression/cfg/util/dune @@ -4,6 +4,7 @@ goblint-cil goblint_logs goblint_common + goblint_lib ; TODO: avoid fpath goblint.sites.dune goblint.build-info.dune) From 2b54e3448a4b9037ee8709ed738cb04d8db9d1c4 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 20 Feb 2024 12:21:05 +0200 Subject: [PATCH 12/40] Allow YAML location invariants before first initializer --- src/witness/witnessUtil.ml | 6 +++--- tests/regression/00-sanity/21-empty-loops.t | 6 +++--- tests/regression/cfg/foo.t/run.t | 2 +- tests/regression/cfg/pr-758.t/run.t | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index f15e6e19ca8..919fc27ef34 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -90,10 +90,10 @@ struct Cil.hasAttribute "goblint_stub" fundec.svar.vattr let is_invariant_node (n : Node.t) = - let loc = Node.location n in match n with - | Statement _ -> - not loc.synthetic && is_invariant_node n && not (is_stub_node n) + | Statement s -> + let locs = CilLocation.get_stmtLoc s in + not locs.loc.synthetic && is_invariant_node n && not (is_stub_node n) | FunctionEntry _ | Function _ -> (* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *) false diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 4fa5878b768..9919e7b3618 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -307,7 +307,7 @@ │ (unknown) │ │ [21-empty-loops.c:127:1-128:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: false, loop: true │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ @@ -404,7 +404,7 @@ │ (unknown) │ │ [21-empty-loops.c:150:1-151:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: false, loop: true │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ @@ -470,7 +470,7 @@ │ (unknown) │ │ [21-empty-loops.c:168:1-169:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: false, loop: true │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index c57a5189757..7d914929880 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -10,7 +10,7 @@ ┌────────────────────────────────┐ │ foo.c:2:3-2:19 │ │ (foo.c:2:7-2:12 (synthetic)) │ - │ YAML loc: false, loop: false │ + │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────┘ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index 28c78be4659..af14ba07123 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -13,7 +13,7 @@ │ ┌────────────────────────────────────┐ │ │ │ pr-758.c:5:3-5:13 │ │ │ │ (pr-758.c:5:7-5:13 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ + │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ @@ -63,7 +63,7 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:3-20:25 │ │ (pr-758.c:20:15-20:24 (synthetic)) │ - │ YAML loc: false, loop: false │ + │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ From e07fad07614ea7c0a226f092bba687776c8238db Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 20 Feb 2024 12:46:56 +0200 Subject: [PATCH 13/40] Add test for loop CFG locations --- tests/regression/cfg/loops.t/loops.c | 40 +++++++ tests/regression/cfg/loops.t/run.t | 168 +++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 tests/regression/cfg/loops.t/loops.c create mode 100644 tests/regression/cfg/loops.t/run.t diff --git a/tests/regression/cfg/loops.t/loops.c b/tests/regression/cfg/loops.t/loops.c new file mode 100644 index 00000000000..6ab811c3133 --- /dev/null +++ b/tests/regression/cfg/loops.t/loops.c @@ -0,0 +1,40 @@ +#include + +int main() { + int i; + + // while loop + i = 0; + while (i < 10) { + i++; + } + + // for loop + for (i = 0; i < 10; i++) { // TODO: allow location invariant before initializer (loop) + __goblint_check(1); + } + + // for loop with empty body + for (i = 0; i < 10; i++) { // TODO: allow location invariant before initializer (loop) + + } + + // for loop with empty increment + for (i = 0; i < 10;) { // TODO: allow location invariant before initializer (loop) + i++; + } + + // for loop with empty initializer + i = 0; + for (; i < 10; i++) { + __goblint_check(1); + } + + // do-while loop + i = 0; + do { + i++; // TODO: wrong loop head location + } while (i < 10); + + return 0; +} diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t new file mode 100644 index 00000000000..a632ece01a5 --- /dev/null +++ b/tests/regression/cfg/loops.t/run.t @@ -0,0 +1,168 @@ + $ cfgDot loops.c + + $ graph-easy --as=boxart main.dot + + ┌─────────────────────────────────────────────────────────────────────────┐ + │ │ + │ │ + ┌─────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┐ │ + │ │ │ │ + │ │ │ │ + │ ┌────────────────────────────────────────┼────────────────────────────────────────────────────┐ │ │ + │ │ │ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ ┌───────────────────────────────────┘ │ main() │ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ (body) │ │ │ + │ │ │ ▼ │ │ │ i = i + 1 + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ loops.c:7:3-7:8 │ │ │ │ + │ │ │ │ (loops.c:7:3-7:8) │ │ │ │ + │ │ │ │ YAML loc: true, loop: false │ │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ + │ │ │ │ GraphML: true; server: true │ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ i = 0 │ │ │ + │ │ │ ▼ │ │ │ + │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ + │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ + │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ + │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ + │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ + │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┼───────────────┼────┘ + │ │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ Neg(i < 10) │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:13:3-15:3 (synthetic) │ │ │ + │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ + │ │ │ YAML loc: false, loop: false │ │ i = i + 1 │ + │ │ │ YAMLval loc: true, loop: false │ │ │ + │ │ │ GraphML: true; server: false │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ i = 0 │ │ + │ │ ▼ │ │ + │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ + │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ + │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ + │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ + │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┘ │ + │ │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ │ │ + │ │ │ __goblint_check(1) │ Neg(i < 10) │ + │ │ ▼ ▼ │ + │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ + │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ + │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ + │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ + │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ + │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ │ i = 0 │ + │ ▼ │ + │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ loops.c:18:3-20:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ + │ │ (loops.c:18:7-18:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ + │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ + └────── │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀────────────────┘ + └──────────────────────────────────┘ └───────────────────────────────────┘ + │ + │ Neg(i < 10) + ▼ + ┌───────────────────────────────────┐ + │ loops.c:23:3-25:3 (synthetic) │ + │ (loops.c:23:7-23:22 (synthetic)) │ + │ YAML loc: false, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: false │ + └───────────────────────────────────┘ + │ + │ i = 0 + ▼ + ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ + │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ + │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ + │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ + │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 + │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┐ + └──────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ │ Neg(i < 10) │ + │ ▼ │ + │ ┌───────────────────────────────────┐ │ + │ │ loops.c:28:3-28:8 │ │ + │ │ (loops.c:28:3-28:8) │ │ + │ │ YAML loc: true, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: true │ │ + │ └───────────────────────────────────┘ │ + │ │ │ + ┌────┘ │ i = 0 │ + │ ▼ │ + │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ │ + │ │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ │ + │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ + │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┼─────────────┐ + │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ __goblint_check(1) │ Neg(i < 10) │ │ + │ ▼ ▼ │ │ + │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:3-34:8 │ │ │ + │ │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:3-34:8) │ │ │ + │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ + │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ + │ └──────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ i = 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:36:5-36:8 │ │ │ + │ │ │ (loops.c:36:5-36:8) │ │ │ + │ │ │ YAML loc: true, loop: true │ │ │ + │ │ │ YAMLval loc: true, loop: true │ │ │ + │ │ │ GraphML: true; server: true │ ◀┐ │ │ + │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ + │ │ │ i = i + 1 │ Pos(i < 10) │ │ + │ │ ▼ │ │ │ + │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ loops.c:35:3-37:19 (synthetic) │ │ │ │ + │ │ │ (loops.c:37:12-37:19 (synthetic)) │ │ │ │ + │ │ │ YAML loc: false, loop: false │ │ │ │ + │ │ │ YAMLval loc: true, loop: false │ │ │ │ + │ │ │ GraphML: true; server: false │ ─┘ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ Neg(i < 10) │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:39:3-39:11 │ │ │ + │ │ │ (loops.c:39:10-39:11) │ │ │ + │ │ │ YAML loc: true, loop: false │ │ │ + │ │ │ YAMLval loc: true, loop: false │ │ │ + │ │ │ GraphML: true; server: true │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ return 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ return of main() │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ + └────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┘ │ + │ │ + │ │ + └───────────────────────────────────────────────────────────────────────────────────────┘ + + From 471d9b51eea1128b514b8fb9555b059f1efb7ff5 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 20 Feb 2024 13:08:18 +0200 Subject: [PATCH 14/40] Make first for initializer loc non-synthetic --- goblint.opam | 2 +- goblint.opam.locked | 2 +- goblint.opam.template | 2 +- tests/regression/cfg/loops.t/loops.c | 6 +++--- tests/regression/cfg/loops.t/run.t | 12 ++++++------ tests/regression/cfg/pr-758.t/run.t | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/goblint.opam b/goblint.opam index 114ef449d94..4b84af1efac 100644 --- a/goblint.opam +++ b/goblint.opam @@ -77,7 +77,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git" available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/goblint.opam.locked b/goblint.opam.locked index 35ca1583f6e..daabd097a4a 100644 --- a/goblint.opam.locked +++ b/goblint.opam.locked @@ -133,7 +133,7 @@ post-messages: [ pin-depends: [ [ "goblint-cil.2.0.3" - "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" + "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" ] [ "ppx_deriving.5.2.1" diff --git a/goblint.opam.template b/goblint.opam.template index 13727b6adbb..a3bb99ff5cb 100644 --- a/goblint.opam.template +++ b/goblint.opam.template @@ -3,7 +3,7 @@ available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ee64e4a30eef8b69483a88111ad91aec90eed2ac" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/tests/regression/cfg/loops.t/loops.c b/tests/regression/cfg/loops.t/loops.c index 6ab811c3133..7797f70715e 100644 --- a/tests/regression/cfg/loops.t/loops.c +++ b/tests/regression/cfg/loops.t/loops.c @@ -10,17 +10,17 @@ int main() { } // for loop - for (i = 0; i < 10; i++) { // TODO: allow location invariant before initializer (loop) + for (i = 0; i < 10; i++) { __goblint_check(1); } // for loop with empty body - for (i = 0; i < 10; i++) { // TODO: allow location invariant before initializer (loop) + for (i = 0; i < 10; i++) { } // for loop with empty increment - for (i = 0; i < 10;) { // TODO: allow location invariant before initializer (loop) + for (i = 0; i < 10;) { i++; } diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index a632ece01a5..d760f692dd0 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -37,9 +37,9 @@ │ │ │ Neg(i < 10) │ │ │ │ ▼ │ │ │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:13:3-15:3 (synthetic) │ │ │ + │ │ │ loops.c:13:3-15:3 │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ - │ │ │ YAML loc: false, loop: false │ │ i = i + 1 │ + │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ │ └───────────────────────────────────┘ │ │ @@ -57,9 +57,9 @@ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ │ ▼ ▼ │ │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ + │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ - │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ + │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ @@ -77,9 +77,9 @@ │ Neg(i < 10) ▼ ┌───────────────────────────────────┐ - │ loops.c:23:3-25:3 (synthetic) │ + │ loops.c:23:3-25:3 │ │ (loops.c:23:7-23:22 (synthetic)) │ - │ YAML loc: false, loop: false │ + │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └───────────────────────────────────┘ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index af14ba07123..c5e38b3f6ac 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -21,9 +21,9 @@ │ │ x = 42 │ │ ▼ │ │ ┌────────────────────────────────────┐ │ - │ │ pr-758.c:6:3-8:3 (synthetic) │ │ + │ │ pr-758.c:6:3-8:3 │ │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ + │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ From 3764aa635ae8e8e910aed703d63ec3d4f0dafc07 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 20 Feb 2024 13:08:32 +0200 Subject: [PATCH 15/40] Test for loop locations with two initializers --- tests/regression/cfg/loops.t/loops.c | 5 + tests/regression/cfg/loops.t/run.t | 357 +++++++++++++++------------ 2 files changed, 200 insertions(+), 162 deletions(-) diff --git a/tests/regression/cfg/loops.t/loops.c b/tests/regression/cfg/loops.t/loops.c index 7797f70715e..acd9db7a8c5 100644 --- a/tests/regression/cfg/loops.t/loops.c +++ b/tests/regression/cfg/loops.t/loops.c @@ -30,6 +30,11 @@ int main() { __goblint_check(1); } + // for loop with two initializers + for (int j = (i = 0); i < 10; i++) { + __goblint_check(1); + } + // do-while loop i = 0; do { diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index d760f692dd0..b7bdb69a58a 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -2,167 +2,200 @@ $ graph-easy --as=boxart main.dot - ┌─────────────────────────────────────────────────────────────────────────┐ - │ │ - │ │ - ┌─────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┐ │ - │ │ │ │ - │ │ │ │ - │ ┌────────────────────────────────────────┼────────────────────────────────────────────────────┐ │ │ - │ │ │ │ │ │ - │ │ │ ┌───────────────────────────────────┐ │ │ │ - │ │ ┌───────────────────────────────────┘ │ main() │ │ │ │ - │ │ │ └───────────────────────────────────┘ │ │ │ - │ │ │ │ │ │ │ - │ │ │ │ (body) │ │ │ - │ │ │ ▼ │ │ │ i = i + 1 - │ │ │ ┌───────────────────────────────────┐ │ │ │ - │ │ │ │ loops.c:7:3-7:8 │ │ │ │ - │ │ │ │ (loops.c:7:3-7:8) │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ - │ │ │ │ GraphML: true; server: true │ │ │ │ - │ │ │ └───────────────────────────────────┘ │ │ │ - │ │ │ │ │ │ │ - │ │ │ │ i = 0 │ │ │ - │ │ │ ▼ │ │ │ - │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ - │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ - │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ - │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ - │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ - │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┼───────────────┼────┘ - │ │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ Neg(i < 10) │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:13:3-15:3 │ │ │ - │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ - │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ - │ │ │ YAMLval loc: true, loop: false │ │ │ - │ │ │ GraphML: true; server: false │ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ i = 0 │ │ - │ │ ▼ │ │ - │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ - │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ - │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ - │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ - │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┘ │ - │ │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ - │ │ │ │ │ - │ │ │ __goblint_check(1) │ Neg(i < 10) │ - │ │ ▼ ▼ │ - │ │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 │ │ - │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ - │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ - │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ - │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ - │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ - │ │ │ - │ │ i = 0 │ - │ ▼ │ - │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ │ loops.c:18:3-20:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ - │ │ (loops.c:18:7-18:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ - │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ - └────── │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀────────────────┘ - └──────────────────────────────────┘ └───────────────────────────────────┘ - │ - │ Neg(i < 10) - ▼ - ┌───────────────────────────────────┐ - │ loops.c:23:3-25:3 │ - │ (loops.c:23:7-23:22 (synthetic)) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: false │ - └───────────────────────────────────┘ - │ - │ i = 0 - ▼ - ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ - │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ - │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ - │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ - │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 - │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┐ - └──────────────────────────────────┘ └───────────────────────────────────┘ │ - │ │ │ - │ │ Neg(i < 10) │ - │ ▼ │ - │ ┌───────────────────────────────────┐ │ - │ │ loops.c:28:3-28:8 │ │ - │ │ (loops.c:28:3-28:8) │ │ - │ │ YAML loc: true, loop: false │ │ - │ │ YAMLval loc: true, loop: false │ │ - │ │ GraphML: true; server: true │ │ - │ └───────────────────────────────────┘ │ - │ │ │ - ┌────┘ │ i = 0 │ - │ ▼ │ - │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ │ - │ │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ - │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ - │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┼─────────────┐ - │ └──────────────────────────────────┘ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ __goblint_check(1) │ Neg(i < 10) │ │ - │ ▼ ▼ │ │ - │ ┌──────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ - │ │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:3-34:8 │ │ │ - │ │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:3-34:8) │ │ │ - │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ - │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ - │ └──────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ i = 0 │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:36:5-36:8 │ │ │ - │ │ │ (loops.c:36:5-36:8) │ │ │ - │ │ │ YAML loc: true, loop: true │ │ │ - │ │ │ YAMLval loc: true, loop: true │ │ │ - │ │ │ GraphML: true; server: true │ ◀┐ │ │ - │ │ └───────────────────────────────────┘ │ │ │ - │ │ │ │ │ │ - │ │ │ i = i + 1 │ Pos(i < 10) │ │ - │ │ ▼ │ │ │ - │ │ ┌───────────────────────────────────┐ │ │ │ - │ │ │ loops.c:35:3-37:19 (synthetic) │ │ │ │ - │ │ │ (loops.c:37:12-37:19 (synthetic)) │ │ │ │ - │ │ │ YAML loc: false, loop: false │ │ │ │ - │ │ │ YAMLval loc: true, loop: false │ │ │ │ - │ │ │ GraphML: true; server: false │ ─┘ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ Neg(i < 10) │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:39:3-39:11 │ │ │ - │ │ │ (loops.c:39:10-39:11) │ │ │ - │ │ │ YAML loc: true, loop: false │ │ │ - │ │ │ YAMLval loc: true, loop: false │ │ │ - │ │ │ GraphML: true; server: true │ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ return 0 │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ return of main() │ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ - └────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┘ │ - │ │ - │ │ - └───────────────────────────────────────────────────────────────────────────────────────┘ + ┌──────────────────────────────────────────────────────────────────────────────┐ + │ │ + │ │ + ┌───────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┐ │ + │ │ │ │ + │ │ │ │ + │ ┌──────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┐ │ │ + │ │ │ │ │ │ + │ │ │ │ │ │ + │ │ ┌─────────────────────────────────────────┼────────────────────────────────────────────────────┐ │ │ │ + │ │ │ │ │ │ │ │ + │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ + │ │ │ ┌────────────────────────────────────┘ │ main() │ │ │ │ │ + │ │ │ │ └───────────────────────────────────┘ │ │ │ │ + │ │ │ │ │ │ │ │ │ i = i + 1 + │ │ │ │ │ (body) │ │ │ │ + │ │ │ │ ▼ │ │ │ │ + │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ + │ │ │ │ │ loops.c:7:3-7:8 │ │ │ │ │ + │ │ │ │ │ (loops.c:7:3-7:8) │ │ │ │ │ + │ │ │ │ │ YAML loc: true, loop: false │ │ │ │ │ + │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ + │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ + │ │ │ │ └───────────────────────────────────┘ │ │ │ │ + │ │ │ │ │ │ │ │ │ + │ │ │ │ │ i = 0 │ │ │ │ + │ │ │ │ ▼ │ │ │ │ + │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ + │ │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ │ + │ │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ │ + │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ │ + │ │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┼───────────────┼────┼────┘ + │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ Neg(i < 10) │ │ │ + │ │ │ ▼ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ loops.c:13:3-15:3 │ │ │ │ + │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ + │ │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ + │ │ │ │ GraphML: true; server: false │ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ i = 0 │ │ │ + │ │ │ ▼ │ │ │ + │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ │ + │ │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ + │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ + │ │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┘ │ │ + │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ │ │ + │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ + │ │ │ ▼ ▼ │ │ + │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 │ │ │ + │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ + │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ + │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ i = 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:18:3-20:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ │ + │ │ │ (loops.c:18:7-18:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ + │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ │ + │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ │ + │ └────── │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀────────────────┘ │ + │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ │ Neg(i < 10) │ + │ ▼ │ + │ ┌───────────────────────────────────┐ │ + │ │ loops.c:23:3-25:3 │ │ + │ │ (loops.c:23:7-23:22 (synthetic)) │ │ + │ │ YAML loc: true, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: false │ │ + │ └───────────────────────────────────┘ │ + │ │ │ + │ │ i = 0 │ + │ ▼ │ + │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ │ + │ │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ │ + │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ + └─────────── │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┘ + └───────────────────────────────────┘ └───────────────────────────────────┘ + │ + │ Neg(i < 10) + ▼ + ┌───────────────────────────────────┐ + │ loops.c:28:3-28:8 │ + │ (loops.c:28:3-28:8) │ + │ YAML loc: true, loop: false │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └───────────────────────────────────┘ + │ + │ i = 0 + ▼ + ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ + │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ + │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ + │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ + │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 + │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┐ + └───────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ __goblint_check(1) │ Neg(i < 10) │ + ▼ ▼ │ + ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:23 │ │ + │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:23 (synthetic)) │ │ + │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ + └───────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ │ i = 0 │ + │ ▼ │ + │ ┌───────────────────────────────────┐ │ + │ │ loops.c:34:8-34:23 (synthetic) │ │ + │ │ (loops.c:34:12-34:23 (synthetic)) │ │ + │ │ YAML loc: false, loop: false │ │ + │ │ YAMLval loc: true, loop: false │ │ + │ │ GraphML: true; server: false │ │ + │ └───────────────────────────────────┘ │ + │ │ │ + ┌────┘ │ j = i │ + │ ▼ │ + │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ + │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:36 (synthetic)) │ │ + │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ + │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┼────┐ + │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ __goblint_check(1) │ Neg(i < 10) │ │ + │ ▼ ▼ │ │ + │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ loops.c:34:8-34:23 (synthetic) │ │ loops.c:39:3-39:8 │ │ │ + │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ + │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ + │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ + │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ i = 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:41:5-41:8 │ │ │ + │ │ │ (loops.c:41:5-41:8) │ │ │ + │ │ │ YAML loc: true, loop: true │ │ │ + │ │ │ YAMLval loc: true, loop: true │ │ │ + │ │ │ GraphML: true; server: true │ ◀┐ │ │ + │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ + │ │ │ i = i + 1 │ Pos(i < 10) │ │ + │ │ ▼ │ │ │ + │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ loops.c:40:3-42:19 (synthetic) │ │ │ │ + │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ + │ │ │ YAML loc: false, loop: false │ │ │ │ + │ │ │ YAMLval loc: true, loop: false │ │ │ │ + │ │ │ GraphML: true; server: false │ ─┘ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ Neg(i < 10) │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:44:3-44:11 │ │ │ + │ │ │ (loops.c:44:10-44:11) │ │ │ + │ │ │ YAML loc: true, loop: false │ │ │ + │ │ │ YAMLval loc: true, loop: false │ │ │ + │ │ │ GraphML: true; server: true │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ return 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ return of main() │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ + └─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┘ │ + │ │ + │ │ + └──────────────────────────────────────────────────────────────────────────────┘ From 2de8dad693cd9f6126421c0194d9fe01fc9ac88e Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 20 Feb 2024 16:55:43 +0200 Subject: [PATCH 16/40] Find syntactic loop heads in cfgDot --- tests/regression/00-sanity/19-if-0.t | 11 +- tests/regression/00-sanity/20-if-0-realnode.t | 11 +- tests/regression/00-sanity/21-empty-loops.t | 142 +++++++++++------- tests/regression/cfg/foo.t/run.t | 14 +- tests/regression/cfg/issue-1356.t/run.t | 33 ++-- tests/regression/cfg/loops.t/run.t | 57 ++++--- tests/regression/cfg/pr-758.t/run.t | 12 +- tests/regression/cfg/util/cfgDot.ml | 17 ++- 8 files changed, 194 insertions(+), 103 deletions(-) diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index 37ba193aefe..f2c7c40a023 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -11,8 +11,9 @@ │ 19-if-0.c:15:9-15:27 │ │ 19-if-0.c:9:5-16:5 │ │ (19-if-0.c:15:9-15:27) │ │ (19-if-0.c:9:9-9:10) │ │ YAML loc: true, loop: false │ │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ Neg(0) │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ ◀──────────────────── │ GraphML: true; server: true │ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ Neg(0) │ GraphML: true; server: true │ + │ loop: │ ◀──────────────────── │ loop: │ └────────────────────────────────┘ └────────────────────────────────┘ │ │ │ │ Pos(0) @@ -23,6 +24,7 @@ │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ + │ │ loop: │ │ └────────────────────────────────┘ │ │ │ │ stuff() @@ -31,8 +33,9 @@ │ │ 19-if-0.c:17:5-17:13 │ │ │ (19-if-0.c:17:12-17:13) │ │ │ YAML loc: true, loop: false │ - │ __goblint_check(1) │ YAMLval loc: true, loop: false │ - └────────────────────────────────────────────────────▶ │ GraphML: true; server: true │ + │ │ YAMLval loc: true, loop: false │ + │ __goblint_check(1) │ GraphML: true; server: true │ + └────────────────────────────────────────────────────▶ │ loop: │ └────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index e1670c1f98d..0ddc4ce5476 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -11,10 +11,11 @@ │ 20-if-0-realnode.c:8:5-14:5 │ │ (20-if-0-realnode.c:8:9-8:10) │ │ [20-if-0-realnode.c:7:5-8:5 │ - │ (unknown)] │ Neg(0) - │ YAML loc: true, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀────────┘ + │ (unknown)] │ + │ YAML loc: true, loop: true │ Neg(0) + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀────────┘ └──────────────────────────────────┘ │ │ Pos(0) @@ -25,6 +26,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────┘ │ │ stuff() @@ -35,6 +37,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 9919e7b3618..1e046d1c13c 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -11,10 +11,11 @@ │ 21-empty-loops.c:57:3-57:31 │ │ (unknown) │ │ [21-empty-loops.c:56:1-57:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: true, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └────────────────────────────────┘ │ │ Neg(1) @@ -25,6 +26,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────┘ │ │ return @@ -42,10 +44,11 @@ ▼ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:62:3-62:14 (synthetic) │ - │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ Pos(1) - │ YAML loc: false, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: false │ ◀────────┘ + │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ + │ YAML loc: false, loop: true │ Pos(1) + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: false │ │ + │ loop: 21-empty-loops.c:62:3-62:14 │ ◀────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -56,6 +59,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -71,6 +75,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────┘ │ │ suffix() @@ -80,7 +85,8 @@ │ (unknown) │ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ ◀┐ + │ GraphML: true; server: true │ + │ loop: │ ◀┐ └──────────────────────────────────────┘ │ │ │ │ return │ @@ -98,10 +104,11 @@ │ 21-empty-loops.c:73:3-73:38 │ │ │ (unknown) │ │ │ [21-empty-loops.c:72:1-73:3 │ │ - skip │ (unknown)] │ │ - ┌─────── │ YAML loc: true, loop: true │ │ - │ │ YAMLval loc: true, loop: true │ │ - └──────▶ │ GraphML: true; server: true │ ─┘ + │ (unknown)] │ │ + skip │ YAML loc: true, loop: true │ │ + ┌─────── │ YAMLval loc: true, loop: true │ │ + │ │ GraphML: true; server: true │ │ + └──────▶ │ loop: │ ─┘ └──────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop_suffix.dot @@ -113,10 +120,11 @@ ▼ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:80:3-80:14 (synthetic) │ - │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ Pos(1) - │ YAML loc: false, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: false │ ◀────────┘ + │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ + │ YAML loc: false, loop: true │ Pos(1) + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: false │ │ + │ loop: 21-empty-loops.c:80:3-80:14 │ ◀────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -127,6 +135,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────────┘ │ │ suffix() @@ -137,6 +146,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -154,10 +164,11 @@ ▼ ┌──────────────────────────────────┐ │ 21-empty-loops.c:93:3-93:9 │ - │ (21-empty-loops.c:93:3-93:9) │ body() - │ YAML loc: true, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀────────┘ + │ (21-empty-loops.c:93:3-93:9) │ + │ YAML loc: true, loop: true │ body() + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀────────┘ └──────────────────────────────────┘ │ │ Neg(1) @@ -168,6 +179,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────┘ │ │ return @@ -190,8 +202,9 @@ │ 21-empty-loops.c:101:5-101:11 │ │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ │ (21-empty-loops.c:101:5-101:11) │ │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ - │ YAMLval loc: true, loop: false │ Pos(1) │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────── │ GraphML: true; server: false │ ◀┘ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ Pos(1) │ GraphML: true; server: false │ │ + │ loop: │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -202,6 +215,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -224,6 +238,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────┘ │ │ prefix() @@ -232,10 +247,11 @@ │ 21-empty-loops.c:115:3-115:38 │ │ (unknown) │ │ [21-empty-loops.c:114:1-115:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: true, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └──────────────────────────────────────┘ │ │ Neg(1) @@ -246,6 +262,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────┘ │ │ return @@ -267,16 +284,18 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────────────┘ │ │ prefix() ▼ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:122:3-122:14 (synthetic) │ - │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ Pos(1) - │ YAML loc: false, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: false │ ◀────────┘ + │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ + │ YAML loc: false, loop: true │ Pos(1) + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: false │ │ + │ loop: 21-empty-loops.c:122:3-122:14 │ ◀────────┘ └──────────────────────────────────────────────┘ │ │ Neg(1) @@ -287,6 +306,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────────────┘ │ │ return @@ -306,10 +326,11 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:127:1-128:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: false, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └─────────────────────────────────────────┘ │ │ Neg(1) @@ -320,6 +341,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └─────────────────────────────────────────┘ │ │ return @@ -337,10 +359,11 @@ ▼ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:135:3-137:3 (synthetic) │ - │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ Pos(1) - │ YAML loc: false, loop: true │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: false │ ◀────────┘ + │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ + │ YAML loc: false, loop: true │ Pos(1) + │ YAMLval loc: true, loop: true │ ─────────┐ + │ GraphML: true; server: false │ │ + │ loop: 21-empty-loops.c:135:3-137:3 │ ◀────────┘ └──────────────────────────────────────────────┘ │ │ Neg(1) @@ -351,6 +374,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └──────────────────────────────────────────────┘ │ │ return @@ -370,10 +394,11 @@ │ 21-empty-loops.c:143:3-143:42 │ │ (unknown) │ │ [21-empty-loops.c:142:1-143:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: true, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └────────────────────────────────────────┘ │ │ Neg(1) @@ -384,6 +409,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────┘ │ │ return @@ -403,10 +429,11 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:150:1-151:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: false, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -417,6 +444,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────────────────────────┘ │ │ return @@ -436,10 +464,11 @@ │ 21-empty-loops.c:160:3-160:59 │ │ (unknown) │ │ [21-empty-loops.c:159:1-160:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: true, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └─────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -450,6 +479,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └─────────────────────────────────────────────────────────┘ │ │ return @@ -469,10 +499,11 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:168:1-169:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ + │ (unknown)] │ + │ YAML loc: false, loop: true │ skip + │ YAMLval loc: true, loop: true │ ───────┐ + │ GraphML: true; server: true │ │ + │ loop: │ ◀──────┘ └───────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -483,6 +514,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └───────────────────────────────────────────────────────┘ │ │ return diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index 7d914929880..8c848b1fd7b 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -13,6 +13,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ + │ loop: │ └────────────────────────────────┘ │ │ a = 1 @@ -23,6 +24,7 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ + │ loop: │ └────────────────────────────────┘ │ │ b = 1 @@ -31,8 +33,9 @@ │ foo.c:7:3-7:11 │ │ foo.c:3:3-6:3 (synthetic) │ │ (foo.c:7:10-7:11) │ │ (foo.c:3:10-3:20 (synthetic)) │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ - │ YAMLval loc: true, loop: false │ Neg(a > 0) │ YAMLval loc: true, loop: true │ - ┌──────▶ │ GraphML: true; server: true │ ◀──────────── │ GraphML: true; server: false │ ◀┐ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ + │ GraphML: true; server: true │ Neg(a > 0) │ GraphML: true; server: false │ + ┌──────▶ │ loop: │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ │ └────────────────────────────────┘ └────────────────────────────────┘ │ │ │ │ │ │ │ return 0 │ Pos(a > 0) │ @@ -42,7 +45,8 @@ │ Neg(b) │ │ │ (foo.c:3:10-3:20 (synthetic)) │ │ │ │ return of main() │ │ YAML loc: false, loop: false │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ │ ┌─────────── │ GraphML: true; server: false │ │ + │ │ │ │ GraphML: true; server: false │ │ + │ │ │ ┌─────────── │ loop: │ │ │ └────────────────────────────────┘ │ └────────────────────────────────┘ │ │ │ │ │ └────────────────────────────────────────────┘ │ Pos(b) │ b = b - 1 @@ -53,6 +57,7 @@ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ │ + │ loop: │ │ └────────────────────────────────┘ │ │ │ │ a = a + 1 │ @@ -62,5 +67,6 @@ │ (foo.c:5:5-5:8) │ │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: true │ ─┘ + │ GraphML: true; server: true │ │ + │ loop: │ ─┘ └────────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 0acc007162c..a56c54c0460 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -14,8 +14,9 @@ │ issue-1356.c:9:3-9:53 (synthetic) │ │ issue-1356.c:9:3-9:53 │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ (issue-1356.c:9:3-9:53) │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ - │ YAMLval loc: true, loop: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: true │ │ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ Pos(b <= 0) │ GraphML: true; server: true │ │ + │ loop: │ ◀────────────────────────── │ loop: │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Neg(b <= 0) │ @@ -25,7 +26,8 @@ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ GraphML: true; server: false │ ─┘ + │ │ GraphML: true; server: false │ │ + │ │ loop: │ ─┘ │ └─────────────────────────────────────────┘ │ │ │ │ Neg((long )a >= (long )b - 2147483648) @@ -36,6 +38,7 @@ │ │ YAML loc: false, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ + │ │ loop: │ │ └─────────────────────────────────────────┘ │ │ │ │ tmp = 0 @@ -44,8 +47,9 @@ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ │ YAML loc: false, loop: false │ - │ tmp = 1 │ YAMLval loc: true, loop: false │ - └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ + │ │ YAMLval loc: true, loop: false │ + │ tmp = 1 │ GraphML: true; server: false │ + └───────────────────────────────────────────────────────────────────▶ │ loop: │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp) @@ -55,7 +59,8 @@ │ (issue-1356.c:10:3-10:53) │ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ ─┐ + │ GraphML: true; server: true │ + │ loop: │ ─┐ └─────────────────────────────────────────┘ │ │ │ │ Neg(b >= 0) │ @@ -63,9 +68,10 @@ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ Pos(b >= 0) - │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: false │ │ + │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ Pos(b >= 0) + │ GraphML: true; server: false │ Neg(a <= b + 2147483647) │ GraphML: true; server: false │ │ + │ loop: │ ◀────────────────────────── │ loop: │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Pos(a <= b + 2147483647) │ @@ -75,7 +81,8 @@ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ GraphML: true; server: false │ ◀┘ + │ │ GraphML: true; server: false │ │ + │ │ loop: │ ◀┘ │ └─────────────────────────────────────────┘ │ │ │ │ tmp___0 = 1 @@ -84,8 +91,9 @@ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ │ YAML loc: false, loop: false │ - │ tmp___0 = 0 │ YAMLval loc: true, loop: false │ - └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ + │ │ YAMLval loc: true, loop: false │ + │ tmp___0 = 0 │ GraphML: true; server: false │ + └───────────────────────────────────────────────────────────────────▶ │ loop: │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp___0) @@ -96,6 +104,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └─────────────────────────────────────────┘ │ │ return a - b diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index b7bdb69a58a..b0cbed15ee4 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -16,8 +16,8 @@ │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ ┌────────────────────────────────────┘ │ main() │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ - │ │ │ │ │ │ │ │ │ i = i + 1 - │ │ │ │ │ (body) │ │ │ │ + │ │ │ │ │ │ │ │ │ + │ │ │ │ │ (body) │ │ │ │ i = i + 1 │ │ │ │ ▼ │ │ │ │ │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ │ │ loops.c:7:3-7:8 │ │ │ │ │ @@ -25,6 +25,7 @@ │ │ │ │ │ YAML loc: true, loop: false │ │ │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ + │ │ │ │ │ loop: │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ │ @@ -33,8 +34,9 @@ │ │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ │ │ │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ │ │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ │ - │ │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┼───────────────┼────┼────┘ + │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ + │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ + │ │ │ │ loop: │ ◀───────────── │ loop: loops.c:8:3-10:3 │ ◀┼───────────────┼────┼────┘ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Neg(i < 10) │ │ │ @@ -42,9 +44,10 @@ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ loops.c:13:3-15:3 │ │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ + │ │ │ │ YAML loc: true, loop: false │ │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ i = i + 1 │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ + │ │ │ │ loop: │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ @@ -53,8 +56,9 @@ │ │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ │ │ │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ │ │ │ - │ │ │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀┘ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ + │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ + │ │ │ │ loop: │ ◀───────────── │ loop: loops.c:13:3-15:3 │ ◀┘ │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ @@ -64,7 +68,8 @@ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ + │ │ │ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ + │ │ └─ │ loop: │ │ loop: │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ @@ -73,8 +78,9 @@ │ │ │ loops.c:18:3-20:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ │ │ │ │ (loops.c:18:7-18:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ │ - │ │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ │ - │ └────── │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀────────────────┘ │ + │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ + │ │ │ GraphML: true; server: false │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ + │ └────── │ loop: │ ◀───────────── │ loop: loops.c:18:3-20:3 │ ◀────────────────┘ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ Neg(i < 10) │ @@ -85,6 +91,7 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ + │ │ loop: │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ i = 0 │ @@ -93,8 +100,9 @@ │ │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ │ │ │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ - │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ - └─────────── │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┘ + │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ + │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ + └─────────── │ loop: │ ◀───────────── │ loop: loops.c:23:3-25:3 │ ◀─────────────────────┘ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ Neg(i < 10) @@ -105,6 +113,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └───────────────────────────────────┘ │ │ i = 0 @@ -113,8 +122,9 @@ │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ - │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 - │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┐ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ + │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 + │ loop: │ ◀───────────── │ loop: loops.c:29:3-31:3 │ ◀─────────────────────┐ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ @@ -125,6 +135,7 @@ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ + │ loop: │ │ loop: │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ i = 0 │ @@ -135,6 +146,7 @@ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ + │ │ loop: │ │ │ └───────────────────────────────────┘ │ │ │ │ ┌────┘ │ j = i │ @@ -143,8 +155,9 @@ │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:36 (synthetic)) │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ - │ │ YAMLval loc: true, loop: false │ Pos(i < 10) │ YAMLval loc: true, loop: true │ i = i + 1 │ - │ │ GraphML: true; server: true │ ◀───────────── │ GraphML: true; server: false │ ◀─────────────────────┼────┐ + │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ + │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ + │ │ loop: │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ @@ -154,7 +167,8 @@ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ + │ │ GraphML: true; server: false │ │ GraphML: true; server: true │ │ │ + │ │ loop: │ ─┐ │ loop: │ │ │ │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ @@ -164,7 +178,8 @@ │ │ │ (loops.c:41:5-41:8) │ │ │ │ │ │ YAML loc: true, loop: true │ │ │ │ │ │ YAMLval loc: true, loop: true │ │ │ - │ │ │ GraphML: true; server: true │ ◀┐ │ │ + │ │ │ GraphML: true; server: true │ │ │ + │ │ │ loop: loops.c:40:3-42:19 │ ◀┐ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ i = i + 1 │ Pos(i < 10) │ │ @@ -174,7 +189,8 @@ │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ │ │ │ YAML loc: false, loop: false │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ - │ │ │ GraphML: true; server: false │ ─┘ │ │ + │ │ │ GraphML: true; server: false │ │ │ │ + │ │ │ loop: │ ─┘ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ Neg(i < 10) │ │ @@ -185,6 +201,7 @@ │ │ │ YAML loc: true, loop: false │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ GraphML: true; server: true │ │ │ + │ │ │ loop: │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ return 0 │ │ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index c5e38b3f6ac..71ecdc254bf 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -16,6 +16,7 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ + │ │ loop: │ │ │ └────────────────────────────────────┘ │ │ │ │ x = x + 1 │ │ x = 42 │ @@ -26,6 +27,7 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ + │ │ loop: │ │ │ └────────────────────────────────────┘ │ │ │ │ │ │ x = 0 │ @@ -34,8 +36,9 @@ │ pr-758.c:6:3-8:3 (synthetic) │ │ pr-758.c:6:3-8:3 (synthetic) │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ - │ YAMLval loc: true, loop: false │ Pos(x < 10) │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: false │ ◀───────────── │ GraphML: true; server: false │ ◀┘ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: false │ Pos(x < 10) │ GraphML: true; server: false │ │ + │ loop: │ ◀───────────── │ loop: pr-758.c:6:3-8:3 │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────┘ │ │ Neg(x < 10) @@ -46,6 +49,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────┘ │ │ k = 0 @@ -56,6 +60,7 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ + │ loop: │ └────────────────────────────────────┘ │ │ i = k @@ -66,6 +71,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ + │ loop: │ └────────────────────────────────────┘ │ │ a.kaal = 2 @@ -76,6 +82,7 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ + │ loop: │ └────────────────────────────────────┘ │ │ a.hind = 3 @@ -86,6 +93,7 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ + │ loop: │ └────────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index ec59b65ab4e..88a896f4001 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -35,7 +35,7 @@ let main () = GoblintCil.computeCFGInfo fd true | _ -> () ); - let (module Cfg) = CfgTools.compute_cfg ast in + let ((module Cfg), skipped) = CfgTools.compute_cfg_skips ast in let module FileCfg = struct let file = ast @@ -43,6 +43,18 @@ let main () = end in + let is_loop_head n = + let prevs = Cfg.prev n in + List.find_map (fun (edges, prev) -> + let stmts = CfgTools.CfgEdgeH.find skipped (prev, edges, n) in + List.find_map (fun s -> + match s.GoblintCil.skind with + | Loop (_, loc, _, _, _) -> Some loc + | _ -> None + ) stmts + ) prevs + in + let module GraphmlWitnessInvariant = WitnessUtil.Invariant (FileCfg) in let module YamlWitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in let module YamlWitnessValidateInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in @@ -70,12 +82,13 @@ let main () = | Node.Statement stmt as n -> let locs: CilLocation.locs = CilLocation.get_stmtLoc stmt in let label = - Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B@]" + Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B@;loop: %a@]" pp_locs locs (Format.pp_print_list ~pp_sep:GobFormat.pp_print_nothing pp_label_locs) stmt.labels (YamlWitnessInvariant.is_invariant_node n) (YamlWitnessInvariant.is_loop_head_node n) (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) + (Format.pp_print_option CilType.Location.pp) (is_loop_head n) in [Printf.sprintf "label=\"%s\"" (Str.global_replace (Str.regexp "\n") "\\n" label)] | _ -> [] From 01809f9becac60b3e1aab32c31ca896e33bf288b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 27 Feb 2024 16:32:06 +0200 Subject: [PATCH 17/40] Hide empty loop in cfgDot --- tests/regression/00-sanity/19-if-0.t | 11 +- tests/regression/00-sanity/20-if-0-realnode.t | 11 +- tests/regression/00-sanity/21-empty-loops.t | 103 +++++++----------- tests/regression/cfg/foo.t/run.t | 11 +- tests/regression/cfg/issue-1356.t/run.t | 33 ++---- tests/regression/cfg/loops.t/run.t | 36 +++--- tests/regression/cfg/pr-758.t/run.t | 9 +- tests/regression/cfg/util/cfgDot.ml | 7 +- 8 files changed, 80 insertions(+), 141 deletions(-) diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index f2c7c40a023..37ba193aefe 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -11,9 +11,8 @@ │ 19-if-0.c:15:9-15:27 │ │ 19-if-0.c:9:5-16:5 │ │ (19-if-0.c:15:9-15:27) │ │ (19-if-0.c:9:9-9:10) │ │ YAML loc: true, loop: false │ │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ Neg(0) │ GraphML: true; server: true │ - │ loop: │ ◀──────────────────── │ loop: │ + │ YAMLval loc: true, loop: false │ Neg(0) │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ ◀──────────────────── │ GraphML: true; server: true │ └────────────────────────────────┘ └────────────────────────────────┘ │ │ │ │ Pos(0) @@ -24,7 +23,6 @@ │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ - │ │ loop: │ │ └────────────────────────────────┘ │ │ │ │ stuff() @@ -33,9 +31,8 @@ │ │ 19-if-0.c:17:5-17:13 │ │ │ (19-if-0.c:17:12-17:13) │ │ │ YAML loc: true, loop: false │ - │ │ YAMLval loc: true, loop: false │ - │ __goblint_check(1) │ GraphML: true; server: true │ - └────────────────────────────────────────────────────▶ │ loop: │ + │ __goblint_check(1) │ YAMLval loc: true, loop: false │ + └────────────────────────────────────────────────────▶ │ GraphML: true; server: true │ └────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index 0ddc4ce5476..e1670c1f98d 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -11,11 +11,10 @@ │ 20-if-0-realnode.c:8:5-14:5 │ │ (20-if-0-realnode.c:8:9-8:10) │ │ [20-if-0-realnode.c:7:5-8:5 │ - │ (unknown)] │ - │ YAML loc: true, loop: true │ Neg(0) - │ YAMLval loc: true, loop: true │ ─────────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀────────┘ + │ (unknown)] │ Neg(0) + │ YAML loc: true, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────┘ │ │ Pos(0) @@ -26,7 +25,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────┘ │ │ stuff() @@ -37,7 +35,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 1e046d1c13c..723dbe81046 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -11,11 +11,10 @@ │ 21-empty-loops.c:57:3-57:31 │ │ (unknown) │ │ [21-empty-loops.c:56:1-57:3 │ - │ (unknown)] │ - │ YAML loc: true, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────┘ │ │ Neg(1) @@ -26,7 +25,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────┘ │ │ return @@ -59,7 +57,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -75,7 +72,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────┘ │ │ suffix() @@ -85,8 +81,7 @@ │ (unknown) │ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - │ loop: │ ◀┐ + │ GraphML: true; server: true │ ◀┐ └──────────────────────────────────────┘ │ │ │ │ return │ @@ -104,11 +99,10 @@ │ 21-empty-loops.c:73:3-73:38 │ │ │ (unknown) │ │ │ [21-empty-loops.c:72:1-73:3 │ │ - │ (unknown)] │ │ - skip │ YAML loc: true, loop: true │ │ - ┌─────── │ YAMLval loc: true, loop: true │ │ - │ │ GraphML: true; server: true │ │ - └──────▶ │ loop: │ ─┘ + skip │ (unknown)] │ │ + ┌─────── │ YAML loc: true, loop: true │ │ + │ │ YAMLval loc: true, loop: true │ │ + └──────▶ │ GraphML: true; server: true │ ─┘ └──────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop_suffix.dot @@ -135,7 +129,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────────┘ │ │ suffix() @@ -146,7 +139,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -164,11 +156,10 @@ ▼ ┌──────────────────────────────────┐ │ 21-empty-loops.c:93:3-93:9 │ - │ (21-empty-loops.c:93:3-93:9) │ - │ YAML loc: true, loop: true │ body() - │ YAMLval loc: true, loop: true │ ─────────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀────────┘ + │ (21-empty-loops.c:93:3-93:9) │ body() + │ YAML loc: true, loop: true │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────┘ │ │ Neg(1) @@ -179,7 +170,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────┘ │ │ return @@ -204,7 +194,7 @@ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ Pos(1) │ GraphML: true; server: false │ │ - │ loop: │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ + │ │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────────────┘ │ │ Neg(1) @@ -215,7 +205,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────────┘ │ │ return @@ -238,7 +227,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────┘ │ │ prefix() @@ -247,11 +235,10 @@ │ 21-empty-loops.c:115:3-115:38 │ │ (unknown) │ │ [21-empty-loops.c:114:1-115:3 │ - │ (unknown)] │ - │ YAML loc: true, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └──────────────────────────────────────┘ │ │ Neg(1) @@ -262,7 +249,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────┘ │ │ return @@ -284,7 +270,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────────────┘ │ │ prefix() @@ -306,7 +291,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────────────┘ │ │ return @@ -326,11 +310,10 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:127:1-128:3 │ - │ (unknown)] │ - │ YAML loc: false, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: false, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ │ │ Neg(1) @@ -341,7 +324,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └─────────────────────────────────────────┘ │ │ return @@ -374,7 +356,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └──────────────────────────────────────────────┘ │ │ return @@ -394,11 +375,10 @@ │ 21-empty-loops.c:143:3-143:42 │ │ (unknown) │ │ [21-empty-loops.c:142:1-143:3 │ - │ (unknown)] │ - │ YAML loc: true, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────┘ │ │ Neg(1) @@ -409,7 +389,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────┘ │ │ return @@ -429,11 +408,10 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:150:1-151:3 │ - │ (unknown)] │ - │ YAML loc: false, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: false, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -444,7 +422,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────────────────────────┘ │ │ return @@ -464,11 +441,10 @@ │ 21-empty-loops.c:160:3-160:59 │ │ (unknown) │ │ [21-empty-loops.c:159:1-160:3 │ - │ (unknown)] │ - │ YAML loc: true, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: true, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -479,7 +455,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └─────────────────────────────────────────────────────────┘ │ │ return @@ -499,11 +474,10 @@ │ unknown │ │ (unknown) │ │ [21-empty-loops.c:168:1-169:3 │ - │ (unknown)] │ - │ YAML loc: false, loop: true │ skip - │ YAMLval loc: true, loop: true │ ───────┐ - │ GraphML: true; server: true │ │ - │ loop: │ ◀──────┘ + │ (unknown)] │ skip + │ YAML loc: false, loop: true │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ │ │ Neg(1) @@ -514,7 +488,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └───────────────────────────────────────────────────────┘ │ │ return diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index 8c848b1fd7b..a3ed58fd424 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -13,7 +13,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ - │ loop: │ └────────────────────────────────┘ │ │ a = 1 @@ -24,7 +23,6 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ - │ loop: │ └────────────────────────────────┘ │ │ b = 1 @@ -35,7 +33,7 @@ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ GraphML: true; server: true │ Neg(a > 0) │ GraphML: true; server: false │ - ┌──────▶ │ loop: │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ + ┌──────▶ │ │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ │ └────────────────────────────────┘ └────────────────────────────────┘ │ │ │ │ │ │ │ return 0 │ Pos(a > 0) │ @@ -45,8 +43,7 @@ │ Neg(b) │ │ │ (foo.c:3:10-3:20 (synthetic)) │ │ │ │ return of main() │ │ YAML loc: false, loop: false │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ │ │ GraphML: true; server: false │ │ - │ │ │ ┌─────────── │ loop: │ │ + │ │ │ ┌─────────── │ GraphML: true; server: false │ │ │ └────────────────────────────────┘ │ └────────────────────────────────┘ │ │ │ │ │ └────────────────────────────────────────────┘ │ Pos(b) │ b = b - 1 @@ -57,7 +54,6 @@ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ │ - │ loop: │ │ └────────────────────────────────┘ │ │ │ │ a = a + 1 │ @@ -67,6 +63,5 @@ │ (foo.c:5:5-5:8) │ │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: true │ │ - │ loop: │ ─┘ + │ GraphML: true; server: true │ ─┘ └────────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index a56c54c0460..0acc007162c 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -14,9 +14,8 @@ │ issue-1356.c:9:3-9:53 (synthetic) │ │ issue-1356.c:9:3-9:53 │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ (issue-1356.c:9:3-9:53) │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: false │ Pos(b <= 0) │ GraphML: true; server: true │ │ - │ loop: │ ◀────────────────────────── │ loop: │ │ + │ YAMLval loc: true, loop: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: true │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Neg(b <= 0) │ @@ -26,8 +25,7 @@ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ GraphML: true; server: false │ │ - │ │ loop: │ ─┘ + │ │ GraphML: true; server: false │ ─┘ │ └─────────────────────────────────────────┘ │ │ │ │ Neg((long )a >= (long )b - 2147483648) @@ -38,7 +36,6 @@ │ │ YAML loc: false, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ - │ │ loop: │ │ └─────────────────────────────────────────┘ │ │ │ │ tmp = 0 @@ -47,9 +44,8 @@ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ │ YAML loc: false, loop: false │ - │ │ YAMLval loc: true, loop: false │ - │ tmp = 1 │ GraphML: true; server: false │ - └───────────────────────────────────────────────────────────────────▶ │ loop: │ + │ tmp = 1 │ YAMLval loc: true, loop: false │ + └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp) @@ -59,8 +55,7 @@ │ (issue-1356.c:10:3-10:53) │ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - │ loop: │ ─┐ + │ GraphML: true; server: true │ ─┐ └─────────────────────────────────────────┘ │ │ │ │ Neg(b >= 0) │ @@ -68,10 +63,9 @@ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ Pos(b >= 0) - │ GraphML: true; server: false │ Neg(a <= b + 2147483647) │ GraphML: true; server: false │ │ - │ loop: │ ◀────────────────────────── │ loop: │ │ + │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ Pos(b >= 0) + │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Pos(a <= b + 2147483647) │ @@ -81,8 +75,7 @@ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ GraphML: true; server: false │ │ - │ │ loop: │ ◀┘ + │ │ GraphML: true; server: false │ ◀┘ │ └─────────────────────────────────────────┘ │ │ │ │ tmp___0 = 1 @@ -91,9 +84,8 @@ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ │ YAML loc: false, loop: false │ - │ │ YAMLval loc: true, loop: false │ - │ tmp___0 = 0 │ GraphML: true; server: false │ - └───────────────────────────────────────────────────────────────────▶ │ loop: │ + │ tmp___0 = 0 │ YAMLval loc: true, loop: false │ + └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ │ assume_abort_if_not(tmp___0) @@ -104,7 +96,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └─────────────────────────────────────────┘ │ │ return a - b diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index b0cbed15ee4..40280507880 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -16,8 +16,8 @@ │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ ┌────────────────────────────────────┘ │ main() │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ - │ │ │ │ │ │ │ │ │ - │ │ │ │ │ (body) │ │ │ │ i = i + 1 + │ │ │ │ │ │ │ │ │ i = i + 1 + │ │ │ │ │ (body) │ │ │ │ │ │ │ │ ▼ │ │ │ │ │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ │ │ loops.c:7:3-7:8 │ │ │ │ │ @@ -25,7 +25,6 @@ │ │ │ │ │ YAML loc: true, loop: false │ │ │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ - │ │ │ │ │ loop: │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ │ @@ -36,7 +35,7 @@ │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ - │ │ │ │ loop: │ ◀───────────── │ loop: loops.c:8:3-10:3 │ ◀┼───────────────┼────┼────┘ + │ │ │ │ │ ◀───────────── │ loop: loops.c:8:3-10:3 │ ◀┼───────────────┼────┼────┘ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Neg(i < 10) │ │ │ @@ -44,10 +43,9 @@ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ loops.c:13:3-15:3 │ │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ i = i + 1 │ │ + │ │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ - │ │ │ │ loop: │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ @@ -58,7 +56,7 @@ │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ - │ │ │ │ loop: │ ◀───────────── │ loop: loops.c:13:3-15:3 │ ◀┘ │ │ + │ │ │ │ │ ◀───────────── │ loop: loops.c:13:3-15:3 │ ◀┘ │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ @@ -68,8 +66,7 @@ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ │ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ - │ │ └─ │ loop: │ │ loop: │ │ │ + │ │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ @@ -80,7 +77,7 @@ │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ GraphML: true; server: false │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ - │ └────── │ loop: │ ◀───────────── │ loop: loops.c:18:3-20:3 │ ◀────────────────┘ │ + │ └────── │ │ ◀───────────── │ loop: loops.c:18:3-20:3 │ ◀────────────────┘ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ Neg(i < 10) │ @@ -91,7 +88,6 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ - │ │ loop: │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ i = 0 │ @@ -102,7 +98,7 @@ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ - └─────────── │ loop: │ ◀───────────── │ loop: loops.c:23:3-25:3 │ ◀─────────────────────┘ + └─────────── │ │ ◀───────────── │ loop: loops.c:23:3-25:3 │ ◀─────────────────────┘ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ Neg(i < 10) @@ -113,7 +109,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └───────────────────────────────────┘ │ │ i = 0 @@ -124,7 +119,7 @@ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 - │ loop: │ ◀───────────── │ loop: loops.c:29:3-31:3 │ ◀─────────────────────┐ + │ │ ◀───────────── │ loop: loops.c:29:3-31:3 │ ◀─────────────────────┐ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ @@ -135,7 +130,6 @@ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ - │ loop: │ │ loop: │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ i = 0 │ @@ -146,7 +140,6 @@ │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ - │ │ loop: │ │ │ └───────────────────────────────────┘ │ │ │ │ ┌────┘ │ j = i │ @@ -157,7 +150,7 @@ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ - │ │ loop: │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ + │ │ │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ @@ -167,8 +160,7 @@ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ GraphML: true; server: false │ │ GraphML: true; server: true │ │ │ - │ │ loop: │ ─┐ │ loop: │ │ │ + │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ @@ -189,8 +181,7 @@ │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ │ │ │ YAML loc: false, loop: false │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ - │ │ │ GraphML: true; server: false │ │ │ │ - │ │ │ loop: │ ─┘ │ │ + │ │ │ GraphML: true; server: false │ ─┘ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ Neg(i < 10) │ │ @@ -201,7 +192,6 @@ │ │ │ YAML loc: true, loop: false │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ GraphML: true; server: true │ │ │ - │ │ │ loop: │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ return 0 │ │ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index 71ecdc254bf..2fd7398900f 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -16,7 +16,6 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ - │ │ loop: │ │ │ └────────────────────────────────────┘ │ │ │ │ x = x + 1 │ │ x = 42 │ @@ -27,7 +26,6 @@ │ │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ - │ │ loop: │ │ │ └────────────────────────────────────┘ │ │ │ │ │ │ x = 0 │ @@ -38,7 +36,7 @@ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: false │ Pos(x < 10) │ GraphML: true; server: false │ │ - │ loop: │ ◀───────────── │ loop: pr-758.c:6:3-8:3 │ ◀┘ + │ │ ◀───────────── │ loop: pr-758.c:6:3-8:3 │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────┘ │ │ Neg(x < 10) @@ -49,7 +47,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────┘ │ │ k = 0 @@ -60,7 +57,6 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ - │ loop: │ └────────────────────────────────────┘ │ │ i = k @@ -71,7 +67,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ - │ loop: │ └────────────────────────────────────┘ │ │ a.kaal = 2 @@ -82,7 +77,6 @@ │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ - │ loop: │ └────────────────────────────────────┘ │ │ a.hind = 3 @@ -93,7 +87,6 @@ │ YAML loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ - │ loop: │ └────────────────────────────────────┘ │ │ return 0 diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index 88a896f4001..23f813ffafa 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -78,17 +78,20 @@ let main () = let locs = CilLocation.get_labelLoc label in Format.fprintf ppf "@;[%a]" pp_locs locs + let pp_loop_loc ppf loop = + Format.fprintf ppf "@;loop: %a" CilType.Location.pp loop + let extraNodeStyles = function | Node.Statement stmt as n -> let locs: CilLocation.locs = CilLocation.get_stmtLoc stmt in let label = - Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B@;loop: %a@]" + Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B%a@]" pp_locs locs (Format.pp_print_list ~pp_sep:GobFormat.pp_print_nothing pp_label_locs) stmt.labels (YamlWitnessInvariant.is_invariant_node n) (YamlWitnessInvariant.is_loop_head_node n) (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) - (Format.pp_print_option CilType.Location.pp) (is_loop_head n) + (Format.pp_print_option pp_loop_loc) (is_loop_head n) in [Printf.sprintf "label=\"%s\"" (Str.global_replace (Str.regexp "\n") "\\n" label)] | _ -> [] From db297e2b7004de489c92d1e8e0bb9422628593df Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 27 Feb 2024 17:01:52 +0200 Subject: [PATCH 18/40] Move skippedByEdge into CFG module --- src/common/framework/cfgTools.ml | 12 ++---------- src/common/framework/myCFG.ml | 21 ++++++++++++++++++--- src/framework/control.ml | 16 ++++++++-------- src/util/server.ml | 2 +- src/witness/svcomp.ml | 4 +--- tests/regression/cfg/util/cfgDot.ml | 4 ++-- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/common/framework/cfgTools.ml b/src/common/framework/cfgTools.ml index 23dfe3ad6c7..f2fe93c0304 100644 --- a/src/common/framework/cfgTools.ml +++ b/src/common/framework/cfgTools.ml @@ -132,13 +132,7 @@ let () = Printexc.register_printer (function | _ -> None (* for other exceptions *) ) -(** Type of CFG "edges": keyed by 'from' and 'to' nodes, - along with the list of connecting instructions. *) -module CfgEdge = struct - type t = Node.t * MyCFG.edges * Node.t [@@deriving eq, hash] -end -module CfgEdgeH = BatHashtbl.Make (CfgEdge) let createCFG (file: file) = let cfgF = H.create 113 in @@ -619,11 +613,9 @@ let getCFG (file: file) : cfg * cfg * stmt list CfgEdgeH.t = if get_bool "justcfg" then fprint_hash_dot cfgB; (fun n -> H.find_default cfgF n []), (fun n -> H.find_default cfgB n []), skippedByEdge -let compute_cfg_skips file = +let compute_cfg file = let cfgF, cfgB, skippedByEdge = getCFG file in - (module struct let prev = cfgB let next = cfgF end : CfgBidir), skippedByEdge - -let compute_cfg file = fst (compute_cfg_skips file) + (module struct let prev = cfgB let next = cfgF let skippedByEdge = skippedByEdge end : CfgBidirSkip) let iter_fd_edges (module Cfg : CfgBackward) fd = diff --git a/src/common/framework/myCFG.ml b/src/common/framework/myCFG.ml index 76675f3c88c..b7e00378923 100644 --- a/src/common/framework/myCFG.ml +++ b/src/common/framework/myCFG.ml @@ -42,19 +42,34 @@ sig include CfgForward end +(** Type of CFG "edges": keyed by 'from' and 'to' nodes, + along with the list of connecting instructions. *) +module CfgEdge = struct + type t = Node.t * edges * Node.t [@@deriving eq, hash] +end + +module CfgEdgeH = BatHashtbl.Make (CfgEdge) + +module type CfgBidirSkip = +sig + include CfgBidir + val skippedByEdge: stmt list CfgEdgeH.t +end + module NodeH = BatHashtbl.Make (Node) let current_node = Node.current_node -let current_cfg : (module CfgBidir) ref = +let current_cfg : (module CfgBidirSkip) ref = let module Cfg = struct let next _ = raise Not_found let prev _ = raise Not_found + let skippedByEdge = CfgEdgeH.create 0 (* TODO: make functional instead? *) end in - ref (module Cfg: CfgBidir) + ref (module Cfg: CfgBidirSkip) let unknown_exp : exp = mkString "__unknown_value__" let dummy_func = emptyFunction "__goblint_dummy_init" (* TODO get rid of this? *) @@ -64,5 +79,5 @@ let dummy_node = FunctionEntry Cil.dummyFunDec module type FileCfg = sig val file: Cil.file - module Cfg: CfgBidir + module Cfg: CfgBidirSkip end diff --git a/src/framework/control.ml b/src/framework/control.ml index 6e8e5b7fc49..09c4083bcbf 100644 --- a/src/framework/control.ml +++ b/src/framework/control.ml @@ -54,7 +54,7 @@ let current_node_state_json : (Node.t -> Yojson.Safe.t option) ref = ref (fun _ let current_varquery_global_state_json: (VarQuery.t option -> Yojson.Safe.t) ref = ref (fun _ -> `Null) (** Given a [Cfg], a [Spec], and an [Inc], computes the solution to [MCP.Path] *) -module AnalyzeCFG (Cfg:CfgBidir) (Spec:Spec) (Inc:Increment) = +module AnalyzeCFG (Cfg:CfgBidirSkip) (Spec:Spec) (Inc:Increment) = struct module SpecSys: SpecSys with module Spec = Spec = @@ -230,7 +230,7 @@ struct res (** The main function to preform the selected analyses. *) - let analyze (file: file) (startfuns, exitfuns, otherfuns: Analyses.fundecs) skippedByEdge = + let analyze (file: file) (startfuns, exitfuns, otherfuns: Analyses.fundecs) = let module FileCfg: FileCfg = struct let file = file @@ -656,7 +656,7 @@ struct let must_be_uncalled fd = not @@ BatSet.Int.mem fd.svar.vid calledFuns in let skipped_statements from_node edge to_node = - CfgTools.CfgEdgeH.find_default skippedByEdge (from_node, edge, to_node) [] + MyCFG.CfgEdgeH.find_default Cfg.skippedByEdge (from_node, edge, to_node) [] in Transform.run_transformations file active_transformations @@ -793,22 +793,22 @@ end [analyze_loop] cannot reside in it anymore since each invocation of [get_spec] in the loop might/should return a different module, and we cannot swap the functor parameter from inside [AnalyzeCFG]. *) -let rec analyze_loop (module CFG : CfgBidir) file fs change_info skippedByEdge = +let rec analyze_loop (module CFG : CfgBidirSkip) file fs change_info = try let (module Spec) = get_spec () in let module A = AnalyzeCFG (CFG) (Spec) (struct let increment = change_info end) in - GobConfig.with_immutable_conf (fun () -> A.analyze file fs skippedByEdge) + GobConfig.with_immutable_conf (fun () -> A.analyze file fs) with Refinement.RestartAnalysis -> (* Tail-recursively restart the analysis again, when requested. All solving starts from scratch. Whoever raised the exception should've modified some global state to do a more precise analysis next time. *) (* TODO: do some more incremental refinement and reuse parts of solution *) - analyze_loop (module CFG) file fs change_info skippedByEdge + analyze_loop (module CFG) file fs change_info (** The main function to perform the selected analyses. *) let analyze change_info (file: file) fs = Logs.debug "Generating the control flow graph."; - let (module CFG), skippedByEdge = CfgTools.compute_cfg_skips file in + let (module CFG) = CfgTools.compute_cfg file in MyCFG.current_cfg := (module CFG); - analyze_loop (module CFG) file fs change_info skippedByEdge + analyze_loop (module CFG) file fs change_info diff --git a/src/util/server.ml b/src/util/server.ml index 1781d88b760..c1b8f33cb8a 100644 --- a/src/util/server.ml +++ b/src/util/server.ml @@ -489,7 +489,7 @@ let () = let process { fname } serv = let fundec = Cilfacade.find_name_fundec fname in let live _ = true in (* TODO: fix this *) - let cfg = CfgTools.sprint_fundec_html_dot !MyCFG.current_cfg live fundec in + let cfg = CfgTools.sprint_fundec_html_dot (module (val !MyCFG.current_cfg: MyCFG.CfgBidirSkip): MyCFG.CfgBidir) live fundec in { cfg } end); diff --git a/src/witness/svcomp.ml b/src/witness/svcomp.ml index 6d22a511664..bb887e6cb1a 100644 --- a/src/witness/svcomp.ml +++ b/src/witness/svcomp.ml @@ -7,10 +7,8 @@ module Specification = SvcompSpec module type Task = sig - val file: Cil.file + include MyCFG.FileCfg val specification: Specification.multi - - module Cfg: MyCFG.CfgBidir end let task: (module Task) option ref = ref None diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index 23f813ffafa..624fa64b725 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -35,7 +35,7 @@ let main () = GoblintCil.computeCFGInfo fd true | _ -> () ); - let ((module Cfg), skipped) = CfgTools.compute_cfg_skips ast in + let (module Cfg) = CfgTools.compute_cfg ast in let module FileCfg = struct let file = ast @@ -46,7 +46,7 @@ let main () = let is_loop_head n = let prevs = Cfg.prev n in List.find_map (fun (edges, prev) -> - let stmts = CfgTools.CfgEdgeH.find skipped (prev, edges, n) in + let stmts = MyCFG.CfgEdgeH.find Cfg.skippedByEdge (prev, edges, n) in List.find_map (fun s -> match s.GoblintCil.skind with | Loop (_, loc, _, _, _) -> Some loc From 7181c19093425b4f528aac00f0661e505f748cc4 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 27 Feb 2024 17:18:47 +0200 Subject: [PATCH 19/40] Move find_syntactic_loop_head to WitnessUtil --- src/witness/witnessUtil.ml | 11 +++++++++++ tests/regression/cfg/util/cfgDot.ml | 14 +------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index 919fc27ef34..0c527233340 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -79,6 +79,17 @@ struct emit_after_lock else emit_other + + let find_syntactic_loop_head n = + let prevs = Cfg.prev n in + List.find_map (fun (edges, prev) -> + let stmts = MyCFG.CfgEdgeH.find Cfg.skippedByEdge (prev, edges, n) in + List.find_map (fun s -> + match s.GoblintCil.skind with + | Loop (_, loc, _, _, _) -> Some loc + | _ -> None + ) stmts + ) prevs end module YamlInvariant (FileCfg: MyCFG.FileCfg) = diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index 624fa64b725..185c045efef 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -43,18 +43,6 @@ let main () = end in - let is_loop_head n = - let prevs = Cfg.prev n in - List.find_map (fun (edges, prev) -> - let stmts = MyCFG.CfgEdgeH.find Cfg.skippedByEdge (prev, edges, n) in - List.find_map (fun s -> - match s.GoblintCil.skind with - | Loop (_, loc, _, _, _) -> Some loc - | _ -> None - ) stmts - ) prevs - in - let module GraphmlWitnessInvariant = WitnessUtil.Invariant (FileCfg) in let module YamlWitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in let module YamlWitnessValidateInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in @@ -91,7 +79,7 @@ let main () = (YamlWitnessInvariant.is_invariant_node n) (YamlWitnessInvariant.is_loop_head_node n) (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) - (Format.pp_print_option pp_loop_loc) (is_loop_head n) + (Format.pp_print_option pp_loop_loc) (GraphmlWitnessInvariant.find_syntactic_loop_head n) in [Printf.sprintf "label=\"%s\"" (Str.global_replace (Str.regexp "\n") "\\n" label)] | _ -> [] From ac1d81362fe7d61b195e9bb04e045e35af8195d3 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 27 Feb 2024 17:40:44 +0200 Subject: [PATCH 20/40] Make CFG skippedByEdge functional --- src/common/framework/cfgTools.ml | 4 ++-- src/common/framework/myCFG.ml | 4 ++-- src/framework/control.ml | 5 ++++- src/witness/witnessUtil.ml | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/framework/cfgTools.ml b/src/common/framework/cfgTools.ml index f2fe93c0304..a2ee2c66343 100644 --- a/src/common/framework/cfgTools.ml +++ b/src/common/framework/cfgTools.ml @@ -602,7 +602,7 @@ let fprint_hash_dot cfg = close_out out -let getCFG (file: file) : cfg * cfg * stmt list CfgEdgeH.t = +let getCFG (file: file) : cfg * cfg * _ = let cfgF, cfgB, skippedByEdge = createCFG file in let cfgF, cfgB, skippedByEdge = if get_bool "exp.mincfg" then @@ -611,7 +611,7 @@ let getCFG (file: file) : cfg * cfg * stmt list CfgEdgeH.t = (cfgF, cfgB, skippedByEdge) in if get_bool "justcfg" then fprint_hash_dot cfgB; - (fun n -> H.find_default cfgF n []), (fun n -> H.find_default cfgB n []), skippedByEdge + (fun n -> H.find_default cfgF n []), (fun n -> H.find_default cfgB n []), (fun u e v -> CfgEdgeH.find skippedByEdge (u, e, v)) let compute_cfg file = let cfgF, cfgB, skippedByEdge = getCFG file in diff --git a/src/common/framework/myCFG.ml b/src/common/framework/myCFG.ml index b7e00378923..22b2b7d679c 100644 --- a/src/common/framework/myCFG.ml +++ b/src/common/framework/myCFG.ml @@ -53,7 +53,7 @@ module CfgEdgeH = BatHashtbl.Make (CfgEdge) module type CfgBidirSkip = sig include CfgBidir - val skippedByEdge: stmt list CfgEdgeH.t + val skippedByEdge: node -> edges -> node -> stmt list end @@ -66,7 +66,7 @@ let current_cfg : (module CfgBidirSkip) ref = struct let next _ = raise Not_found let prev _ = raise Not_found - let skippedByEdge = CfgEdgeH.create 0 (* TODO: make functional instead? *) + let skippedByEdge _ _ _ = raise Not_found end in ref (module Cfg: CfgBidirSkip) diff --git a/src/framework/control.ml b/src/framework/control.ml index 09c4083bcbf..65350346285 100644 --- a/src/framework/control.ml +++ b/src/framework/control.ml @@ -656,7 +656,10 @@ struct let must_be_uncalled fd = not @@ BatSet.Int.mem fd.svar.vid calledFuns in let skipped_statements from_node edge to_node = - MyCFG.CfgEdgeH.find_default Cfg.skippedByEdge (from_node, edge, to_node) [] + try + Cfg.skippedByEdge from_node edge to_node + with Not_found -> + [] in Transform.run_transformations file active_transformations diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index 0c527233340..f460871150e 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -83,7 +83,7 @@ struct let find_syntactic_loop_head n = let prevs = Cfg.prev n in List.find_map (fun (edges, prev) -> - let stmts = MyCFG.CfgEdgeH.find Cfg.skippedByEdge (prev, edges, n) in + let stmts = Cfg.skippedByEdge prev edges n in List.find_map (fun s -> match s.GoblintCil.skind with | Loop (_, loc, _, _, _) -> Some loc From f91b76cd8b1ebeb5af3baef45664a7c680f63cc3 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 27 Feb 2024 17:43:47 +0200 Subject: [PATCH 21/40] Fix GobView with CfgBidirSkip --- gobview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gobview b/gobview index 581a3e2e06f..79d0d7dd9ce 160000 --- a/gobview +++ b/gobview @@ -1 +1 @@ -Subproject commit 581a3e2e06f7f076b05688e2e7085db36de3e260 +Subproject commit 79d0d7dd9cec90742e8c1379d791eb1416ed2df9 From 3fc582eb63f99f92495b61df90231b8ea93a168d Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 11:26:09 +0200 Subject: [PATCH 22/40] Base YAML witness loop invariants on syntactic loops Excludes goto-based loops. --- src/witness/witnessUtil.ml | 7 +++++-- tests/regression/00-sanity/20-if-0-realnode.t | 2 +- tests/regression/00-sanity/21-empty-loops.t | 18 +++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index f460871150e..cdd72eb15a3 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -109,8 +109,11 @@ struct (* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *) false - let is_loop_head_node n = - NH.mem loop_heads n && not (is_stub_node n) + let loop_location n = + find_syntactic_loop_head n + |> BatOption.filter (fun _loc -> not (is_stub_node n)) + + let is_loop_head_node n = Option.is_some (loop_location n) end module YamlInvariantValidate (FileCfg: MyCFG.FileCfg) = diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index e1670c1f98d..1ffc73343ba 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -12,7 +12,7 @@ │ (20-if-0-realnode.c:8:9-8:10) │ │ [20-if-0-realnode.c:7:5-8:5 │ │ (unknown)] │ Neg(0) - │ YAML loc: true, loop: true │ ─────────┐ + │ YAML loc: true, loop: false │ ─────────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────┘ diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 723dbe81046..b64e9f9e2e3 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -12,7 +12,7 @@ │ (unknown) │ │ [21-empty-loops.c:56:1-57:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: true, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────┘ @@ -100,7 +100,7 @@ │ (unknown) │ │ │ [21-empty-loops.c:72:1-73:3 │ │ skip │ (unknown)] │ │ - ┌─────── │ YAML loc: true, loop: true │ │ + ┌─────── │ YAML loc: true, loop: false │ │ │ │ YAMLval loc: true, loop: true │ │ └──────▶ │ GraphML: true; server: true │ ─┘ └──────────────────────────────────────┘ @@ -157,7 +157,7 @@ ┌──────────────────────────────────┐ │ 21-empty-loops.c:93:3-93:9 │ │ (21-empty-loops.c:93:3-93:9) │ body() - │ YAML loc: true, loop: true │ ─────────┐ + │ YAML loc: true, loop: false │ ─────────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────┘ @@ -236,7 +236,7 @@ │ (unknown) │ │ [21-empty-loops.c:114:1-115:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: true, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └──────────────────────────────────────┘ @@ -311,7 +311,7 @@ │ (unknown) │ │ [21-empty-loops.c:127:1-128:3 │ │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ + │ YAML loc: false, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ @@ -376,7 +376,7 @@ │ (unknown) │ │ [21-empty-loops.c:142:1-143:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: true, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────┘ @@ -409,7 +409,7 @@ │ (unknown) │ │ [21-empty-loops.c:150:1-151:3 │ │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ + │ YAML loc: false, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ @@ -442,7 +442,7 @@ │ (unknown) │ │ [21-empty-loops.c:159:1-160:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: true │ ───────┐ + │ YAML loc: true, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────────────────────┘ @@ -475,7 +475,7 @@ │ (unknown) │ │ [21-empty-loops.c:168:1-169:3 │ │ (unknown)] │ skip - │ YAML loc: false, loop: true │ ───────┐ + │ YAML loc: false, loop: false │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ From e12956e386c45ccb84c58a4f7402861ecd7e95a2 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 11:31:47 +0200 Subject: [PATCH 23/40] Extract location_location for YAML witness location invariants --- src/witness/witnessUtil.ml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index cdd72eb15a3..152f8911e2a 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -100,14 +100,19 @@ struct let fundec = Node.find_fundec n in Cil.hasAttribute "goblint_stub" fundec.svar.vattr - let is_invariant_node (n : Node.t) = + let location_location (n : Node.t) = (* great naming... *) match n with | Statement s -> - let locs = CilLocation.get_stmtLoc s in - not locs.loc.synthetic && is_invariant_node n && not (is_stub_node n) + let {loc; _}: CilLocation.locs = CilLocation.get_stmtLoc s in + if not loc.synthetic && is_invariant_node n && not (is_stub_node n) then (* TODO: remove is_invariant_node? *) + Some loc + else + None | FunctionEntry _ | Function _ -> (* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *) - false + None + + let is_invariant_node n = Option.is_some (location_location n) let loop_location n = find_syntactic_loop_head n From 9dd83ad03ee4aebcff0ceaec211e47c0423ba0f1 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 11:48:06 +0200 Subject: [PATCH 24/40] Simplify YAML invariant locations in cfgDot --- tests/regression/00-sanity/19-if-0.t | 6 +- tests/regression/00-sanity/20-if-0-realnode.t | 58 +-- tests/regression/00-sanity/21-empty-loops.t | 365 +++++++++--------- tests/regression/cfg/foo.t/run.t | 18 +- tests/regression/cfg/issue-1356.t/run.t | 18 +- tests/regression/cfg/loops.t/loops.c | 2 +- tests/regression/cfg/loops.t/run.t | 49 ++- tests/regression/cfg/pr-758.t/run.t | 18 +- tests/regression/cfg/util/cfgDot.ml | 11 +- 9 files changed, 269 insertions(+), 276 deletions(-) diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index 37ba193aefe..2294ed34a9f 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -10,7 +10,7 @@ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ 19-if-0.c:15:9-15:27 │ │ 19-if-0.c:9:5-16:5 │ │ (19-if-0.c:15:9-15:27) │ │ (19-if-0.c:9:9-9:10) │ - │ YAML loc: true, loop: false │ │ YAML loc: true, loop: false │ + │ YAML loc: 19-if-0.c:15:9-15:27 │ │ YAML loc: 19-if-0.c:9:5-16:5 │ │ YAMLval loc: true, loop: false │ Neg(0) │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ ◀──────────────────── │ GraphML: true; server: true │ └────────────────────────────────┘ └────────────────────────────────┘ @@ -20,7 +20,7 @@ │ ┌────────────────────────────────┐ │ │ 19-if-0.c:11:9-11:16 │ │ │ (19-if-0.c:11:9-11:16) │ - │ │ YAML loc: true, loop: false │ + │ │ YAML loc: 19-if-0.c:11:9-11:16 │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ │ └────────────────────────────────┘ @@ -30,7 +30,7 @@ │ ┌────────────────────────────────┐ │ │ 19-if-0.c:17:5-17:13 │ │ │ (19-if-0.c:17:12-17:13) │ - │ │ YAML loc: true, loop: false │ + │ │ YAML loc: 19-if-0.c:17:5-17:13 │ │ __goblint_check(1) │ YAMLval loc: true, loop: false │ └────────────────────────────────────────────────────▶ │ GraphML: true; server: true │ └────────────────────────────────┘ diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index 1ffc73343ba..3d22d094ab0 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -1,44 +1,44 @@ $ cfgDot 20-if-0-realnode.c $ graph-easy --as=boxart main.dot - ┌──────────────────────────────────┐ - │ main() │ - └──────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ main() │ + └─────────────────────────────────────────┘ │ │ (body) ▼ - ┌──────────────────────────────────┐ - │ 20-if-0-realnode.c:8:5-14:5 │ - │ (20-if-0-realnode.c:8:9-8:10) │ - │ [20-if-0-realnode.c:7:5-8:5 │ - │ (unknown)] │ Neg(0) - │ YAML loc: true, loop: false │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀────────┘ - └──────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 20-if-0-realnode.c:8:5-14:5 │ + │ (20-if-0-realnode.c:8:9-8:10) │ + │ [20-if-0-realnode.c:7:5-8:5 │ + │ (unknown)] │ Neg(0) + │ YAML loc: 20-if-0-realnode.c:8:5-14:5 │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ + └─────────────────────────────────────────┘ │ │ Pos(0) ▼ - ┌──────────────────────────────────┐ - │ 20-if-0-realnode.c:10:9-10:16 │ - │ (20-if-0-realnode.c:10:9-10:16) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 20-if-0-realnode.c:10:9-10:16 │ + │ (20-if-0-realnode.c:10:9-10:16) │ + │ YAML loc: 20-if-0-realnode.c:10:9-10:16 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └─────────────────────────────────────────┘ │ │ stuff() ▼ - ┌──────────────────────────────────┐ - │ 20-if-0-realnode.c:15:5-15:13 │ - │ (20-if-0-realnode.c:15:12-15:13) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 20-if-0-realnode.c:15:5-15:13 │ + │ (20-if-0-realnode.c:15:12-15:13) │ + │ YAML loc: 20-if-0-realnode.c:15:5-15:13 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └─────────────────────────────────────────┘ │ │ return 0 ▼ - ┌──────────────────────────────────┐ - │ return of main() │ - └──────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ return of main() │ + └─────────────────────────────────────────┘ diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index b64e9f9e2e3..2daf9615923 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -1,37 +1,37 @@ $ cfgDot 21-empty-loops.c $ graph-easy --as=boxart f_empty_goto_loop.dot - ┌────────────────────────────────┐ - │ f_empty_goto_loop() │ - └────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ f_empty_goto_loop() │ + └───────────────────────────────────────┘ │ │ (body) ▼ - ┌────────────────────────────────┐ - │ 21-empty-loops.c:57:3-57:31 │ - │ (unknown) │ - │ [21-empty-loops.c:56:1-57:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: false │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ - └────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ 21-empty-loops.c:57:3-57:31 │ + │ (unknown) │ + │ [21-empty-loops.c:56:1-57:3 │ + │ (unknown)] │ skip + │ YAML loc: 21-empty-loops.c:57:3-57:31 │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ + └───────────────────────────────────────┘ │ │ Neg(1) ▼ - ┌────────────────────────────────┐ - │ 21-empty-loops.c:58:1-58:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ 21-empty-loops.c:58:1-58:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:58:1-58:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └───────────────────────────────────────┘ │ │ return ▼ - ┌────────────────────────────────┐ - │ return of f_empty_goto_loop() │ - └────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ return of f_empty_goto_loop() │ + └───────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop.dot ┌────────────────────────────────────────────┐ @@ -43,7 +43,7 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:62:3-62:14 (synthetic) │ │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ - │ YAML loc: false, loop: true │ Pos(1) + │ YAML loop: 21-empty-loops.c:62:3-62:14 │ Pos(1) │ YAMLval loc: true, loop: true │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:62:3-62:14 │ ◀────────┘ @@ -54,7 +54,7 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:63:1-63:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:63:1-63:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ @@ -66,44 +66,44 @@ └────────────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_goto_loop_suffix.dot - ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:75:3-75:11 │ - │ (21-empty-loops.c:75:3-75:11) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ 21-empty-loops.c:75:3-75:11 │ + │ (21-empty-loops.c:75:3-75:11) │ + │ YAML loc: 21-empty-loops.c:75:3-75:11 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └───────────────────────────────────────┘ │ │ suffix() ▼ - ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:76:1-76:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ ◀┐ - └──────────────────────────────────────┘ │ - │ │ - │ return │ - ▼ │ - ┌──────────────────────────────────────┐ │ - │ return of f_empty_goto_loop_suffix() │ │ - └──────────────────────────────────────┘ │ - ┌──────────────────────────────────────┐ │ Neg(1) - │ f_empty_goto_loop_suffix() │ │ - └──────────────────────────────────────┘ │ - │ │ - │ (body) │ - ▼ │ - ┌──────────────────────────────────────┐ │ - │ 21-empty-loops.c:73:3-73:38 │ │ - │ (unknown) │ │ - │ [21-empty-loops.c:72:1-73:3 │ │ - skip │ (unknown)] │ │ - ┌─────── │ YAML loc: true, loop: false │ │ - │ │ YAMLval loc: true, loop: true │ │ - └──────▶ │ GraphML: true; server: true │ ─┘ - └──────────────────────────────────────┘ + ┌───────────────────────────────────────┐ + │ 21-empty-loops.c:76:1-76:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:76:1-76:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ ◀┐ + └───────────────────────────────────────┘ │ + │ │ + │ return │ + ▼ │ + ┌───────────────────────────────────────┐ │ + │ return of f_empty_goto_loop_suffix() │ │ + └───────────────────────────────────────┘ │ + ┌───────────────────────────────────────┐ │ Neg(1) + │ f_empty_goto_loop_suffix() │ │ + └───────────────────────────────────────┘ │ + │ │ + │ (body) │ + ▼ │ + ┌───────────────────────────────────────┐ │ + │ 21-empty-loops.c:73:3-73:38 │ │ + │ (unknown) │ │ + │ [21-empty-loops.c:72:1-73:3 │ │ + skip │ (unknown)] │ │ + ┌─────── │ YAML loc: 21-empty-loops.c:73:3-73:38 │ │ + │ │ YAMLval loc: true, loop: true │ │ + └──────▶ │ GraphML: true; server: true │ ─┘ + └───────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop_suffix.dot ┌────────────────────────────────────────────┐ @@ -115,7 +115,7 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:80:3-80:14 (synthetic) │ │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ - │ YAML loc: false, loop: true │ Pos(1) + │ YAML loop: 21-empty-loops.c:80:3-80:14 │ Pos(1) │ YAMLval loc: true, loop: true │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:80:3-80:14 │ ◀────────┘ @@ -126,7 +126,7 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:82:3-82:11 │ │ (21-empty-loops.c:82:3-82:11) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:82:3-82:11 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ @@ -136,7 +136,7 @@ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:83:1-83:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:83:1-83:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ @@ -148,114 +148,114 @@ └────────────────────────────────────────────┘ $ graph-easy --as=boxart f_nonempty_goto_loop.dot - ┌──────────────────────────────────┐ - │ f_nonempty_goto_loop() │ - └──────────────────────────────────┘ + ┌──────────────────────────────────────┐ + │ f_nonempty_goto_loop() │ + └──────────────────────────────────────┘ │ │ (body) ▼ - ┌──────────────────────────────────┐ - │ 21-empty-loops.c:93:3-93:9 │ - │ (21-empty-loops.c:93:3-93:9) │ body() - │ YAML loc: true, loop: false │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀────────┘ - └──────────────────────────────────┘ + ┌──────────────────────────────────────┐ + │ 21-empty-loops.c:93:3-93:9 │ + │ (21-empty-loops.c:93:3-93:9) │ body() + │ YAML loc: 21-empty-loops.c:93:3-93:9 │ ─────────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀────────┘ + └──────────────────────────────────────┘ │ │ Neg(1) ▼ - ┌──────────────────────────────────┐ - │ 21-empty-loops.c:95:1-95:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────┘ + ┌──────────────────────────────────────┐ + │ 21-empty-loops.c:95:1-95:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:95:1-95:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └──────────────────────────────────────┘ │ │ return ▼ - ┌──────────────────────────────────┐ - │ return of f_nonempty_goto_loop() │ - └──────────────────────────────────┘ + ┌──────────────────────────────────────┐ + │ return of f_nonempty_goto_loop() │ + └──────────────────────────────────────┘ $ graph-easy --as=boxart f_nonempty_while_loop.dot - ┌───────────────────────────────────────────────────────────────────────────────────────────┐ - │ │ - │ ┌────────────────────────────────────────────┐ │ - │ │ f_nonempty_while_loop() │ │ - │ └────────────────────────────────────────────┘ │ - │ │ │ body() - │ │ (body) │ - │ ▼ │ - ┌─────────────────────────────────┐ ┌────────────────────────────────────────────┐ │ - │ 21-empty-loops.c:101:5-101:11 │ │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ - │ (21-empty-loops.c:101:5-101:11) │ │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ │ - │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ Pos(1) │ GraphML: true; server: false │ │ - │ │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ - └─────────────────────────────────┘ └────────────────────────────────────────────┘ - │ - │ Neg(1) - ▼ - ┌────────────────────────────────────────────┐ - │ 21-empty-loops.c:103:1-103:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └────────────────────────────────────────────┘ - │ - │ return - ▼ - ┌────────────────────────────────────────────┐ - │ return of f_nonempty_while_loop() │ - └────────────────────────────────────────────┘ + ┌───────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ │ + │ ┌────────────────────────────────────────────┐ │ + │ │ f_nonempty_while_loop() │ │ + │ └────────────────────────────────────────────┘ │ + │ │ │ body() + │ │ (body) │ + │ ▼ │ + ┌─────────────────────────────────────────┐ ┌────────────────────────────────────────────┐ │ + │ 21-empty-loops.c:101:5-101:11 │ │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ + │ (21-empty-loops.c:101:5-101:11) │ │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ │ + │ YAML loc: 21-empty-loops.c:101:5-101:11 │ │ YAML loop: 21-empty-loops.c:99:3-102:3 │ │ + │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ Pos(1) │ GraphML: true; server: false │ │ + │ │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ + └─────────────────────────────────────────┘ └────────────────────────────────────────────┘ + │ + │ Neg(1) + ▼ + ┌────────────────────────────────────────────┐ + │ 21-empty-loops.c:103:1-103:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:103:1-103:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └────────────────────────────────────────────┘ + │ + │ return + ▼ + ┌────────────────────────────────────────────┐ + │ return of f_nonempty_while_loop() │ + └────────────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_goto_loop_prefix.dot - ┌──────────────────────────────────────┐ - │ f_empty_goto_loop_prefix() │ - └──────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ f_empty_goto_loop_prefix() │ + └─────────────────────────────────────────┘ │ │ (body) ▼ - ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:112:3-112:11 │ - │ (21-empty-loops.c:112:3-112:11) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 21-empty-loops.c:112:3-112:11 │ + │ (21-empty-loops.c:112:3-112:11) │ + │ YAML loc: 21-empty-loops.c:112:3-112:11 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └─────────────────────────────────────────┘ │ │ prefix() ▼ - ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:115:3-115:38 │ - │ (unknown) │ - │ [21-empty-loops.c:114:1-115:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: false │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ - └──────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 21-empty-loops.c:115:3-115:38 │ + │ (unknown) │ + │ [21-empty-loops.c:114:1-115:3 │ + │ (unknown)] │ skip + │ YAML loc: 21-empty-loops.c:115:3-115:38 │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ + └─────────────────────────────────────────┘ │ │ Neg(1) ▼ - ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:116:1-116:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └──────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 21-empty-loops.c:116:1-116:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:116:1-116:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └─────────────────────────────────────────┘ │ │ return ▼ - ┌──────────────────────────────────────┐ - │ return of f_empty_goto_loop_prefix() │ - └──────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ return of f_empty_goto_loop_prefix() │ + └─────────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_while_loop_prefix.dot ┌──────────────────────────────────────────────┐ @@ -267,7 +267,7 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:120:3-120:11 │ │ (21-empty-loops.c:120:3-120:11) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:120:3-120:11 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ @@ -277,7 +277,7 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:122:3-122:14 (synthetic) │ │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ - │ YAML loc: false, loop: true │ Pos(1) + │ YAML loop: 21-empty-loops.c:122:3-122:14 │ Pos(1) │ YAMLval loc: true, loop: true │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:122:3-122:14 │ ◀────────┘ @@ -288,7 +288,7 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:123:1-123:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:123:1-123:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ @@ -309,9 +309,8 @@ ┌─────────────────────────────────────────┐ │ unknown │ │ (unknown) │ - │ [21-empty-loops.c:127:1-128:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: false │ ───────┐ + │ [21-empty-loops.c:127:1-128:3 │ skip + │ (unknown)] │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ @@ -321,7 +320,7 @@ ┌─────────────────────────────────────────┐ │ 21-empty-loops.c:131:1-131:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:131:1-131:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ @@ -342,7 +341,7 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:135:3-137:3 (synthetic) │ │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ - │ YAML loc: false, loop: true │ Pos(1) + │ YAML loop: 21-empty-loops.c:135:3-137:3 │ Pos(1) │ YAMLval loc: true, loop: true │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:135:3-137:3 │ ◀────────┘ @@ -353,7 +352,7 @@ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:138:1-138:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:138:1-138:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ @@ -365,37 +364,37 @@ └──────────────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_goto_loop_multiple.dot - ┌────────────────────────────────────────┐ - │ f_empty_goto_loop_multiple() │ - └────────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ f_empty_goto_loop_multiple() │ + └─────────────────────────────────────────┘ │ │ (body) ▼ - ┌────────────────────────────────────────┐ - │ 21-empty-loops.c:143:3-143:42 │ - │ (unknown) │ - │ [21-empty-loops.c:142:1-143:3 │ - │ (unknown)] │ skip - │ YAML loc: true, loop: false │ ───────┐ - │ YAMLval loc: true, loop: true │ │ - │ GraphML: true; server: true │ ◀──────┘ - └────────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 21-empty-loops.c:143:3-143:42 │ + │ (unknown) │ + │ [21-empty-loops.c:142:1-143:3 │ + │ (unknown)] │ skip + │ YAML loc: 21-empty-loops.c:143:3-143:42 │ ───────┐ + │ YAMLval loc: true, loop: true │ │ + │ GraphML: true; server: true │ ◀──────┘ + └─────────────────────────────────────────┘ │ │ Neg(1) ▼ - ┌────────────────────────────────────────┐ - │ 21-empty-loops.c:146:1-146:1 │ - │ (unknown) │ - │ YAML loc: true, loop: false │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: true │ - └────────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ 21-empty-loops.c:146:1-146:1 │ + │ (unknown) │ + │ YAML loc: 21-empty-loops.c:146:1-146:1 │ + │ YAMLval loc: true, loop: false │ + │ GraphML: true; server: true │ + └─────────────────────────────────────────┘ │ │ return ▼ - ┌────────────────────────────────────────┐ - │ return of f_empty_goto_loop_multiple() │ - └────────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ return of f_empty_goto_loop_multiple() │ + └─────────────────────────────────────────┘ $ graph-easy --as=boxart f_empty_goto_loop_multiple_semicolon_first.dot ┌────────────────────────────────────────────────────────┐ @@ -407,9 +406,8 @@ ┌────────────────────────────────────────────────────────┐ │ unknown │ │ (unknown) │ - │ [21-empty-loops.c:150:1-151:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: false │ ───────┐ + │ [21-empty-loops.c:150:1-151:3 │ skip + │ (unknown)] │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ @@ -419,7 +417,7 @@ ┌────────────────────────────────────────────────────────┐ │ 21-empty-loops.c:155:1-155:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:155:1-155:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────────────────┘ @@ -442,7 +440,7 @@ │ (unknown) │ │ [21-empty-loops.c:159:1-160:3 │ │ (unknown)] │ skip - │ YAML loc: true, loop: false │ ───────┐ + │ YAML loc: 21-empty-loops.c:160:3-160:59 │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────────────────────┘ @@ -452,7 +450,7 @@ ┌─────────────────────────────────────────────────────────┐ │ 21-empty-loops.c:164:1-164:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:164:1-164:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────────────────────┘ @@ -473,9 +471,8 @@ ┌───────────────────────────────────────────────────────┐ │ unknown │ │ (unknown) │ - │ [21-empty-loops.c:168:1-169:3 │ - │ (unknown)] │ skip - │ YAML loc: false, loop: false │ ───────┐ + │ [21-empty-loops.c:168:1-169:3 │ skip + │ (unknown)] │ ───────┐ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ @@ -485,7 +482,7 @@ ┌───────────────────────────────────────────────────────┐ │ 21-empty-loops.c:174:1-174:1 │ │ (unknown) │ - │ YAML loc: true, loop: false │ + │ YAML loc: 21-empty-loops.c:174:1-174:1 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────────────────────────┘ diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index a3ed58fd424..a2af02a3d9a 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -10,7 +10,7 @@ ┌────────────────────────────────┐ │ foo.c:2:3-2:19 │ │ (foo.c:2:7-2:12 (synthetic)) │ - │ YAML loc: true, loop: false │ + │ YAML loc: foo.c:2:3-2:19 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────┘ @@ -20,7 +20,6 @@ ┌────────────────────────────────┐ │ foo.c:2:3-2:19 (synthetic) │ │ (foo.c:2:14-2:19 (synthetic)) │ - │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────┘ @@ -30,7 +29,7 @@ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ foo.c:7:3-7:11 │ │ foo.c:3:3-6:3 (synthetic) │ │ (foo.c:7:10-7:11) │ │ (foo.c:3:10-3:20 (synthetic)) │ - │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ + │ YAML loc: foo.c:7:3-7:11 │ │ YAML loop: foo.c:3:3-6:3 │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ GraphML: true; server: true │ Neg(a > 0) │ GraphML: true; server: false │ ┌──────▶ │ │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ @@ -39,19 +38,18 @@ │ │ return 0 │ Pos(a > 0) │ │ ▼ ▼ │ │ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ - │ │ │ │ foo.c:3:3-6:3 (synthetic) │ │ - │ Neg(b) │ │ │ (foo.c:3:10-3:20 (synthetic)) │ │ - │ │ return of main() │ │ YAML loc: false, loop: false │ │ + │ Neg(b) │ │ │ foo.c:3:3-6:3 (synthetic) │ │ + │ │ return of main() │ │ (foo.c:3:10-3:20 (synthetic)) │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ ┌─────────── │ GraphML: true; server: false │ │ │ └────────────────────────────────┘ │ └────────────────────────────────┘ │ │ │ │ │ - └────────────────────────────────────────────┘ │ Pos(b) │ b = b - 1 - ▼ │ + └────────────────────────────────────────────┘ │ Pos(b) │ + ▼ │ b = b - 1 ┌────────────────────────────────┐ │ │ foo.c:4:5-4:8 │ │ │ (foo.c:4:5-4:8) │ │ - │ YAML loc: true, loop: false │ │ + │ YAML loc: foo.c:4:5-4:8 │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ │ └────────────────────────────────┘ │ @@ -61,7 +59,7 @@ ┌────────────────────────────────┐ │ │ foo.c:5:5-5:8 │ │ │ (foo.c:5:5-5:8) │ │ - │ YAML loc: true, loop: false │ │ + │ YAML loc: foo.c:5:5-5:8 │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ ─┘ └────────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 0acc007162c..48df029fd48 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -13,9 +13,9 @@ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ issue-1356.c:9:3-9:53 │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ (issue-1356.c:9:3-9:53) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ - │ YAMLval loc: true, loop: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: true │ │ + │ YAMLval loc: true, loop: false │ │ YAML loc: issue-1356.c:9:3-9:53 │ │ + │ GraphML: true; server: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ + │ │ ◀────────────────────────── │ GraphML: true; server: true │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ │ │ Neg(b <= 0) │ @@ -23,7 +23,6 @@ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ ─┘ │ └─────────────────────────────────────────┘ @@ -33,7 +32,6 @@ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ - │ │ YAML loc: false, loop: false │ │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ @@ -43,7 +41,6 @@ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ - │ │ YAML loc: false, loop: false │ │ tmp = 1 │ YAMLval loc: true, loop: false │ └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ @@ -53,7 +50,7 @@ ┌─────────────────────────────────────────┐ │ issue-1356.c:10:3-10:53 │ │ (issue-1356.c:10:3-10:53) │ - │ YAML loc: true, loop: false │ + │ YAML loc: issue-1356.c:10:3-10:53 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ ─┐ └─────────────────────────────────────────┘ │ @@ -63,8 +60,7 @@ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: false, loop: false │ │ Pos(b >= 0) - │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ + │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ Pos(b >= 0) │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ @@ -73,7 +69,6 @@ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ ◀┘ │ └─────────────────────────────────────────┘ @@ -83,7 +78,6 @@ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ - │ │ YAML loc: false, loop: false │ │ tmp___0 = 0 │ YAMLval loc: true, loop: false │ └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ @@ -93,7 +87,7 @@ ┌─────────────────────────────────────────┐ │ issue-1356.c:11:3-11:15 │ │ (issue-1356.c:11:10-11:15) │ - │ YAML loc: true, loop: false │ + │ YAML loc: issue-1356.c:11:3-11:15 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ diff --git a/tests/regression/cfg/loops.t/loops.c b/tests/regression/cfg/loops.t/loops.c index acd9db7a8c5..0e038e18983 100644 --- a/tests/regression/cfg/loops.t/loops.c +++ b/tests/regression/cfg/loops.t/loops.c @@ -38,7 +38,7 @@ int main() { // do-while loop i = 0; do { - i++; // TODO: wrong loop head location + i++; } while (i < 10); return 0; diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index 40280507880..71efa2fe1c3 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -22,7 +22,7 @@ │ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ │ │ loops.c:7:3-7:8 │ │ │ │ │ │ │ │ │ │ (loops.c:7:3-7:8) │ │ │ │ │ - │ │ │ │ │ YAML loc: true, loop: false │ │ │ │ │ + │ │ │ │ │ YAML loc: loops.c:7:3-7:8 │ │ │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ @@ -32,7 +32,7 @@ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ │ │ │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ │ + │ │ │ │ YAML loc: loops.c:9:5-9:8 │ │ YAML loop: loops.c:8:3-10:3 │ │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ │ │ │ │ │ ◀───────────── │ loop: loops.c:8:3-10:3 │ ◀┼───────────────┼────┼────┘ @@ -43,7 +43,7 @@ │ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ loops.c:13:3-15:3 │ │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ i = i + 1 │ │ + │ │ │ │ YAML loc: loops.c:13:3-15:3 │ │ i = i + 1 │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ @@ -53,7 +53,7 @@ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ │ │ │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ - │ │ │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ │ │ + │ │ │ │ YAML loc: loops.c:14:5-14:23 │ │ YAML loop: loops.c:13:3-15:3 │ │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ │ │ │ │ ◀───────────── │ loop: loops.c:13:3-15:3 │ ◀┘ │ │ @@ -64,17 +64,17 @@ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ - │ │ │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ └─ │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ │ + │ │ │ │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:18:3-20:3 │ │ │ + │ │ │ │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ └─ │ │ │ GraphML: true; server: false │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ │ ▼ │ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:18:3-20:3 (synthetic) │ │ loops.c:18:3-20:3 (synthetic) │ │ │ - │ │ │ (loops.c:18:7-18:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ - │ │ │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ │ + │ │ │ │ │ loops.c:18:3-20:3 (synthetic) │ │ │ + │ │ │ loops.c:18:3-20:3 (synthetic) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ + │ │ │ (loops.c:18:7-18:26 (synthetic)) │ │ YAML loop: loops.c:18:3-20:3 │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ GraphML: true; server: false │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ │ └────── │ │ ◀───────────── │ loop: loops.c:18:3-20:3 │ ◀────────────────┘ │ @@ -85,7 +85,7 @@ │ ┌───────────────────────────────────┐ │ │ │ loops.c:23:3-25:3 │ │ │ │ (loops.c:23:7-23:22 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ + │ │ YAML loc: loops.c:23:3-25:3 │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └───────────────────────────────────┘ │ @@ -95,7 +95,7 @@ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ │ │ │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAML loc: loops.c:24:5-24:8 │ │ YAML loop: loops.c:23:3-25:3 │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ └─────────── │ │ ◀───────────── │ loop: loops.c:23:3-25:3 │ ◀─────────────────────┘ @@ -106,7 +106,7 @@ ┌───────────────────────────────────┐ │ loops.c:28:3-28:8 │ │ (loops.c:28:3-28:8) │ - │ YAML loc: true, loop: false │ + │ YAML loc: loops.c:28:3-28:8 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────┘ @@ -116,7 +116,7 @@ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ - │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ + │ YAML loc: loops.c:30:5-30:23 │ │ YAML loop: loops.c:29:3-31:3 │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ ◀───────────── │ loop: loops.c:29:3-31:3 │ ◀─────────────────────┐ @@ -127,9 +127,9 @@ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:23 │ │ │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: false │ │ GraphML: true; server: false │ │ + │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:34:8-34:23 │ │ + │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ + │ │ │ GraphML: true; server: false │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ i = 0 │ @@ -137,7 +137,6 @@ │ ┌───────────────────────────────────┐ │ │ │ loops.c:34:8-34:23 (synthetic) │ │ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ │ YAML loc: false, loop: false │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └───────────────────────────────────┘ │ @@ -147,7 +146,7 @@ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:36 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ YAML loc: loops.c:35:5-35:23 │ │ YAML loop: loops.c:34:3-36:3 │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ │ │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ @@ -158,9 +157,9 @@ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ loops.c:34:8-34:23 (synthetic) │ │ loops.c:39:3-39:8 │ │ │ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ - │ │ YAML loc: false, loop: false │ │ YAML loc: true, loop: false │ │ │ - │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: false │ │ │ - │ │ GraphML: true; server: false │ ─┐ │ GraphML: true; server: true │ │ │ + │ │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:39:3-39:8 │ │ │ + │ │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ │ ─┐ │ GraphML: true; server: true │ │ │ │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ @@ -168,7 +167,8 @@ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ loops.c:41:5-41:8 │ │ │ │ │ │ (loops.c:41:5-41:8) │ │ │ - │ │ │ YAML loc: true, loop: true │ │ │ + │ │ │ YAML loc: loops.c:41:5-41:8 │ │ │ + │ │ │ YAML loop: loops.c:40:3-42:19 │ │ │ │ │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ │ loop: loops.c:40:3-42:19 │ ◀┐ │ │ @@ -179,7 +179,6 @@ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ loops.c:40:3-42:19 (synthetic) │ │ │ │ │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ - │ │ │ YAML loc: false, loop: false │ │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ GraphML: true; server: false │ ─┘ │ │ │ │ └───────────────────────────────────┘ │ │ @@ -189,7 +188,7 @@ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ loops.c:44:3-44:11 │ │ │ │ │ │ (loops.c:44:10-44:11) │ │ │ - │ │ │ YAML loc: true, loop: false │ │ │ + │ │ │ YAML loc: loops.c:44:3-44:11 │ │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ └───────────────────────────────────┘ │ │ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index 2fd7398900f..04554b40883 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -13,7 +13,7 @@ │ ┌────────────────────────────────────┐ │ │ │ pr-758.c:5:3-5:13 │ │ │ │ (pr-758.c:5:7-5:13 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ + │ │ YAML loc: pr-758.c:5:3-5:13 │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ @@ -23,7 +23,7 @@ │ ┌────────────────────────────────────┐ │ │ │ pr-758.c:6:3-8:3 │ │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ - │ │ YAML loc: true, loop: false │ │ + │ │ YAML loc: pr-758.c:6:3-8:3 │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ @@ -31,9 +31,9 @@ │ │ x = 0 │ │ ▼ │ ┌─────────────────────────────────┐ ┌────────────────────────────────────┐ │ - │ pr-758.c:6:3-8:3 (synthetic) │ │ pr-758.c:6:3-8:3 (synthetic) │ │ - │ (pr-758.c:6:7-6:26 (synthetic)) │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ - │ YAML loc: false, loop: false │ │ YAML loc: false, loop: true │ │ + │ │ │ pr-758.c:6:3-8:3 (synthetic) │ │ + │ pr-758.c:6:3-8:3 (synthetic) │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ + │ (pr-758.c:6:7-6:26 (synthetic)) │ │ YAML loop: pr-758.c:6:3-8:3 │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: false │ Pos(x < 10) │ GraphML: true; server: false │ │ │ │ ◀───────────── │ loop: pr-758.c:6:3-8:3 │ ◀┘ @@ -44,7 +44,7 @@ ┌────────────────────────────────────┐ │ pr-758.c:12:3-12:12 │ │ (pr-758.c:12:3-12:12) │ - │ YAML loc: true, loop: false │ + │ YAML loc: pr-758.c:12:3-12:12 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────┘ @@ -54,7 +54,6 @@ ┌────────────────────────────────────┐ │ pr-758.c:12:3-12:12 (synthetic) │ │ (pr-758.c:12:3-12:12 (synthetic)) │ - │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ @@ -64,7 +63,7 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:3-20:25 │ │ (pr-758.c:20:15-20:24 (synthetic)) │ - │ YAML loc: true, loop: false │ + │ YAML loc: pr-758.c:20:3-20:25 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ @@ -74,7 +73,6 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:3-20:25 (synthetic) │ │ (pr-758.c:20:15-20:24 (synthetic)) │ - │ YAML loc: false, loop: false │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ @@ -84,7 +82,7 @@ ┌────────────────────────────────────┐ │ pr-758.c:21:3-21:11 │ │ (pr-758.c:21:10-21:11) │ - │ YAML loc: true, loop: false │ + │ YAML loc: pr-758.c:21:3-21:11 │ │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────┘ diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index 185c045efef..b90bd96a344 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -66,6 +66,12 @@ let main () = let locs = CilLocation.get_labelLoc label in Format.fprintf ppf "@;[%a]" pp_locs locs + let pp_yaml_loc ppf loc = + Format.fprintf ppf "@;YAML loc: %a" CilType.Location.pp loc + + let pp_yaml_loop ppf loc = + Format.fprintf ppf "@;YAML loop: %a" CilType.Location.pp loc + let pp_loop_loc ppf loop = Format.fprintf ppf "@;loop: %a" CilType.Location.pp loop @@ -73,10 +79,11 @@ let main () = | Node.Statement stmt as n -> let locs: CilLocation.locs = CilLocation.get_stmtLoc stmt in let label = - Format.asprintf "@[%a%a@;YAML loc: %B, loop: %B@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B%a@]" + Format.asprintf "@[%a%a%a%a@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B%a@]" pp_locs locs (Format.pp_print_list ~pp_sep:GobFormat.pp_print_nothing pp_label_locs) stmt.labels - (YamlWitnessInvariant.is_invariant_node n) (YamlWitnessInvariant.is_loop_head_node n) + (Format.pp_print_option pp_yaml_loc) (YamlWitnessInvariant.location_location n) + (Format.pp_print_option pp_yaml_loop) (YamlWitnessInvariant.loop_location n) (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) (Format.pp_print_option pp_loop_loc) (GraphmlWitnessInvariant.find_syntactic_loop_head n) From e9b4fd3ac028364ea946fae53629a984335989bb Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 12:01:12 +0200 Subject: [PATCH 25/40] Deprecate WitnessUtil.YamlInvariantValidate --- src/analyses/unassumeAnalysis.ml | 2 +- src/witness/witnessUtil.ml | 1 + src/witness/yamlWitness.ml | 2 +- tests/regression/00-sanity/19-if-0.t | 7 +- tests/regression/00-sanity/20-if-0-realnode.t | 9 +- tests/regression/00-sanity/21-empty-loops.t | 102 ++++++--------- tests/regression/cfg/foo.t/run.t | 118 +++++++++--------- tests/regression/cfg/issue-1356.t/run.t | 17 +-- tests/regression/cfg/loops.t/run.t | 23 +--- tests/regression/cfg/pr-758.t/run.t | 8 -- tests/regression/cfg/util/cfgDot.ml | 4 +- 11 files changed, 107 insertions(+), 186 deletions(-) diff --git a/src/analyses/unassumeAnalysis.ml b/src/analyses/unassumeAnalysis.ml index 5194d1c45c6..8136d4f8c30 100644 --- a/src/analyses/unassumeAnalysis.ml +++ b/src/analyses/unassumeAnalysis.ml @@ -48,7 +48,7 @@ struct let file = !Cilfacade.current_file module Cfg = (val !MyCFG.current_cfg) end in - let module WitnessInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in + let module WitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in (* DFS, copied from CfgTools.find_backwards_reachable *) let reachable = NH.create 100 in diff --git a/src/witness/witnessUtil.ml b/src/witness/witnessUtil.ml index 152f8911e2a..6c025461683 100644 --- a/src/witness/witnessUtil.ml +++ b/src/witness/witnessUtil.ml @@ -133,6 +133,7 @@ struct let is_loop_head_node = NH.mem loop_heads end +[@@deprecated] module InvariantExp = struct diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index 8ce012974cf..8e13ef02dc1 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -546,7 +546,7 @@ struct module Locator = WitnessUtil.Locator (EQSys.LVar) module LvarS = Locator.ES - module WitnessInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) + module WitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) module InvariantParser = WitnessUtil.InvariantParser module VR = ValidationResult diff --git a/tests/regression/00-sanity/19-if-0.t b/tests/regression/00-sanity/19-if-0.t index 2294ed34a9f..9f856c43fcf 100644 --- a/tests/regression/00-sanity/19-if-0.t +++ b/tests/regression/00-sanity/19-if-0.t @@ -10,8 +10,7 @@ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ 19-if-0.c:15:9-15:27 │ │ 19-if-0.c:9:5-16:5 │ │ (19-if-0.c:15:9-15:27) │ │ (19-if-0.c:9:9-9:10) │ - │ YAML loc: 19-if-0.c:15:9-15:27 │ │ YAML loc: 19-if-0.c:9:5-16:5 │ - │ YAMLval loc: true, loop: false │ Neg(0) │ YAMLval loc: true, loop: false │ + │ YAML loc: 19-if-0.c:15:9-15:27 │ Neg(0) │ YAML loc: 19-if-0.c:9:5-16:5 │ │ GraphML: true; server: true │ ◀──────────────────── │ GraphML: true; server: true │ └────────────────────────────────┘ └────────────────────────────────┘ │ │ @@ -21,7 +20,6 @@ │ │ 19-if-0.c:11:9-11:16 │ │ │ (19-if-0.c:11:9-11:16) │ │ │ YAML loc: 19-if-0.c:11:9-11:16 │ - │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: true │ │ └────────────────────────────────┘ │ │ @@ -30,8 +28,7 @@ │ ┌────────────────────────────────┐ │ │ 19-if-0.c:17:5-17:13 │ │ │ (19-if-0.c:17:12-17:13) │ - │ │ YAML loc: 19-if-0.c:17:5-17:13 │ - │ __goblint_check(1) │ YAMLval loc: true, loop: false │ + │ __goblint_check(1) │ YAML loc: 19-if-0.c:17:5-17:13 │ └────────────────────────────────────────────────────▶ │ GraphML: true; server: true │ └────────────────────────────────┘ │ diff --git a/tests/regression/00-sanity/20-if-0-realnode.t b/tests/regression/00-sanity/20-if-0-realnode.t index 3d22d094ab0..32f06ecdd44 100644 --- a/tests/regression/00-sanity/20-if-0-realnode.t +++ b/tests/regression/00-sanity/20-if-0-realnode.t @@ -10,10 +10,9 @@ ┌─────────────────────────────────────────┐ │ 20-if-0-realnode.c:8:5-14:5 │ │ (20-if-0-realnode.c:8:9-8:10) │ - │ [20-if-0-realnode.c:7:5-8:5 │ - │ (unknown)] │ Neg(0) - │ YAML loc: 20-if-0-realnode.c:8:5-14:5 │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ + │ [20-if-0-realnode.c:7:5-8:5 │ Neg(0) + │ (unknown)] │ ─────────┐ + │ YAML loc: 20-if-0-realnode.c:8:5-14:5 │ │ │ GraphML: true; server: true │ ◀────────┘ └─────────────────────────────────────────┘ │ @@ -23,7 +22,6 @@ │ 20-if-0-realnode.c:10:9-10:16 │ │ (20-if-0-realnode.c:10:9-10:16) │ │ YAML loc: 20-if-0-realnode.c:10:9-10:16 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ @@ -33,7 +31,6 @@ │ 20-if-0-realnode.c:15:5-15:13 │ │ (20-if-0-realnode.c:15:12-15:13) │ │ YAML loc: 20-if-0-realnode.c:15:5-15:13 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ diff --git a/tests/regression/00-sanity/21-empty-loops.t b/tests/regression/00-sanity/21-empty-loops.t index 2daf9615923..932a21f049e 100644 --- a/tests/regression/00-sanity/21-empty-loops.t +++ b/tests/regression/00-sanity/21-empty-loops.t @@ -10,10 +10,9 @@ ┌───────────────────────────────────────┐ │ 21-empty-loops.c:57:3-57:31 │ │ (unknown) │ - │ [21-empty-loops.c:56:1-57:3 │ - │ (unknown)] │ skip - │ YAML loc: 21-empty-loops.c:57:3-57:31 │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ [21-empty-loops.c:56:1-57:3 │ skip + │ (unknown)] │ ───────┐ + │ YAML loc: 21-empty-loops.c:57:3-57:31 │ │ │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────┘ │ @@ -23,7 +22,6 @@ │ 21-empty-loops.c:58:1-58:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:58:1-58:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────────┘ │ @@ -42,9 +40,8 @@ ▼ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:62:3-62:14 (synthetic) │ - │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ - │ YAML loop: 21-empty-loops.c:62:3-62:14 │ Pos(1) - │ YAMLval loc: true, loop: true │ ─────────┐ + │ (21-empty-loops.c:62:10-62:11 (synthetic)) │ Pos(1) + │ YAML loop: 21-empty-loops.c:62:3-62:14 │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:62:3-62:14 │ ◀────────┘ └────────────────────────────────────────────┘ @@ -55,7 +52,6 @@ │ 21-empty-loops.c:63:1-63:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:63:1-63:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ @@ -70,7 +66,6 @@ │ 21-empty-loops.c:75:3-75:11 │ │ (21-empty-loops.c:75:3-75:11) │ │ YAML loc: 21-empty-loops.c:75:3-75:11 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────────┘ │ @@ -80,7 +75,6 @@ │ 21-empty-loops.c:76:1-76:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:76:1-76:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ ◀┐ └───────────────────────────────────────┘ │ │ │ @@ -98,10 +92,9 @@ ┌───────────────────────────────────────┐ │ │ 21-empty-loops.c:73:3-73:38 │ │ │ (unknown) │ │ - │ [21-empty-loops.c:72:1-73:3 │ │ - skip │ (unknown)] │ │ - ┌─────── │ YAML loc: 21-empty-loops.c:73:3-73:38 │ │ - │ │ YAMLval loc: true, loop: true │ │ + skip │ [21-empty-loops.c:72:1-73:3 │ │ + ┌─────── │ (unknown)] │ │ + │ │ YAML loc: 21-empty-loops.c:73:3-73:38 │ │ └──────▶ │ GraphML: true; server: true │ ─┘ └───────────────────────────────────────┘ @@ -114,9 +107,8 @@ ▼ ┌────────────────────────────────────────────┐ │ 21-empty-loops.c:80:3-80:14 (synthetic) │ - │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ - │ YAML loop: 21-empty-loops.c:80:3-80:14 │ Pos(1) - │ YAMLval loc: true, loop: true │ ─────────┐ + │ (21-empty-loops.c:80:10-80:11 (synthetic)) │ Pos(1) + │ YAML loop: 21-empty-loops.c:80:3-80:14 │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:80:3-80:14 │ ◀────────┘ └────────────────────────────────────────────┘ @@ -127,7 +119,6 @@ │ 21-empty-loops.c:82:3-82:11 │ │ (21-empty-loops.c:82:3-82:11) │ │ YAML loc: 21-empty-loops.c:82:3-82:11 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ @@ -137,7 +128,6 @@ │ 21-empty-loops.c:83:1-83:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:83:1-83:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ @@ -155,10 +145,9 @@ │ (body) ▼ ┌──────────────────────────────────────┐ - │ 21-empty-loops.c:93:3-93:9 │ - │ (21-empty-loops.c:93:3-93:9) │ body() - │ YAML loc: 21-empty-loops.c:93:3-93:9 │ ─────────┐ - │ YAMLval loc: true, loop: true │ │ + │ 21-empty-loops.c:93:3-93:9 │ body() + │ (21-empty-loops.c:93:3-93:9) │ ─────────┐ + │ YAML loc: 21-empty-loops.c:93:3-93:9 │ │ │ GraphML: true; server: true │ ◀────────┘ └──────────────────────────────────────┘ │ @@ -168,7 +157,6 @@ │ 21-empty-loops.c:95:1-95:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:95:1-95:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────┘ │ @@ -192,7 +180,6 @@ │ 21-empty-loops.c:101:5-101:11 │ │ 21-empty-loops.c:99:3-102:3 (synthetic) │ │ │ (21-empty-loops.c:101:5-101:11) │ │ (21-empty-loops.c:99:10-99:11 (synthetic)) │ │ │ YAML loc: 21-empty-loops.c:101:5-101:11 │ │ YAML loop: 21-empty-loops.c:99:3-102:3 │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: true │ Pos(1) │ GraphML: true; server: false │ │ │ │ ◀──────── │ loop: 21-empty-loops.c:99:3-102:3 │ ◀┘ └─────────────────────────────────────────┘ └────────────────────────────────────────────┘ @@ -203,7 +190,6 @@ │ 21-empty-loops.c:103:1-103:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:103:1-103:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────┘ │ @@ -225,7 +211,6 @@ │ 21-empty-loops.c:112:3-112:11 │ │ (21-empty-loops.c:112:3-112:11) │ │ YAML loc: 21-empty-loops.c:112:3-112:11 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ @@ -234,10 +219,9 @@ ┌─────────────────────────────────────────┐ │ 21-empty-loops.c:115:3-115:38 │ │ (unknown) │ - │ [21-empty-loops.c:114:1-115:3 │ - │ (unknown)] │ skip - │ YAML loc: 21-empty-loops.c:115:3-115:38 │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ [21-empty-loops.c:114:1-115:3 │ skip + │ (unknown)] │ ───────┐ + │ YAML loc: 21-empty-loops.c:115:3-115:38 │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ │ @@ -247,7 +231,6 @@ │ 21-empty-loops.c:116:1-116:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:116:1-116:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ @@ -268,7 +251,6 @@ │ 21-empty-loops.c:120:3-120:11 │ │ (21-empty-loops.c:120:3-120:11) │ │ YAML loc: 21-empty-loops.c:120:3-120:11 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ @@ -276,9 +258,8 @@ ▼ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:122:3-122:14 (synthetic) │ - │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ - │ YAML loop: 21-empty-loops.c:122:3-122:14 │ Pos(1) - │ YAMLval loc: true, loop: true │ ─────────┐ + │ (21-empty-loops.c:122:10-122:11 (synthetic)) │ Pos(1) + │ YAML loop: 21-empty-loops.c:122:3-122:14 │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:122:3-122:14 │ ◀────────┘ └──────────────────────────────────────────────┘ @@ -289,7 +270,6 @@ │ 21-empty-loops.c:123:1-123:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:123:1-123:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ @@ -308,10 +288,9 @@ ▼ ┌─────────────────────────────────────────┐ │ unknown │ - │ (unknown) │ - │ [21-empty-loops.c:127:1-128:3 │ skip - │ (unknown)] │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ (unknown) │ skip + │ [21-empty-loops.c:127:1-128:3 │ ───────┐ + │ (unknown)] │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ │ @@ -321,7 +300,6 @@ │ 21-empty-loops.c:131:1-131:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:131:1-131:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ @@ -340,9 +318,8 @@ ▼ ┌──────────────────────────────────────────────┐ │ 21-empty-loops.c:135:3-137:3 (synthetic) │ - │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ - │ YAML loop: 21-empty-loops.c:135:3-137:3 │ Pos(1) - │ YAMLval loc: true, loop: true │ ─────────┐ + │ (21-empty-loops.c:135:10-135:11 (synthetic)) │ Pos(1) + │ YAML loop: 21-empty-loops.c:135:3-137:3 │ ─────────┐ │ GraphML: true; server: false │ │ │ loop: 21-empty-loops.c:135:3-137:3 │ ◀────────┘ └──────────────────────────────────────────────┘ @@ -353,7 +330,6 @@ │ 21-empty-loops.c:138:1-138:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:138:1-138:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └──────────────────────────────────────────────┘ │ @@ -373,10 +349,9 @@ ┌─────────────────────────────────────────┐ │ 21-empty-loops.c:143:3-143:42 │ │ (unknown) │ - │ [21-empty-loops.c:142:1-143:3 │ - │ (unknown)] │ skip - │ YAML loc: 21-empty-loops.c:143:3-143:42 │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ [21-empty-loops.c:142:1-143:3 │ skip + │ (unknown)] │ ───────┐ + │ YAML loc: 21-empty-loops.c:143:3-143:42 │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────┘ │ @@ -386,7 +361,6 @@ │ 21-empty-loops.c:146:1-146:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:146:1-146:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ @@ -405,10 +379,9 @@ ▼ ┌────────────────────────────────────────────────────────┐ │ unknown │ - │ (unknown) │ - │ [21-empty-loops.c:150:1-151:3 │ skip - │ (unknown)] │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ (unknown) │ skip + │ [21-empty-loops.c:150:1-151:3 │ ───────┐ + │ (unknown)] │ │ │ GraphML: true; server: true │ ◀──────┘ └────────────────────────────────────────────────────────┘ │ @@ -418,7 +391,6 @@ │ 21-empty-loops.c:155:1-155:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:155:1-155:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────────────────────────┘ │ @@ -438,10 +410,9 @@ ┌─────────────────────────────────────────────────────────┐ │ 21-empty-loops.c:160:3-160:59 │ │ (unknown) │ - │ [21-empty-loops.c:159:1-160:3 │ - │ (unknown)] │ skip - │ YAML loc: 21-empty-loops.c:160:3-160:59 │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ [21-empty-loops.c:159:1-160:3 │ skip + │ (unknown)] │ ───────┐ + │ YAML loc: 21-empty-loops.c:160:3-160:59 │ │ │ GraphML: true; server: true │ ◀──────┘ └─────────────────────────────────────────────────────────┘ │ @@ -451,7 +422,6 @@ │ 21-empty-loops.c:164:1-164:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:164:1-164:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────────────────────┘ │ @@ -470,10 +440,9 @@ ▼ ┌───────────────────────────────────────────────────────┐ │ unknown │ - │ (unknown) │ - │ [21-empty-loops.c:168:1-169:3 │ skip - │ (unknown)] │ ───────┐ - │ YAMLval loc: true, loop: true │ │ + │ (unknown) │ skip + │ [21-empty-loops.c:168:1-169:3 │ ───────┐ + │ (unknown)] │ │ │ GraphML: true; server: true │ ◀──────┘ └───────────────────────────────────────────────────────┘ │ @@ -483,7 +452,6 @@ │ 21-empty-loops.c:174:1-174:1 │ │ (unknown) │ │ YAML loc: 21-empty-loops.c:174:1-174:1 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────────────────────────┘ │ diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index a2af02a3d9a..ba7720d81fe 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -1,65 +1,59 @@ $ cfgDot foo.c $ graph-easy --as=boxart main.dot - ┌────────────────────────────────┐ - │ main() │ - └────────────────────────────────┘ - │ - │ (body) - ▼ - ┌────────────────────────────────┐ - │ foo.c:2:3-2:19 │ - │ (foo.c:2:7-2:12 (synthetic)) │ - │ YAML loc: foo.c:2:3-2:19 │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: false │ - └────────────────────────────────┘ - │ - │ a = 1 - ▼ - ┌────────────────────────────────┐ - │ foo.c:2:3-2:19 (synthetic) │ - │ (foo.c:2:14-2:19 (synthetic)) │ - │ YAMLval loc: true, loop: false │ - │ GraphML: true; server: false │ - └────────────────────────────────┘ - │ - │ b = 1 - ▼ - ┌────────────────────────────────┐ ┌────────────────────────────────┐ - │ foo.c:7:3-7:11 │ │ foo.c:3:3-6:3 (synthetic) │ - │ (foo.c:7:10-7:11) │ │ (foo.c:3:10-3:20 (synthetic)) │ - │ YAML loc: foo.c:7:3-7:11 │ │ YAML loop: foo.c:3:3-6:3 │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ - │ GraphML: true; server: true │ Neg(a > 0) │ GraphML: true; server: false │ - ┌──────▶ │ │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ - │ └────────────────────────────────┘ └────────────────────────────────┘ │ - │ │ │ │ - │ │ return 0 │ Pos(a > 0) │ - │ ▼ ▼ │ - │ ┌────────────────────────────────┐ ┌────────────────────────────────┐ │ - │ Neg(b) │ │ │ foo.c:3:3-6:3 (synthetic) │ │ - │ │ return of main() │ │ (foo.c:3:10-3:20 (synthetic)) │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ - │ │ │ ┌─────────── │ GraphML: true; server: false │ │ - │ └────────────────────────────────┘ │ └────────────────────────────────┘ │ - │ │ │ │ - └────────────────────────────────────────────┘ │ Pos(b) │ - ▼ │ b = b - 1 - ┌────────────────────────────────┐ │ - │ foo.c:4:5-4:8 │ │ - │ (foo.c:4:5-4:8) │ │ - │ YAML loc: foo.c:4:5-4:8 │ │ - │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: true │ │ - └────────────────────────────────┘ │ - │ │ - │ a = a + 1 │ - ▼ │ - ┌────────────────────────────────┐ │ - │ foo.c:5:5-5:8 │ │ - │ (foo.c:5:5-5:8) │ │ - │ YAML loc: foo.c:5:5-5:8 │ │ - │ YAMLval loc: true, loop: false │ │ - │ GraphML: true; server: true │ ─┘ - └────────────────────────────────┘ + ┌───────────────────────────────┐ + │ main() │ + └───────────────────────────────┘ + │ + │ (body) + ▼ + ┌───────────────────────────────┐ + │ foo.c:2:3-2:19 │ + │ (foo.c:2:7-2:12 (synthetic)) │ + │ YAML loc: foo.c:2:3-2:19 │ + │ GraphML: true; server: false │ + └───────────────────────────────┘ + │ + │ a = 1 + ▼ + ┌───────────────────────────────┐ + │ foo.c:2:3-2:19 (synthetic) │ + │ (foo.c:2:14-2:19 (synthetic)) │ + │ GraphML: true; server: false │ + └───────────────────────────────┘ + │ + │ b = 1 + ▼ + ┌─────────────────────────────┐ ┌───────────────────────────────┐ + │ foo.c:7:3-7:11 │ │ foo.c:3:3-6:3 (synthetic) │ + │ (foo.c:7:10-7:11) │ │ (foo.c:3:10-3:20 (synthetic)) │ + │ YAML loc: foo.c:7:3-7:11 │ │ YAML loop: foo.c:3:3-6:3 │ + │ GraphML: true; server: true │ Neg(a > 0) │ GraphML: true; server: false │ + ┌──────▶ │ │ ◀──────────── │ loop: foo.c:3:3-6:3 │ ◀┐ + │ └─────────────────────────────┘ └───────────────────────────────┘ │ + │ │ │ │ + │ │ return 0 │ Pos(a > 0) │ + │ ▼ ▼ │ + │ ┌─────────────────────────────┐ ┌───────────────────────────────┐ │ + │ Neg(b) │ │ │ foo.c:3:3-6:3 (synthetic) │ │ + │ │ return of main() │ │ (foo.c:3:10-3:20 (synthetic)) │ │ + │ │ │ ┌─────────── │ GraphML: true; server: false │ │ + │ └─────────────────────────────┘ │ └───────────────────────────────┘ │ + │ │ │ │ + └─────────────────────────────────────────┘ │ Pos(b) │ + ▼ │ b = b - 1 + ┌───────────────────────────────┐ │ + │ foo.c:4:5-4:8 │ │ + │ (foo.c:4:5-4:8) │ │ + │ YAML loc: foo.c:4:5-4:8 │ │ + │ GraphML: true; server: true │ │ + └───────────────────────────────┘ │ + │ │ + │ a = a + 1 │ + ▼ │ + ┌───────────────────────────────┐ │ + │ foo.c:5:5-5:8 │ │ + │ (foo.c:5:5-5:8) │ │ + │ YAML loc: foo.c:5:5-5:8 │ │ + │ GraphML: true; server: true │ ─┘ + └───────────────────────────────┘ diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 48df029fd48..195b29deef2 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -13,8 +13,7 @@ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ issue-1356.c:9:3-9:53 │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ (issue-1356.c:9:3-9:53) │ │ - │ YAMLval loc: true, loop: false │ │ YAML loc: issue-1356.c:9:3-9:53 │ │ - │ GraphML: true; server: false │ Pos(b <= 0) │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ Pos(b <= 0) │ YAML loc: issue-1356.c:9:3-9:53 │ │ │ │ ◀────────────────────────── │ GraphML: true; server: true │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ @@ -23,7 +22,6 @@ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ ─┘ │ └─────────────────────────────────────────┘ │ │ @@ -32,7 +30,6 @@ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ - │ │ YAMLval loc: true, loop: false │ │ │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ │ │ @@ -40,8 +37,7 @@ │ ▼ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:9:3-9:53 (synthetic) │ - │ │ (issue-1356.c:9:3-9:53 (synthetic)) │ - │ tmp = 1 │ YAMLval loc: true, loop: false │ + │ tmp = 1 │ (issue-1356.c:9:3-9:53 (synthetic)) │ └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ @@ -51,7 +47,6 @@ │ issue-1356.c:10:3-10:53 │ │ (issue-1356.c:10:3-10:53) │ │ YAML loc: issue-1356.c:10:3-10:53 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ ─┐ └─────────────────────────────────────────┘ │ │ │ @@ -59,8 +54,7 @@ ▼ │ ┌─────────────────────────────────────────┐ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ - │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ YAMLval loc: true, loop: false │ Neg(a <= b + 2147483647) │ YAMLval loc: true, loop: false │ │ Pos(b >= 0) + │ (issue-1356.c:10:3-10:53 (synthetic)) │ Neg(a <= b + 2147483647) │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ Pos(b >= 0) │ GraphML: true; server: false │ ◀────────────────────────── │ GraphML: true; server: false │ │ └─────────────────────────────────────────┘ └─────────────────────────────────────────┘ │ │ │ │ @@ -69,7 +63,6 @@ │ ┌─────────────────────────────────────────┐ │ │ │ issue-1356.c:10:3-10:53 (synthetic) │ │ │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ ◀┘ │ └─────────────────────────────────────────┘ │ │ @@ -77,8 +70,7 @@ │ ▼ │ ┌─────────────────────────────────────────┐ │ │ issue-1356.c:10:3-10:53 (synthetic) │ - │ │ (issue-1356.c:10:3-10:53 (synthetic)) │ - │ tmp___0 = 0 │ YAMLval loc: true, loop: false │ + │ tmp___0 = 0 │ (issue-1356.c:10:3-10:53 (synthetic)) │ └───────────────────────────────────────────────────────────────────▶ │ GraphML: true; server: false │ └─────────────────────────────────────────┘ │ @@ -88,7 +80,6 @@ │ issue-1356.c:11:3-11:15 │ │ (issue-1356.c:11:10-11:15) │ │ YAML loc: issue-1356.c:11:3-11:15 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └─────────────────────────────────────────┘ │ diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index 71efa2fe1c3..bd9ec423075 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -23,7 +23,6 @@ │ │ │ │ │ loops.c:7:3-7:8 │ │ │ │ │ │ │ │ │ │ (loops.c:7:3-7:8) │ │ │ │ │ │ │ │ │ │ YAML loc: loops.c:7:3-7:8 │ │ │ │ │ - │ │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -33,7 +32,6 @@ │ │ │ │ loops.c:9:5-9:8 │ │ loops.c:8:3-10:3 (synthetic) │ │ │ │ │ │ │ │ │ (loops.c:9:5-9:8) │ │ (loops.c:8:10-8:16 (synthetic)) │ │ │ │ │ │ │ │ │ YAML loc: loops.c:9:5-9:8 │ │ YAML loop: loops.c:8:3-10:3 │ │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ │ │ │ │ │ ◀───────────── │ loop: loops.c:8:3-10:3 │ ◀┼───────────────┼────┼────┘ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ @@ -44,7 +42,6 @@ │ │ │ │ loops.c:13:3-15:3 │ │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ │ │ │ │ YAML loc: loops.c:13:3-15:3 │ │ i = i + 1 │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ @@ -54,7 +51,6 @@ │ │ │ │ loops.c:14:5-14:23 │ │ loops.c:13:3-15:3 (synthetic) │ │ │ │ │ │ │ │ (loops.c:14:5-14:23) │ │ (loops.c:13:7-13:26 (synthetic)) │ │ │ │ │ │ │ │ YAML loc: loops.c:14:5-14:23 │ │ YAML loop: loops.c:13:3-15:3 │ │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ │ │ │ │ │ │ │ │ ◀───────────── │ loop: loops.c:13:3-15:3 │ ◀┘ │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ @@ -64,8 +60,7 @@ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ │ │ loops.c:13:3-15:3 (synthetic) │ │ loops.c:18:3-20:3 │ │ │ │ │ │ │ (loops.c:13:7-13:26 (synthetic)) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ - │ │ │ │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:18:3-20:3 │ │ │ - │ │ │ │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ │ │ GraphML: true; server: false │ │ YAML loc: loops.c:18:3-20:3 │ │ │ │ │ └─ │ │ │ GraphML: true; server: false │ │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ @@ -75,7 +70,6 @@ │ │ │ │ │ loops.c:18:3-20:3 (synthetic) │ │ │ │ │ │ loops.c:18:3-20:3 (synthetic) │ │ (loops.c:18:7-18:26 (synthetic)) │ │ │ │ │ │ (loops.c:18:7-18:26 (synthetic)) │ │ YAML loop: loops.c:18:3-20:3 │ │ │ - │ │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ GraphML: true; server: false │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ │ └────── │ │ ◀───────────── │ loop: loops.c:18:3-20:3 │ ◀────────────────┘ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ @@ -86,7 +80,6 @@ │ │ loops.c:23:3-25:3 │ │ │ │ (loops.c:23:7-23:22 (synthetic)) │ │ │ │ YAML loc: loops.c:23:3-25:3 │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └───────────────────────────────────┘ │ │ │ │ @@ -96,7 +89,6 @@ │ │ loops.c:24:5-24:8 │ │ loops.c:23:3-25:3 (synthetic) │ │ │ │ (loops.c:24:5-24:8) │ │ (loops.c:23:7-23:22 (synthetic)) │ │ │ │ YAML loc: loops.c:24:5-24:8 │ │ YAML loop: loops.c:23:3-25:3 │ │ - │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ └─────────── │ │ ◀───────────── │ loop: loops.c:23:3-25:3 │ ◀─────────────────────┘ └───────────────────────────────────┘ └───────────────────────────────────┘ @@ -107,7 +99,6 @@ │ loops.c:28:3-28:8 │ │ (loops.c:28:3-28:8) │ │ YAML loc: loops.c:28:3-28:8 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └───────────────────────────────────┘ │ @@ -117,7 +108,6 @@ │ loops.c:30:5-30:23 │ │ loops.c:29:3-31:3 (synthetic) │ │ (loops.c:30:5-30:23) │ │ (loops.c:29:7-29:21 (synthetic)) │ │ YAML loc: loops.c:30:5-30:23 │ │ YAML loop: loops.c:29:3-31:3 │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ ◀───────────── │ loop: loops.c:29:3-31:3 │ ◀─────────────────────┐ └───────────────────────────────────┘ └───────────────────────────────────┘ │ @@ -127,8 +117,7 @@ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:23 │ │ │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:34:8-34:23 │ │ - │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ + │ GraphML: true; server: false │ │ YAML loc: loops.c:34:8-34:23 │ │ │ │ │ GraphML: true; server: false │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ @@ -137,7 +126,6 @@ │ ┌───────────────────────────────────┐ │ │ │ loops.c:34:8-34:23 (synthetic) │ │ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └───────────────────────────────────┘ │ │ │ │ @@ -147,7 +135,6 @@ │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:36 (synthetic)) │ │ │ │ YAML loc: loops.c:35:5-35:23 │ │ YAML loop: loops.c:34:3-36:3 │ │ - │ │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ │ │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ @@ -157,8 +144,7 @@ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ │ loops.c:34:8-34:23 (synthetic) │ │ loops.c:39:3-39:8 │ │ │ │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ - │ │ YAMLval loc: true, loop: false │ │ YAML loc: loops.c:39:3-39:8 │ │ │ - │ │ GraphML: true; server: false │ │ YAMLval loc: true, loop: false │ │ │ + │ │ GraphML: true; server: false │ │ YAML loc: loops.c:39:3-39:8 │ │ │ │ │ │ ─┐ │ GraphML: true; server: true │ │ │ │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ @@ -169,7 +155,6 @@ │ │ │ (loops.c:41:5-41:8) │ │ │ │ │ │ YAML loc: loops.c:41:5-41:8 │ │ │ │ │ │ YAML loop: loops.c:40:3-42:19 │ │ │ - │ │ │ YAMLval loc: true, loop: true │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ │ loop: loops.c:40:3-42:19 │ ◀┐ │ │ │ │ └───────────────────────────────────┘ │ │ │ @@ -179,7 +164,6 @@ │ │ ┌───────────────────────────────────┐ │ │ │ │ │ │ loops.c:40:3-42:19 (synthetic) │ │ │ │ │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ - │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ │ GraphML: true; server: false │ ─┘ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ @@ -189,7 +173,6 @@ │ │ │ loops.c:44:3-44:11 │ │ │ │ │ │ (loops.c:44:10-44:11) │ │ │ │ │ │ YAML loc: loops.c:44:3-44:11 │ │ │ - │ │ │ YAMLval loc: true, loop: false │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ │ └───────────────────────────────────┘ │ │ │ │ │ │ │ diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index 04554b40883..d05e5affcbd 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -14,7 +14,6 @@ │ │ pr-758.c:5:3-5:13 │ │ │ │ (pr-758.c:5:7-5:13 (synthetic)) │ │ │ │ YAML loc: pr-758.c:5:3-5:13 │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ │ │ │ x = x + 1 @@ -24,7 +23,6 @@ │ │ pr-758.c:6:3-8:3 │ │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ │ │ YAML loc: pr-758.c:6:3-8:3 │ │ - │ │ YAMLval loc: true, loop: false │ │ │ │ GraphML: true; server: false │ │ │ └────────────────────────────────────┘ │ │ │ │ @@ -34,7 +32,6 @@ │ │ │ pr-758.c:6:3-8:3 (synthetic) │ │ │ pr-758.c:6:3-8:3 (synthetic) │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ │ (pr-758.c:6:7-6:26 (synthetic)) │ │ YAML loop: pr-758.c:6:3-8:3 │ │ - │ YAMLval loc: true, loop: false │ │ YAMLval loc: true, loop: true │ │ │ GraphML: true; server: false │ Pos(x < 10) │ GraphML: true; server: false │ │ │ │ ◀───────────── │ loop: pr-758.c:6:3-8:3 │ ◀┘ └─────────────────────────────────┘ └────────────────────────────────────┘ @@ -45,7 +42,6 @@ │ pr-758.c:12:3-12:12 │ │ (pr-758.c:12:3-12:12) │ │ YAML loc: pr-758.c:12:3-12:12 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────┘ │ @@ -54,7 +50,6 @@ ┌────────────────────────────────────┐ │ pr-758.c:12:3-12:12 (synthetic) │ │ (pr-758.c:12:3-12:12 (synthetic)) │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ │ @@ -64,7 +59,6 @@ │ pr-758.c:20:3-20:25 │ │ (pr-758.c:20:15-20:24 (synthetic)) │ │ YAML loc: pr-758.c:20:3-20:25 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ │ @@ -73,7 +67,6 @@ ┌────────────────────────────────────┐ │ pr-758.c:20:3-20:25 (synthetic) │ │ (pr-758.c:20:15-20:24 (synthetic)) │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: false │ └────────────────────────────────────┘ │ @@ -83,7 +76,6 @@ │ pr-758.c:21:3-21:11 │ │ (pr-758.c:21:10-21:11) │ │ YAML loc: pr-758.c:21:3-21:11 │ - │ YAMLval loc: true, loop: false │ │ GraphML: true; server: true │ └────────────────────────────────────┘ │ diff --git a/tests/regression/cfg/util/cfgDot.ml b/tests/regression/cfg/util/cfgDot.ml index b90bd96a344..16f03ee43a6 100644 --- a/tests/regression/cfg/util/cfgDot.ml +++ b/tests/regression/cfg/util/cfgDot.ml @@ -45,7 +45,6 @@ let main () = let module GraphmlWitnessInvariant = WitnessUtil.Invariant (FileCfg) in let module YamlWitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in - let module YamlWitnessValidateInvariant = WitnessUtil.YamlInvariantValidate (FileCfg) in let module LocationExtraNodeStyles = struct @@ -79,12 +78,11 @@ let main () = | Node.Statement stmt as n -> let locs: CilLocation.locs = CilLocation.get_stmtLoc stmt in let label = - Format.asprintf "@[%a%a%a%a@;YAMLval loc: %B, loop: %B@;GraphML: %B; server: %B%a@]" + Format.asprintf "@[%a%a%a%a@;GraphML: %B; server: %B%a@]" pp_locs locs (Format.pp_print_list ~pp_sep:GobFormat.pp_print_nothing pp_label_locs) stmt.labels (Format.pp_print_option pp_yaml_loc) (YamlWitnessInvariant.location_location n) (Format.pp_print_option pp_yaml_loop) (YamlWitnessInvariant.loop_location n) - (YamlWitnessValidateInvariant.is_invariant_node n) (YamlWitnessValidateInvariant.is_loop_head_node n) (GraphmlWitnessInvariant.is_invariant_node n) (Server.is_server_node n) (Format.pp_print_option pp_loop_loc) (GraphmlWitnessInvariant.find_syntactic_loop_head n) in From 09794b9464dc6b20e6568e14cfdc84266fb0d4c9 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 12:32:10 +0200 Subject: [PATCH 26/40] Use non-Node locations for YAML witnesses --- src/analyses/unassumeAnalysis.ml | 20 ++--- src/witness/yamlWitness.ml | 127 ++++++++++++++++--------------- 2 files changed, 77 insertions(+), 70 deletions(-) diff --git a/src/analyses/unassumeAnalysis.ml b/src/analyses/unassumeAnalysis.ml index 8136d4f8c30..86db81e86bd 100644 --- a/src/analyses/unassumeAnalysis.ml +++ b/src/analyses/unassumeAnalysis.ml @@ -27,7 +27,7 @@ struct module Locator = WitnessUtil.Locator (Node) - let locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *) + let location_locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *) let loop_locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *) type inv = { @@ -41,7 +41,7 @@ struct let pre_invs: inv EH.t NH.t = NH.create 100 let init _ = - Locator.clear locator; + Locator.clear location_locator; Locator.clear loop_locator; let module FileCfg = struct @@ -55,10 +55,12 @@ struct let rec iter_node node = if not (NH.mem reachable node) then begin NH.replace reachable node (); - if WitnessInvariant.is_invariant_node node then - Locator.add locator (Node.location node) node; - if WitnessInvariant.is_loop_head_node node then - Locator.add loop_locator (Node.location node) node; + Option.iter (fun loc -> + Locator.add location_locator loc node + ) (WitnessInvariant.location_location node); + Option.iter (fun loc -> + Locator.add loop_locator loc node + ) (WitnessInvariant.loop_location node); List.iter (fun (_, prev_node) -> iter_node prev_node ) (FileCfg.Cfg.prev node) @@ -128,7 +130,7 @@ struct let inv = location_invariant.location_invariant.string in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some nodes -> unassume_nodes_invariant ~loc ~nodes inv | None -> @@ -191,7 +193,7 @@ struct let inv = precondition_loop_invariant.loop_invariant.string in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some nodes -> unassume_precondition_nodes_invariant ~loc ~nodes pre inv | None -> @@ -205,7 +207,7 @@ struct let inv = location_invariant.value in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some nodes -> unassume_nodes_invariant ~loc ~nodes inv | None -> diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index 8e13ef02dc1..028b9deee0b 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -172,10 +172,21 @@ struct (* TODO: fix location hack *) module LH = BatHashtbl.Make (CilType.Location) - let location2nodes: Node.t list LH.t Lazy.t = lazy ( + let location_nodes: Node.t list LH.t Lazy.t = lazy ( let lh = LH.create 113 in NH.iter (fun n _ -> - LH.modify_def [] (Node.location n) (List.cons n) lh + Option.iter (fun loc -> + LH.modify_def [] loc (List.cons n) lh + ) (WitnessInvariant.location_location n) + ) (Lazy.force nh); + lh + ) + let loop_nodes: Node.t list LH.t Lazy.t = lazy ( + let lh = LH.create 113 in + NH.iter (fun n _ -> + Option.iter (fun loc -> + LH.modify_def [] loc (List.cons n) lh + ) (WitnessInvariant.loop_location n) ) (Lazy.force nh); lh ) @@ -235,30 +246,26 @@ struct let entries = if entry_type_enabled YamlWitnessType.LocationInvariant.entry_type then ( LH.fold (fun loc ns acc -> - if List.exists WitnessInvariant.is_invariant_node ns then ( - let inv = List.fold_left (fun acc n -> - let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in - let lvals = local_lvals n local in - Invariant.(acc || R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals})) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) - ) (Invariant.bot ()) ns - in - match inv with - | `Lifted inv -> - let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *) - let location_function = fundec.svar.vname in - let location = Entry.location ~location:loc ~location_function in - let invs = WitnessUtil.InvariantExp.process_exp inv in - List.fold_left (fun acc inv -> - let invariant = Entry.invariant (CilType.Exp.show inv) in - let entry = Entry.location_invariant ~task ~location ~invariant in - entry :: acc - ) acc invs - | `Bot | `Top -> (* TODO: 0 for bot (dead code)? *) - acc - ) - else + let inv = List.fold_left (fun acc n -> + let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in + let lvals = local_lvals n local in + Invariant.(acc || R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals})) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) + ) (Invariant.bot ()) ns + in + match inv with + | `Lifted inv -> + let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *) + let location_function = fundec.svar.vname in + let location = Entry.location ~location:loc ~location_function in + let invs = WitnessUtil.InvariantExp.process_exp inv in + List.fold_left (fun acc inv -> + let invariant = Entry.invariant (CilType.Exp.show inv) in + let entry = Entry.location_invariant ~task ~location ~invariant in + entry :: acc + ) acc invs + | `Bot | `Top -> (* TODO: 0 for bot (dead code)? *) acc - ) (Lazy.force location2nodes) entries + ) (Lazy.force location_nodes) entries ) else entries @@ -268,7 +275,7 @@ struct let entries = if entry_type_enabled YamlWitnessType.LoopInvariant.entry_type then ( LH.fold (fun loc ns acc -> - if WitnessInvariant.emit_loop_head && List.exists WitnessInvariant.is_loop_head_node ns then ( + if WitnessInvariant.emit_loop_head then ( (* TODO: remove double condition? *) let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) @@ -290,7 +297,7 @@ struct ) else acc - ) (Lazy.force location2nodes) entries + ) (Lazy.force loop_nodes) entries ) else entries @@ -430,30 +437,26 @@ struct let invariants = if invariant_type_enabled YamlWitnessType.InvariantSet.LocationInvariant.invariant_type then ( LH.fold (fun loc ns acc -> - if List.exists WitnessInvariant.is_invariant_node ns then ( - let inv = List.fold_left (fun acc n -> - let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in - let lvals = local_lvals n local in - Invariant.(acc || R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals})) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) - ) (Invariant.bot ()) ns - in - match inv with - | `Lifted inv -> - let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *) - let location_function = fundec.svar.vname in - let location = Entry.location ~location:loc ~location_function in - let invs = WitnessUtil.InvariantExp.process_exp inv in - List.fold_left (fun acc inv -> - let invariant = CilType.Exp.show inv in - let invariant = Entry.location_invariant' ~location ~invariant in - invariant :: acc - ) acc invs - | `Bot | `Top -> (* TODO: 0 for bot (dead code)? *) - acc - ) - else + let inv = List.fold_left (fun acc n -> + let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in + let lvals = local_lvals n local in + Invariant.(acc || R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals})) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) + ) (Invariant.bot ()) ns + in + match inv with + | `Lifted inv -> + let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *) + let location_function = fundec.svar.vname in + let location = Entry.location ~location:loc ~location_function in + let invs = WitnessUtil.InvariantExp.process_exp inv in + List.fold_left (fun acc inv -> + let invariant = CilType.Exp.show inv in + let invariant = Entry.location_invariant' ~location ~invariant in + invariant :: acc + ) acc invs + | `Bot | `Top -> (* TODO: 0 for bot (dead code)? *) acc - ) (Lazy.force location2nodes) invariants + ) (Lazy.force location_nodes) invariants ) else invariants @@ -463,7 +466,7 @@ struct let invariants = if invariant_type_enabled YamlWitnessType.InvariantSet.LoopInvariant.invariant_type then ( LH.fold (fun loc ns acc -> - if WitnessInvariant.emit_loop_head && List.exists WitnessInvariant.is_loop_head_node ns then ( + if WitnessInvariant.emit_loop_head then ( (* TODO: remove double condition? *) let inv = List.fold_left (fun acc n -> let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *) @@ -485,7 +488,7 @@ struct ) else acc - ) (Lazy.force location2nodes) invariants + ) (Lazy.force loop_nodes) invariants ) else invariants @@ -562,14 +565,16 @@ struct } let validate () = - let locator = Locator.create () in + let location_locator = Locator.create () in let loop_locator = Locator.create () in + (* TODO: add all CFG nodes, not just live ones from lh, like UnassumeAnalysis *) LHT.iter (fun ((n, _) as lvar) _ -> - let loc = Node.location n in - if WitnessInvariant.is_invariant_node n then - Locator.add locator loc lvar; - if WitnessInvariant.is_loop_head_node n then - Locator.add loop_locator loc lvar + Option.iter (fun loc -> + Locator.add location_locator loc lvar + ) (WitnessInvariant.location_location n); + Option.iter (fun loc -> + Locator.add loop_locator loc lvar + ) (WitnessInvariant.loop_location n) ) lh; let inv_parser = InvariantParser.create FileCfg.file in @@ -663,7 +668,7 @@ struct None in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some lvars -> validate_lvars_invariant ~entry_certificate ~loc ~lvars inv | None -> @@ -703,7 +708,7 @@ struct in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some lvars -> begin match InvariantParser.parse_cabs pre with | Ok pre_cabs -> @@ -754,7 +759,7 @@ struct let loc = loc_of_location location_invariant.location in let inv = location_invariant.value in - match Locator.find_opt locator loc with + match Locator.find_opt location_locator loc with | Some lvars -> ignore (validate_lvars_invariant ~entry_certificate:None ~loc ~lvars inv) | None -> From edfd0bcafad1fcbb4a38eedb6e8aee85cb8ef86d Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 12:44:47 +0200 Subject: [PATCH 27/40] Fix most YAML witness tests with new locations --- tests/regression/56-witness/10-apron-unassume-interval.c | 2 +- .../regression/56-witness/10-apron-unassume-interval.yml | 8 ++++---- tests/regression/56-witness/11-base-unassume-interval.c | 2 +- tests/regression/56-witness/11-base-unassume-interval.yml | 8 ++++---- tests/regression/56-witness/20-apron-unassume-global.c | 2 +- tests/regression/56-witness/20-apron-unassume-global.yml | 8 ++++---- tests/regression/56-witness/26-mine-tutorial-ex4.6.c | 2 +- tests/regression/56-witness/26-mine-tutorial-ex4.6.yml | 4 ++-- tests/regression/56-witness/27-mine-tutorial-ex4.7.c | 2 +- tests/regression/56-witness/27-mine-tutorial-ex4.7.yml | 6 +++--- tests/regression/56-witness/28-mine-tutorial-ex4.8.c | 2 +- tests/regression/56-witness/28-mine-tutorial-ex4.8.yml | 4 ++-- tests/regression/56-witness/29-mine-tutorial-ex4.10.c | 2 +- tests/regression/56-witness/29-mine-tutorial-ex4.10.yml | 4 ++-- tests/regression/56-witness/35-hh-ex1b.yml | 6 +++--- tests/regression/56-witness/36-hh-ex2b.c | 2 +- tests/regression/56-witness/36-hh-ex2b.yml | 4 ++-- tests/regression/56-witness/38-bh-ex3.c | 2 +- tests/regression/56-witness/38-bh-ex3.yml | 4 ++-- tests/regression/56-witness/39-bh-ex-add.c | 2 +- tests/regression/56-witness/39-bh-ex-add.yml | 4 ++-- tests/regression/56-witness/41-as-hybrid.c | 2 +- tests/regression/56-witness/41-as-hybrid.yml | 4 ++-- tests/regression/56-witness/44-base-unassume-array.yml | 4 ++-- 24 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/regression/56-witness/10-apron-unassume-interval.c b/tests/regression/56-witness/10-apron-unassume-interval.c index e35d42d5636..1ee6117c611 100644 --- a/tests/regression/56-witness/10-apron-unassume-interval.c +++ b/tests/regression/56-witness/10-apron-unassume-interval.c @@ -3,7 +3,7 @@ // Using polyhedra instead of octagon, because the former has no narrowing and really needs the witness. int main() { int i = 0; - while (i < 100) { + while (i < 100) { // TODO: location invariant before loop doesn't work anymore i++; } assert(i == 100); diff --git a/tests/regression/56-witness/10-apron-unassume-interval.yml b/tests/regression/56-witness/10-apron-unassume-interval.yml index 12cc344957d..f7958922ae3 100644 --- a/tests/regression/56-witness/10-apron-unassume-interval.yml +++ b/tests/regression/56-witness/10-apron-unassume-interval.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 0a72f7b3-7826-4f68-bc7b-25425e95946e @@ -22,11 +22,11 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 100LL - (long long )i >= 0LL type: assertion format: C -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 4e078bcd-9e55-4874-a86e-0563927704a5 @@ -50,7 +50,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: (long long )i >= 0LL type: assertion format: C diff --git a/tests/regression/56-witness/11-base-unassume-interval.c b/tests/regression/56-witness/11-base-unassume-interval.c index bfecee5bbee..f8b685fcb1d 100644 --- a/tests/regression/56-witness/11-base-unassume-interval.c +++ b/tests/regression/56-witness/11-base-unassume-interval.c @@ -3,7 +3,7 @@ int main() { int i = 0; - while (i < 100) { + while (i < 100) { // TODO: location invariant before loop doesn't work anymore i++; } assert(i == 100); diff --git a/tests/regression/56-witness/11-base-unassume-interval.yml b/tests/regression/56-witness/11-base-unassume-interval.yml index bb4740c7b01..df939b7ca4b 100644 --- a/tests/regression/56-witness/11-base-unassume-interval.yml +++ b/tests/regression/56-witness/11-base-unassume-interval.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 0a72f7b3-7826-4f68-bc7b-25425e95946e @@ -22,11 +22,11 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 100LL - (long long )i >= 0LL type: assertion format: C -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 4e078bcd-9e55-4874-a86e-0563927704a5 @@ -50,7 +50,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: (long long )i >= 0LL type: assertion format: C diff --git a/tests/regression/56-witness/20-apron-unassume-global.c b/tests/regression/56-witness/20-apron-unassume-global.c index 6ad4146ba20..f8cdc63ba45 100644 --- a/tests/regression/56-witness/20-apron-unassume-global.c +++ b/tests/regression/56-witness/20-apron-unassume-global.c @@ -3,7 +3,7 @@ int i = 0; int main() { - while (i < 100) { + while (i < 100) { // TODO: location invariant before loop doesn't work anymore i++; } assert(i == 100); diff --git a/tests/regression/56-witness/20-apron-unassume-global.yml b/tests/regression/56-witness/20-apron-unassume-global.yml index 641adcac2b3..6f824d4f9f4 100644 --- a/tests/regression/56-witness/20-apron-unassume-global.yml +++ b/tests/regression/56-witness/20-apron-unassume-global.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 0a72f7b3-7826-4f68-bc7b-25425e95946e @@ -22,11 +22,11 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 100LL - (long long )i >= 0LL type: assertion format: C -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 4e078bcd-9e55-4874-a86e-0563927704a5 @@ -50,7 +50,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: (long long )i >= 0LL type: assertion format: C diff --git a/tests/regression/56-witness/26-mine-tutorial-ex4.6.c b/tests/regression/56-witness/26-mine-tutorial-ex4.6.c index d497c6344a6..129f7e809a5 100644 --- a/tests/regression/56-witness/26-mine-tutorial-ex4.6.c +++ b/tests/regression/56-witness/26-mine-tutorial-ex4.6.c @@ -2,7 +2,7 @@ #include int main() { int x = 40; - while (x != 0) { + while (x != 0) { // TODO: location invariant before loop doesn't work anymore __goblint_check(x <= 40); x--; __goblint_check(x >= 0); diff --git a/tests/regression/56-witness/26-mine-tutorial-ex4.6.yml b/tests/regression/56-witness/26-mine-tutorial-ex4.6.yml index 2e3c6758fcb..659537ba77c 100644 --- a/tests/regression/56-witness/26-mine-tutorial-ex4.6.yml +++ b/tests/regression/56-witness/26-mine-tutorial-ex4.6.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 0e84a9de-b9f6-44dd-ab8d-ebdeca941482 @@ -21,7 +21,7 @@ line: 5 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= x && x <= 40 type: assertion format: C diff --git a/tests/regression/56-witness/27-mine-tutorial-ex4.7.c b/tests/regression/56-witness/27-mine-tutorial-ex4.7.c index 10f83ba6e28..2589c596b86 100644 --- a/tests/regression/56-witness/27-mine-tutorial-ex4.7.c +++ b/tests/regression/56-witness/27-mine-tutorial-ex4.7.c @@ -3,7 +3,7 @@ extern _Bool __VERIFIER_nondet_bool(); int main() { int x = 0; - while (__VERIFIER_nondet_bool() == 0) { + while (__VERIFIER_nondet_bool() == 0) { // TODO: location invariant before loop doesn't work anymore __goblint_check(0 <= x); __goblint_check(x <= 40); if (__VERIFIER_nondet_bool() == 0) { diff --git a/tests/regression/56-witness/27-mine-tutorial-ex4.7.yml b/tests/regression/56-witness/27-mine-tutorial-ex4.7.yml index ad4c2872272..c87b070d40b 100644 --- a/tests/regression/56-witness/27-mine-tutorial-ex4.7.yml +++ b/tests/regression/56-witness/27-mine-tutorial-ex4.7.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: e17f9860-95af-4213-a767-ab4876ead27e @@ -21,9 +21,9 @@ file_name: 27-mine-tutorial-ex4.7.c file_hash: 4d06e38718d405171bd503e630f6c7a247bb3b0d3c1c6c951466e4989883b43c line: 6 - column: 8 + column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= x && x <= 40 type: assertion format: C diff --git a/tests/regression/56-witness/28-mine-tutorial-ex4.8.c b/tests/regression/56-witness/28-mine-tutorial-ex4.8.c index 6892267fc80..b2881cdfa67 100644 --- a/tests/regression/56-witness/28-mine-tutorial-ex4.8.c +++ b/tests/regression/56-witness/28-mine-tutorial-ex4.8.c @@ -3,7 +3,7 @@ extern _Bool __VERIFIER_nondet_bool(); int main() { int v = 0; - while (__VERIFIER_nondet_bool() == 0) { + while (__VERIFIER_nondet_bool() == 0) { // TODO: location invariant before loop doesn't work anymore __goblint_check(0 <= v); __goblint_check(v <= 1); if (v == 0) diff --git a/tests/regression/56-witness/28-mine-tutorial-ex4.8.yml b/tests/regression/56-witness/28-mine-tutorial-ex4.8.yml index 69479e6df00..c92f0223e41 100644 --- a/tests/regression/56-witness/28-mine-tutorial-ex4.8.yml +++ b/tests/regression/56-witness/28-mine-tutorial-ex4.8.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 299c2080-fb13-4879-be2b-5d2758465577 @@ -23,7 +23,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= v && v <= 1 type: assertion format: C diff --git a/tests/regression/56-witness/29-mine-tutorial-ex4.10.c b/tests/regression/56-witness/29-mine-tutorial-ex4.10.c index 655c19e08e1..437e20130cd 100644 --- a/tests/regression/56-witness/29-mine-tutorial-ex4.10.c +++ b/tests/regression/56-witness/29-mine-tutorial-ex4.10.c @@ -3,7 +3,7 @@ #include int main() { int v = 1; // Not explicitly stated in Miné's example - while (v <= 50) { + while (v <= 50) { // TODO: location invariant before loop doesn't work anymore __goblint_check(1 <= v); v += 2; __goblint_check(v <= 52); diff --git a/tests/regression/56-witness/29-mine-tutorial-ex4.10.yml b/tests/regression/56-witness/29-mine-tutorial-ex4.10.yml index 0f9b3622900..c719c76c0a5 100644 --- a/tests/regression/56-witness/29-mine-tutorial-ex4.10.yml +++ b/tests/regression/56-witness/29-mine-tutorial-ex4.10.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: f04fe372-3d6e-4a80-9567-80c64bd7fd03 @@ -24,7 +24,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 1 <= v && v <= 52 type: assertion format: C diff --git a/tests/regression/56-witness/35-hh-ex1b.yml b/tests/regression/56-witness/35-hh-ex1b.yml index 9763960fd7e..084c71cc975 100644 --- a/tests/regression/56-witness/35-hh-ex1b.yml +++ b/tests/regression/56-witness/35-hh-ex1b.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 1a354f1e-76e8-40e9-808a-8d5efbe35496 @@ -21,9 +21,9 @@ file_name: 35-hh-ex1b.c file_hash: 9fe07d5f950140350848bae4342d9d1b7c6c9f625f6985746089a36a37243600 line: 7 - column: 2 + column: 4 function: main - location_invariant: + loop_invariant: string: 0 <= i && i <= 99 type: assertion format: C diff --git a/tests/regression/56-witness/36-hh-ex2b.c b/tests/regression/56-witness/36-hh-ex2b.c index f8d35f28bdf..41c5fcf71eb 100644 --- a/tests/regression/56-witness/36-hh-ex2b.c +++ b/tests/regression/56-witness/36-hh-ex2b.c @@ -3,7 +3,7 @@ extern _Bool __VERIFIER_nondet_bool(); int main() { int n = 0; - while (1) { + while (1) { // TODO: location invariant before loop doesn't work anymore __goblint_check(n <= 60); if (__VERIFIER_nondet_bool()) { if (n < 60) { diff --git a/tests/regression/56-witness/36-hh-ex2b.yml b/tests/regression/56-witness/36-hh-ex2b.yml index 69e0a888414..d2a7218a287 100644 --- a/tests/regression/56-witness/36-hh-ex2b.yml +++ b/tests/regression/56-witness/36-hh-ex2b.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 9589b9d4-edce-4043-8413-279703946762 @@ -23,7 +23,7 @@ line: 6 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= n && n <= 60 type: assertion format: C diff --git a/tests/regression/56-witness/38-bh-ex3.c b/tests/regression/56-witness/38-bh-ex3.c index 633394586f5..2a5d07fc1e5 100644 --- a/tests/regression/56-witness/38-bh-ex3.c +++ b/tests/regression/56-witness/38-bh-ex3.c @@ -4,7 +4,7 @@ extern _Bool __VERIFIER_nondet_bool(); int main() { int m = 0; int n = 0; - while (1) { + while (1) { // TODO: location invariant before loop doesn't work anymore __goblint_check(m <= 60); __goblint_check(n <= 60); if (__VERIFIER_nondet_bool()) { diff --git a/tests/regression/56-witness/38-bh-ex3.yml b/tests/regression/56-witness/38-bh-ex3.yml index d1f6677fbbe..2e489e1f174 100644 --- a/tests/regression/56-witness/38-bh-ex3.yml +++ b/tests/regression/56-witness/38-bh-ex3.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: bd436e09-244f-45db-a5f4-9337ca997424 @@ -23,7 +23,7 @@ line: 7 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= m && m <= 60 && 0 <= n && n <= 60 type: assertion format: C diff --git a/tests/regression/56-witness/39-bh-ex-add.c b/tests/regression/56-witness/39-bh-ex-add.c index 256e274b737..630ef344a4e 100644 --- a/tests/regression/56-witness/39-bh-ex-add.c +++ b/tests/regression/56-witness/39-bh-ex-add.c @@ -4,7 +4,7 @@ extern _Bool __VERIFIER_nondet_bool(); int main() { int m = 0; int n = 0; - while (1) { + while (1) { // TODO: location invariant before loop doesn't work anymore __goblint_check(m <= 60); __goblint_check(n <= 60); if (__VERIFIER_nondet_bool()) { diff --git a/tests/regression/56-witness/39-bh-ex-add.yml b/tests/regression/56-witness/39-bh-ex-add.yml index 84aa374c1eb..29d30062764 100644 --- a/tests/regression/56-witness/39-bh-ex-add.yml +++ b/tests/regression/56-witness/39-bh-ex-add.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: bd436e09-244f-45db-a5f4-9337ca997424 @@ -23,7 +23,7 @@ line: 7 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= m && m <= 60 && 0 <= n && n <= 60 type: assertion format: C diff --git a/tests/regression/56-witness/41-as-hybrid.c b/tests/regression/56-witness/41-as-hybrid.c index 77351870369..3a3a4c6ea62 100644 --- a/tests/regression/56-witness/41-as-hybrid.c +++ b/tests/regression/56-witness/41-as-hybrid.c @@ -2,7 +2,7 @@ #include int main() { int i = 0; - while (1) { + while (1) { // TODO: location invariant before loop doesn't work anymore i++; int j = 0; while (j < 10) { diff --git a/tests/regression/56-witness/41-as-hybrid.yml b/tests/regression/56-witness/41-as-hybrid.yml index 0e810b6acaa..8eac9f75f7d 100644 --- a/tests/regression/56-witness/41-as-hybrid.yml +++ b/tests/regression/56-witness/41-as-hybrid.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 71b761c6-4f85-405e-8ee6-9a3a8f743513 @@ -23,7 +23,7 @@ line: 5 column: 2 function: main - location_invariant: + loop_invariant: string: 0 <= i && i <= 9 type: assertion format: C diff --git a/tests/regression/56-witness/44-base-unassume-array.yml b/tests/regression/56-witness/44-base-unassume-array.yml index dbf7fb8e545..ad2e3a3ad21 100644 --- a/tests/regression/56-witness/44-base-unassume-array.yml +++ b/tests/regression/56-witness/44-base-unassume-array.yml @@ -21,7 +21,7 @@ file_name: 44-base-unassume-array.c file_hash: 9d9dc013c8d8aee483852aa73d0b4ac48ee7ea0f5433dc86ee28c3fe54c49726 line: 7 - column: 6 + column: 2 function: main loop_invariant: string: 0 <= a[(long )"all_index"] @@ -50,7 +50,7 @@ file_name: 44-base-unassume-array.c file_hash: 9d9dc013c8d8aee483852aa73d0b4ac48ee7ea0f5433dc86ee28c3fe54c49726 line: 7 - column: 6 + column: 2 function: main loop_invariant: string: a[(long )"all_index"] < 3 From 9ddac1bb979b260adfb0247deb6d4f84249829b5 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 13:02:40 +0200 Subject: [PATCH 28/40] Make YAML precondition_loop_invariant only match loops, not all locations --- src/analyses/unassumeAnalysis.ml | 2 +- src/witness/yamlWitness.ml | 83 ++++++++++--------- .../14-base-unassume-precondition.c | 2 +- .../14-base-unassume-precondition.yml | 4 +- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/analyses/unassumeAnalysis.ml b/src/analyses/unassumeAnalysis.ml index 86db81e86bd..58ac1d06ea3 100644 --- a/src/analyses/unassumeAnalysis.ml +++ b/src/analyses/unassumeAnalysis.ml @@ -193,7 +193,7 @@ struct let inv = precondition_loop_invariant.loop_invariant.string in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt location_locator loc with + match Locator.find_opt loop_locator loc with | Some nodes -> unassume_precondition_nodes_invariant ~loc ~nodes pre inv | None -> diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index 028b9deee0b..3eefe5c5471 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -328,11 +328,11 @@ struct entries in - (* Generate precondition invariants. + (* Generate precondition loop invariants. We do this in three steps: 1. Collect contexts for each function 2. For each function context, find "matching"/"weaker" contexts that may satisfy its invariant - 3. Generate precondition invariants. The postcondition is a disjunction over the invariants for matching states. *) + 3. Generate precondition loop invariants. The postcondition is a disjunction over the invariants for matching states. *) let entries = if entry_type_enabled YamlWitnessType.PreconditionLoopInvariant.entry_type then ( (* 1. Collect contexts for each function *) @@ -380,47 +380,48 @@ struct (* 3. Generate precondition invariants *) LHT.fold (fun ((n, c) as lvar) local acc -> - if WitnessInvariant.is_invariant_node n then ( + match WitnessInvariant.loop_location n with + | Some loc -> let fundec = Node.find_fundec n in let pre_lvar = (Node.FunctionEntry fundec, c) in let query = Queries.Invariant Invariant.default_context in - match R.ask_local pre_lvar query with - | `Lifted c_inv -> - let loc = Node.location n in - (* Find unknowns for which the preceding start state satisfies the precondtion *) - let xs = find_matching_states lvar in - - (* Generate invariants. Give up in case one invariant could not be generated. *) - let invs = GobList.fold_while_some (fun acc local -> - let lvals = local_lvals n local in - match R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals}) with - | `Lifted c -> Some ((`Lifted c)::acc) - | `Bot | `Top -> None - ) [] xs - in - begin match invs with - | None - | Some [] -> acc - | Some (x::xs) -> - begin match List.fold_left (fun acc inv -> Invariant.(acc || inv) [@coverage off]) x xs with (* bisect_ppx cannot handle redefined (||) *) - | `Lifted inv -> - let invs = WitnessUtil.InvariantExp.process_exp inv in - let c_inv = InvariantCil.exp_replace_original_name c_inv in (* cannot be split *) - List.fold_left (fun acc inv -> - let location_function = (Node.find_fundec n).svar.vname in - let location = Entry.location ~location:loc ~location_function in - let precondition = Entry.invariant (CilType.Exp.show c_inv) in - let invariant = Entry.invariant (CilType.Exp.show inv) in - let entry = Entry.precondition_loop_invariant ~task ~location ~precondition ~invariant in - entry :: acc - ) acc invs - | `Bot | `Top -> acc - end - end - | _ -> (* Do not construct precondition invariants if we cannot express precondition *) - acc - ) - else + begin match R.ask_local pre_lvar query with + | `Lifted c_inv -> + let loc = Node.location n in + (* Find unknowns for which the preceding start state satisfies the precondtion *) + let xs = find_matching_states lvar in + + (* Generate invariants. Give up in case one invariant could not be generated. *) + let invs = GobList.fold_while_some (fun acc local -> + let lvals = local_lvals n local in + match R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals}) with + | `Lifted c -> Some ((`Lifted c)::acc) + | `Bot | `Top -> None + ) [] xs + in + begin match invs with + | None + | Some [] -> acc + | Some (x::xs) -> + begin match List.fold_left (fun acc inv -> Invariant.(acc || inv) [@coverage off]) x xs with (* bisect_ppx cannot handle redefined (||) *) + | `Lifted inv -> + let invs = WitnessUtil.InvariantExp.process_exp inv in + let c_inv = InvariantCil.exp_replace_original_name c_inv in (* cannot be split *) + List.fold_left (fun acc inv -> + let location_function = (Node.find_fundec n).svar.vname in + let location = Entry.location ~location:loc ~location_function in + let precondition = Entry.invariant (CilType.Exp.show c_inv) in + let invariant = Entry.invariant (CilType.Exp.show inv) in + let entry = Entry.precondition_loop_invariant ~task ~location ~precondition ~invariant in + entry :: acc + ) acc invs + | `Bot | `Top -> acc + end + end + | _ -> (* Do not construct precondition invariants if we cannot express precondition *) + acc + end + | None -> acc ) lh entries ) @@ -708,7 +709,7 @@ struct in let msgLoc: M.Location.t = CilLocation loc in - match Locator.find_opt location_locator loc with + match Locator.find_opt loop_locator loc with | Some lvars -> begin match InvariantParser.parse_cabs pre with | Ok pre_cabs -> diff --git a/tests/regression/56-witness/14-base-unassume-precondition.c b/tests/regression/56-witness/14-base-unassume-precondition.c index 8e6a1b3c73a..23b2d8b9231 100644 --- a/tests/regression/56-witness/14-base-unassume-precondition.c +++ b/tests/regression/56-witness/14-base-unassume-precondition.c @@ -3,7 +3,7 @@ void foo(int n) { int i = 0; - while (i < n) { + while (i < n) { // TODO: (precondition) location invariant before loop doesn't work anymore i++; } assert(i == n); diff --git a/tests/regression/56-witness/14-base-unassume-precondition.yml b/tests/regression/56-witness/14-base-unassume-precondition.yml index df4bbc8dc73..2d84e4ea9ff 100644 --- a/tests/regression/56-witness/14-base-unassume-precondition.yml +++ b/tests/regression/56-witness/14-base-unassume-precondition.yml @@ -1,4 +1,4 @@ -- entry_type: location_invariant +- entry_type: loop_invariant metadata: format_version: "0.1" uuid: 26e6d2de-13a6-4610-9b08-ee3d9e6b9338 @@ -21,7 +21,7 @@ line: 6 column: 2 function: foo - location_invariant: + loop_invariant: string: 0 <= i type: assertion format: C From 02bba9350b61590653b87a89e79b68c7fd905ba1 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 14:50:18 +0200 Subject: [PATCH 29/40] Fix get_stmtLoc for GobView syntactic/semantic search --- src/framework/control.ml | 17 ++++++++++------- src/transform/expressionEvaluation.ml | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/framework/control.ml b/src/framework/control.ml index 65350346285..e11cee92681 100644 --- a/src/framework/control.ml +++ b/src/framework/control.ml @@ -625,13 +625,16 @@ struct let node_values = LHT.enum lh |> map (Tuple2.map1 fst) in (* drop context from key *) let hashtbl_size = if fast_count node_values then count node_values else 123 in let by_loc, by_node = Hashtbl.create hashtbl_size, NodeH.create hashtbl_size in - node_values |> iter (fun (node, v) -> - let loc = Node.location node in - (* join values once for the same location and once for the same node *) - let join = Option.some % function None -> v | Some v' -> Spec.D.join v v' in - Hashtbl.modify_opt loc join by_loc; - NodeH.modify_opt node join by_node; - ); + iter (fun (node, v) -> + let loc = match node with + | Statement s -> Cil.get_stmtLoc s.skind (* nosemgrep: cilfacade *) (* Must use CIL's because syntactic search is in CIL. *) + | FunctionEntry _ | Function _ -> Node.location node + in + (* join values once for the same location and once for the same node *) + let join = Option.some % function None -> v | Some v' -> Spec.D.join v v' in + Hashtbl.modify_opt loc join by_loc; + NodeH.modify_opt node join by_node; + ) node_values; by_loc, by_node in diff --git a/src/transform/expressionEvaluation.ml b/src/transform/expressionEvaluation.ml index 0cf59f0c787..88b273ab6dd 100644 --- a/src/transform/expressionEvaluation.ml +++ b/src/transform/expressionEvaluation.ml @@ -68,7 +68,7 @@ struct (* Take all statements *) |> List.concat_map (fun (f : Cil.fundec) -> f.sallstmts |> List.map (fun s -> f, s)) (* Add locations *) - |> List.map (fun (f, (s : Cil.stmt)) -> (Cilfacade.get_stmtLoc s, f, s)) + |> List.map (fun (f, (s : Cil.stmt)) -> (Cil.get_stmtLoc s.skind, f, s)) (* nosemgrep: cilfacade *) (* Must use CIL's because syntactic search is in CIL. *) (* Filter artificial ones by impossible location *) |> List.filter (fun ((l : Cil.location), _, _) -> l.line >= 0) (* Create hash table *) @@ -109,7 +109,7 @@ struct fun (s : Cil.stmt) -> succeeding_statement := Some s; (* Evaluate at (directly before) a succeeding location *) - Some(self#try_ask (Cilfacade.get_stmtLoc s) expression) + Some(self#try_ask (Cil.get_stmtLoc s.skind) expression) (* nosemgrep: cilfacade *) (* Must use CIL's because syntactic search is in CIL. *) end statement.succs with Not_found -> None From 0bf0407c694ef37ccda5b5fd238271ed8fef80f8 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 28 Feb 2024 15:46:03 +0200 Subject: [PATCH 30/40] Check YAML witness and loop unrolling incompatibility --- conf/svcomp.json | 1 - src/maingoblint.ml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/svcomp.json b/conf/svcomp.json index 7e30554cebe..97bdf89cd3f 100644 --- a/conf/svcomp.json +++ b/conf/svcomp.json @@ -84,7 +84,6 @@ "congruence", "octagon", "wideningThresholds", - "loopUnrollHeuristic", "memsafetySpecification", "termination", "tmpSpecialAnalysis" diff --git a/src/maingoblint.ml b/src/maingoblint.ml index 7fdb7a4a134..dcff1132166 100644 --- a/src/maingoblint.ml +++ b/src/maingoblint.ml @@ -145,6 +145,8 @@ let check_arguments () = if get_bool "ana.autotune.enabled" && get_bool "incremental.load" then (set_bool "ana.autotune.enabled" false; warn "ana.autotune.enabled implicitly disabled by incremental.load"); if get_bool "exp.basic-blocks" && not (get_bool "justcil") && List.mem "assert" @@ get_string_list "trans.activated" then (set_bool "exp.basic-blocks" false; warn "The option exp.basic-blocks implicitely disabled by activating the \"assert\" tranformation."); if (not @@ get_bool "witness.invariant.all-locals") && (not @@ get_bool "cil.addNestedScopeAttr") then (set_bool "cil.addNestedScopeAttr" true; warn "Disabling witness.invariant.all-locals implicitly enables cil.addNestedScopeAttr."); + if (get_int "exp.unrolling-factor" > 0 || AutoTune0.isActivated "loopUnrollHeuristic") && (get_bool "witness.yaml.enabled" || get_string "witness.yaml.validate" <> "" || get_string "witness.yaml.unassume" <> "") then + fail "YAML witnesses are incompatible with syntactic loop unrolling (https://github.com/goblint/analyzer/pull/1370)."; if List.mem "remove_dead_code" @@ get_string_list "trans.activated" then ( (* 'assert' transform happens before 'remove_dead_code' transform *) ignore @@ List.fold_left From da6987d474fe402ace4bc244b0e68ea89c9984a2 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 16:53:02 +0200 Subject: [PATCH 31/40] Deduplicate YAML witness tests from CFG tests --- tests/regression/cfg/issue-1356.t/run.t | 14 +++ tests/regression/cfg/pr-758.t/run.t | 121 +++++++++++++++++++++ tests/regression/issue-1356.t/issue-1356.c | 20 ---- tests/regression/issue-1356.t/run.t | 12 -- tests/regression/pr-758.t/pr-758.c | 22 ---- tests/regression/pr-758.t/run.t | 119 -------------------- 6 files changed, 135 insertions(+), 173 deletions(-) delete mode 100644 tests/regression/issue-1356.t/issue-1356.c delete mode 100644 tests/regression/issue-1356.t/run.t delete mode 100644 tests/regression/pr-758.t/pr-758.c delete mode 100644 tests/regression/pr-758.t/run.t diff --git a/tests/regression/cfg/issue-1356.t/run.t b/tests/regression/cfg/issue-1356.t/run.t index 78a81aff686..416eadea95e 100644 --- a/tests/regression/cfg/issue-1356.t/run.t +++ b/tests/regression/cfg/issue-1356.t/run.t @@ -76,3 +76,17 @@ ┌─────────────────────────────────────────┐ │ return of minus() │ └─────────────────────────────────────────┘ + + + $ goblint --enable ana.sv-comp.functions --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant"]' issue-1356.c + [Warning][Integer > Overflow][CWE-190] Signed integer overflow (issue-1356.c:10:3-10:53) + [Warning][Integer > Overflow][CWE-190][CWE-191] Signed integer overflow and underflow (issue-1356.c:11:3-11:15) + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 13 + dead: 0 + total lines: 13 + [Info][Witness] witness generation summary: + total generation entries: 0 + + $ yamlWitnessStrip < witness.yml + [] diff --git a/tests/regression/cfg/pr-758.t/run.t b/tests/regression/cfg/pr-758.t/run.t index d87d9128c7a..23eaa2ae391 100644 --- a/tests/regression/cfg/pr-758.t/run.t +++ b/tests/regression/cfg/pr-758.t/run.t @@ -69,3 +69,124 @@ ┌────────────────────────────────────┐ │ return of main() │ └────────────────────────────────────┘ + + + $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["loop_invariant", "location_invariant"]' pr-758.c + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 6 + dead: 0 + total lines: 6 + [Info][Witness] witness generation summary: + total generation entries: 10 + + $ yamlWitnessStrip < witness.yml + - entry_type: loop_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 6 + column: 2 + function: main + loop_invariant: + string: (0 <= x && (x <= 9 || x <= 10)) + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: i == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: a.kaal == 2 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 21 + column: 2 + function: main + location_invariant: + string: a.hind == 3 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 20 + column: 2 + function: main + location_invariant: + string: i == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: pr-758.c + file_hash: $FILE_HASH + line: 12 + column: 2 + function: main + location_invariant: + string: x == 10 + type: assertion + format: C diff --git a/tests/regression/issue-1356.t/issue-1356.c b/tests/regression/issue-1356.t/issue-1356.c deleted file mode 100644 index b773f6cf668..00000000000 --- a/tests/regression/issue-1356.t/issue-1356.c +++ /dev/null @@ -1,20 +0,0 @@ -extern int __VERIFIER_nondet_int(void); - -extern void abort(void); -void assume_abort_if_not(int cond) { - if(!cond) {abort();} -} - -int minus(int a, int b) { - assume_abort_if_not(b <= 0 || a >= b - 2147483648); // there shouldn't be invariants 1 <= b and b != 0 before this line - assume_abort_if_not(b >= 0 || a <= b + 2147483647); // there shouldn't be invariants b <= -1 and b != 0 before this line - return a - b; -} - -int main() { - int x, y; - x = __VERIFIER_nondet_int(); - y = __VERIFIER_nondet_int(); - minus(x, y); - return 0; -} diff --git a/tests/regression/issue-1356.t/run.t b/tests/regression/issue-1356.t/run.t deleted file mode 100644 index 7765c02b8d0..00000000000 --- a/tests/regression/issue-1356.t/run.t +++ /dev/null @@ -1,12 +0,0 @@ - $ goblint --enable ana.sv-comp.functions --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant"]' issue-1356.c - [Warning][Integer > Overflow][CWE-190] Signed integer overflow (issue-1356.c:10:3-10:53) - [Warning][Integer > Overflow][CWE-190][CWE-191] Signed integer overflow and underflow (issue-1356.c:11:3-11:15) - [Info][Deadcode] Logical lines of code (LLoC) summary: - live: 13 - dead: 0 - total lines: 13 - [Info][Witness] witness generation summary: - total generation entries: 0 - - $ yamlWitnessStrip < witness.yml - [] diff --git a/tests/regression/pr-758.t/pr-758.c b/tests/regression/pr-758.t/pr-758.c deleted file mode 100644 index 87aa41889d6..00000000000 --- a/tests/regression/pr-758.t/pr-758.c +++ /dev/null @@ -1,22 +0,0 @@ -// Code from https://github.com/goblint/cil/pull/98 - -int main() { - // for loop - int x = 42; - for (x = 0; x < 10; x++) { // there shouldn't be invariants x <= 9, x <= 10 and 0 <= x before this line - // ... - } - - // expression with side effect - int i, k; - i = k = 0; // there shouldn't be invariant k == 0 before this line - - // compound initializers - struct kala { - int kaal; - int hind; - }; - - struct kala a = {2, 3}; // there shouldn't be invariant a.kaal == 2 before this line - return 0; -} diff --git a/tests/regression/pr-758.t/run.t b/tests/regression/pr-758.t/run.t deleted file mode 100644 index 23c327aeb2f..00000000000 --- a/tests/regression/pr-758.t/run.t +++ /dev/null @@ -1,119 +0,0 @@ - $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["loop_invariant", "location_invariant"]' pr-758.c - [Info][Deadcode] Logical lines of code (LLoC) summary: - live: 6 - dead: 0 - total lines: 6 - [Info][Witness] witness generation summary: - total generation entries: 10 - - $ yamlWitnessStrip < witness.yml - - entry_type: loop_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 6 - column: 2 - function: main - loop_invariant: - string: (0 <= x && (x <= 9 || x <= 10)) - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 21 - column: 2 - function: main - location_invariant: - string: x == 10 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 21 - column: 2 - function: main - location_invariant: - string: k == 0 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 21 - column: 2 - function: main - location_invariant: - string: i == 0 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 21 - column: 2 - function: main - location_invariant: - string: a.kaal == 2 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 21 - column: 2 - function: main - location_invariant: - string: a.hind == 3 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 20 - column: 2 - function: main - location_invariant: - string: x == 10 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 20 - column: 2 - function: main - location_invariant: - string: k == 0 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 20 - column: 2 - function: main - location_invariant: - string: i == 0 - type: assertion - format: C - - entry_type: location_invariant - location: - file_name: pr-758.c - file_hash: $FILE_HASH - line: 12 - column: 2 - function: main - location_invariant: - string: x == 10 - type: assertion - format: C From 78b8037e97eeaab3c1bc7512ae107199c87c8542 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:21:15 +0200 Subject: [PATCH 32/40] Adapt 56-witness/05-prec-problem to correct precondition_loop_invariant handling --- tests/regression/56-witness/05-prec-problem.c | 3 +- tests/regression/56-witness/05-prec-problem.t | 39 +++---------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/tests/regression/56-witness/05-prec-problem.c b/tests/regression/56-witness/05-prec-problem.c index 276adec0938..08c665ce127 100644 --- a/tests/regression/56-witness/05-prec-problem.c +++ b/tests/regression/56-witness/05-prec-problem.c @@ -9,7 +9,8 @@ int foo(int* ptr1, int* ptr2){ } else { result = 1; } - // cram test checks for precondition invariant soundness + + while (0); // cram test checks for precondition invariant soundness return result; } diff --git a/tests/regression/56-witness/05-prec-problem.t b/tests/regression/56-witness/05-prec-problem.t index 829ddd1ab8b..25a3fc619f7 100644 --- a/tests/regression/56-witness/05-prec-problem.t +++ b/tests/regression/56-witness/05-prec-problem.t @@ -1,11 +1,12 @@ $ goblint --enable witness.yaml.enabled --enable ana.int.interval --set witness.yaml.entry-types '["precondition_loop_invariant"]' 05-prec-problem.c - [Success][Assert] Assertion "y != z" will succeed (05-prec-problem.c:21:5-21:28) + [Success][Assert] Assertion "y != z" will succeed (05-prec-problem.c:22:5-22:28) [Info][Deadcode] Logical lines of code (LLoC) summary: - live: 12 + live: 13 dead: 0 - total lines: 12 + total lines: 13 + [Warning][Deadcode][CWE-570] condition '0' (possibly inserted by CIL) is always false (05-prec-problem.c:13:12-13:13) [Info][Witness] witness generation summary: - total generation entries: 10 + total generation entries: 6 Witness shouldn't contain two unsound precondition_loop_invariant-s with precondition `*ptr1 == 5 && *ptr2 == 5`, and separately invariants `result == 0` and `result == 1`. @@ -57,33 +58,3 @@ The sound invariant is `result == 1 || result == 0`. string: '*ptr1 == 5 && *ptr2 == 5' type: assertion format: C - - entry_type: precondition_loop_invariant - location: - file_name: 05-prec-problem.c - file_hash: $FILE_HASH - line: 7 - column: 7 - function: foo - loop_invariant: - string: '*ptr2 == 5' - type: assertion - format: C - precondition: - string: '*ptr1 == 5 && *ptr2 == 5' - type: assertion - format: C - - entry_type: precondition_loop_invariant - location: - file_name: 05-prec-problem.c - file_hash: $FILE_HASH - line: 7 - column: 7 - function: foo - loop_invariant: - string: '*ptr1 == 5' - type: assertion - format: C - precondition: - string: '*ptr1 == 5 && *ptr2 == 5' - type: assertion - format: C From 61f94d099dbf9dc448f2451c64a6ba74144482bb Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:22:40 +0200 Subject: [PATCH 33/40] Fix invalid locations for precondition_loop_invariant Accidentally shadowed the right loc variable for the loop head. --- src/witness/yamlWitness.ml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/witness/yamlWitness.ml b/src/witness/yamlWitness.ml index 3eefe5c5471..c7694f67bee 100644 --- a/src/witness/yamlWitness.ml +++ b/src/witness/yamlWitness.ml @@ -387,7 +387,6 @@ struct let query = Queries.Invariant Invariant.default_context in begin match R.ask_local pre_lvar query with | `Lifted c_inv -> - let loc = Node.location n in (* Find unknowns for which the preceding start state satisfies the precondtion *) let xs = find_matching_states lvar in From 786affd4a0135df7a3221b31ceafed1f3fc8f12b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:24:37 +0200 Subject: [PATCH 34/40] Add TODO about duplicate precondition_loop_invariant entries --- tests/regression/56-witness/05-prec-problem.t | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/regression/56-witness/05-prec-problem.t b/tests/regression/56-witness/05-prec-problem.t index 25a3fc619f7..4c7dd02fa9a 100644 --- a/tests/regression/56-witness/05-prec-problem.t +++ b/tests/regression/56-witness/05-prec-problem.t @@ -8,6 +8,8 @@ [Info][Witness] witness generation summary: total generation entries: 6 +TODO: Don't generate duplicate entries from each context: should have generated just 3. + Witness shouldn't contain two unsound precondition_loop_invariant-s with precondition `*ptr1 == 5 && *ptr2 == 5`, and separately invariants `result == 0` and `result == 1`. The sound invariant is `result == 1 || result == 0`. From 07430d2c0f225449d5b40426c87e6747481981a9 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:27:29 +0200 Subject: [PATCH 35/40] Use yamlWitnessStrip for 56-witness/08-witness-all-locals --- .../56-witness/08-witness-all-locals.t | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/tests/regression/56-witness/08-witness-all-locals.t b/tests/regression/56-witness/08-witness-all-locals.t index 64ab0545498..bd7012ec257 100644 --- a/tests/regression/56-witness/08-witness-all-locals.t +++ b/tests/regression/56-witness/08-witness-all-locals.t @@ -6,7 +6,40 @@ [Info][Witness] witness generation summary: total generation entries: 3 -TODO: check witness.yml content with yamlWitnessStrip + $ yamlWitnessStrip < witness.yml + - entry_type: location_invariant + location: + file_name: 08-witness-all-locals.c + file_hash: $FILE_HASH + line: 9 + column: 2 + function: main + location_invariant: + string: y == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: 08-witness-all-locals.c + file_hash: $FILE_HASH + line: 9 + column: 2 + function: main + location_invariant: + string: x == 5 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: 08-witness-all-locals.c + file_hash: $FILE_HASH + line: 7 + column: 4 + function: main + location_invariant: + string: x == 5 + type: assertion + format: C Fewer entries are emitted if locals from nested block scopes are excluded: @@ -19,4 +52,26 @@ Fewer entries are emitted if locals from nested block scopes are excluded: [Info][Witness] witness generation summary: total generation entries: 2 -TODO: check witness.yml content with yamlWitnessStrip + $ yamlWitnessStrip < witness.yml + - entry_type: location_invariant + location: + file_name: 08-witness-all-locals.c + file_hash: $FILE_HASH + line: 9 + column: 2 + function: main + location_invariant: + string: x == 5 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: 08-witness-all-locals.c + file_hash: $FILE_HASH + line: 7 + column: 4 + function: main + location_invariant: + string: x == 5 + type: assertion + format: C From 5d98e2e2b1cba4bd12384c33903387f0e1b210cb Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:33:49 +0200 Subject: [PATCH 36/40] Add cram test for YAML witness unrolled loop invariant (issue #1225) --- .../55-loop-unrolling/11-unrolled-loop-invariant.c | 6 ++++++ .../55-loop-unrolling/11-unrolled-loop-invariant.t | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.c create mode 100644 tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t diff --git a/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.c b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.c new file mode 100644 index 00000000000..39e3cbce494 --- /dev/null +++ b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.c @@ -0,0 +1,6 @@ +int main() { + int i = 0; + while (i < 10) + i++; + return 0; +} diff --git a/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t new file mode 100644 index 00000000000..c46c468642d --- /dev/null +++ b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t @@ -0,0 +1,6 @@ + $ goblint --set lib.activated '[]' --set exp.unrolling-factor 5 --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant", "loop_invariant"]' 11-unrolled-loop-invariant.c + [Error] YAML witnesses are incompatible with syntactic loop unrolling (https://github.com/goblint/analyzer/pull/1370). + Fatal error: exception Failure("Option error") + [2] + +TODO: Fix loop unrolling with YAML witnesses: https://github.com/goblint/analyzer/pull/1370 From 71015ee5c5f0809fbd5449b2cfec6715d803b91f Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 29 Feb 2024 17:58:28 +0200 Subject: [PATCH 37/40] Add YAML witness location tests for loops --- tests/regression/cfg/foo.t/run.t | 156 ++++++++++ tests/regression/cfg/loops.t/run.t | 440 +++++++++++++++++++++++++++++ 2 files changed, 596 insertions(+) diff --git a/tests/regression/cfg/foo.t/run.t b/tests/regression/cfg/foo.t/run.t index ba7720d81fe..6dcb21863e3 100644 --- a/tests/regression/cfg/foo.t/run.t +++ b/tests/regression/cfg/foo.t/run.t @@ -57,3 +57,159 @@ │ YAML loc: foo.c:5:5-5:8 │ │ │ GraphML: true; server: true │ ─┘ └───────────────────────────────┘ + + $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant", "loop_invariant"]' --set sem.int.signed_overflow assume_none foo.c + [Warning][Integer > Overflow][CWE-190] Signed integer overflow (foo.c:4:5-4:8) + [Warning][Integer > Overflow][CWE-191] Signed integer underflow (foo.c:5:5-5:8) + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 6 + dead: 0 + total lines: 6 + [Warning][Deadcode][CWE-571] condition 'a > 0' (possibly inserted by CIL) is always true (foo.c:3:10-3:20) + [Info][Witness] witness generation summary: + total generation entries: 13 + + $ yamlWitnessStrip < witness.yml + - entry_type: loop_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 3 + column: 2 + function: main + loop_invariant: + string: b <= 1 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 3 + column: 2 + function: main + loop_invariant: + string: 1 <= a + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 7 + column: 2 + function: main + location_invariant: + string: b == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 7 + column: 2 + function: main + location_invariant: + string: a != 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 7 + column: 2 + function: main + location_invariant: + string: 1 <= a + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 5 + column: 4 + function: main + location_invariant: + string: b <= 1 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 5 + column: 4 + function: main + location_invariant: + string: b != 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 5 + column: 4 + function: main + location_invariant: + string: a != 1 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 5 + column: 4 + function: main + location_invariant: + string: 2 <= a + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 4 + column: 4 + function: main + location_invariant: + string: b <= 1 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 4 + column: 4 + function: main + location_invariant: + string: b != 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 4 + column: 4 + function: main + location_invariant: + string: a != 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: foo.c + file_hash: $FILE_HASH + line: 4 + column: 4 + function: main + location_invariant: + string: 1 <= a + type: assertion + format: C diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index bd9ec423075..febb255865e 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -187,4 +187,444 @@ │ │ └──────────────────────────────────────────────────────────────────────────────┘ + $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant", "loop_invariant"]' loops.c + [Success][Assert] Assertion "1" will succeed (loops.c:14:5-14:23) + [Success][Assert] Assertion "1" will succeed (loops.c:30:5-30:23) + [Success][Assert] Assertion "1" will succeed (loops.c:35:5-35:23) + [Info][Deadcode] Logical lines of code (LLoC) summary: + live: 18 + dead: 0 + total lines: 18 + [Info][Witness] witness generation summary: + total generation entries: 39 + $ yamlWitnessStrip < witness.yml + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 40 + column: 2 + function: main + loop_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 40 + column: 2 + function: main + loop_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 40 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 34 + column: 2 + function: main + loop_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 34 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 34 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 29 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 29 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 23 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 23 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 18 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 18 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 13 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 13 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 8 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 8 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 44 + column: 2 + function: main + location_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 44 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 41 + column: 4 + function: main + location_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 41 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 41 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 + column: 2 + function: main + location_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 35 + column: 4 + function: main + location_invariant: + string: j == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 35 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 35 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 34 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 30 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 30 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 28 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 24 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 24 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 23 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 18 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 14 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 14 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 13 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 9 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 9 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C From 3527e35c0dd49fba0078f6df44c9c18e4569674a Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Fri, 1 Mar 2024 12:44:56 +0200 Subject: [PATCH 38/40] Add for loop location test with single delcaration initializer --- tests/regression/cfg/loops.t/loops.c | 7 +- tests/regression/cfg/loops.t/run.t | 357 ++++++++++++++++++++------- 2 files changed, 273 insertions(+), 91 deletions(-) diff --git a/tests/regression/cfg/loops.t/loops.c b/tests/regression/cfg/loops.t/loops.c index 0e038e18983..cac7837bccd 100644 --- a/tests/regression/cfg/loops.t/loops.c +++ b/tests/regression/cfg/loops.t/loops.c @@ -30,8 +30,13 @@ int main() { __goblint_check(1); } + // for loop with declaration initializer + for (int j = 0; j < 10; j++) { + __goblint_check(1); + } + // for loop with two initializers - for (int j = (i = 0); i < 10; i++) { + for (int k = (i = 0); i < 10; i++) { __goblint_check(1); } diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index febb255865e..bcbe66d1260 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -115,106 +115,140 @@ │ __goblint_check(1) │ Neg(i < 10) │ ▼ ▼ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:23 │ │ - │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ GraphML: true; server: false │ │ YAML loc: loops.c:34:8-34:23 │ │ - │ │ │ GraphML: true; server: false │ │ - └───────────────────────────────────┘ └───────────────────────────────────┘ │ - │ │ │ - │ │ i = 0 │ - │ ▼ │ - │ ┌───────────────────────────────────┐ │ - │ │ loops.c:34:8-34:23 (synthetic) │ │ - │ │ (loops.c:34:12-34:23 (synthetic)) │ │ - │ │ GraphML: true; server: false │ │ - │ └───────────────────────────────────┘ │ - │ │ │ - ┌────┘ │ j = i │ - │ ▼ │ - │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ - │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:36 (synthetic)) │ │ - │ │ YAML loc: loops.c:35:5-35:23 │ │ YAML loop: loops.c:34:3-36:3 │ │ - │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ - │ │ │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ - │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ __goblint_check(1) │ Neg(i < 10) │ │ - │ ▼ ▼ │ │ - │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ - │ │ loops.c:34:8-34:23 (synthetic) │ │ loops.c:39:3-39:8 │ │ │ - │ │ (loops.c:34:12-34:23 (synthetic)) │ │ (loops.c:39:3-39:8) │ │ │ - │ │ GraphML: true; server: false │ │ YAML loc: loops.c:39:3-39:8 │ │ │ - │ │ │ ─┐ │ GraphML: true; server: true │ │ │ - │ └───────────────────────────────────┘ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ i = 0 │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:41:5-41:8 │ │ │ - │ │ │ (loops.c:41:5-41:8) │ │ │ - │ │ │ YAML loc: loops.c:41:5-41:8 │ │ │ - │ │ │ YAML loop: loops.c:40:3-42:19 │ │ │ - │ │ │ GraphML: true; server: true │ │ │ - │ │ │ loop: loops.c:40:3-42:19 │ ◀┐ │ │ - │ │ └───────────────────────────────────┘ │ │ │ - │ │ │ │ │ │ - │ │ │ i = i + 1 │ Pos(i < 10) │ │ - │ │ ▼ │ │ │ - │ │ ┌───────────────────────────────────┐ │ │ │ - │ │ │ loops.c:40:3-42:19 (synthetic) │ │ │ │ - │ │ │ (loops.c:42:12-42:19 (synthetic)) │ │ │ │ - │ │ │ GraphML: true; server: false │ ─┘ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ Neg(i < 10) │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:44:3-44:11 │ │ │ - │ │ │ (loops.c:44:10-44:11) │ │ │ - │ │ │ YAML loc: loops.c:44:3-44:11 │ │ │ - │ │ │ GraphML: true; server: true │ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ │ - │ │ │ return 0 │ │ - │ │ ▼ │ │ - │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ return of main() │ │ │ - │ │ └───────────────────────────────────┘ │ │ - │ │ │ │ - └─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┘ │ - │ │ - │ │ - └──────────────────────────────────────────────────────────────────────────────┘ + │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:17 │ │ + │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:17 (synthetic)) │ │ + │ GraphML: true; server: false │ │ YAML loc: loops.c:34:8-34:17 │ │ + ┌────── │ │ │ GraphML: true; server: false │ │ + │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ + │ │ │ + │ │ j = 0 │ + │ ▼ │ + │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ + │ │ loops.c:35:5-35:23 │ │ loops.c:34:3-36:3 (synthetic) │ │ + │ │ (loops.c:35:5-35:23) │ │ (loops.c:34:7-34:30 (synthetic)) │ │ + │ │ YAML loc: loops.c:35:5-35:23 │ │ YAML loop: loops.c:34:3-36:3 │ │ + │ │ GraphML: true; server: true │ Pos(j < 10) │ GraphML: true; server: false │ j = j + 1 │ + │ │ │ ◀───────────── │ loop: loops.c:34:3-36:3 │ ◀─────────────────────┼────┐ + │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ __goblint_check(1) │ Neg(j < 10) │ │ + │ ▼ ▼ │ │ + │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ loops.c:34:8-34:17 (synthetic) │ │ loops.c:39:8-39:23 │ │ │ + │ │ (loops.c:34:12-34:17 (synthetic)) │ │ (loops.c:39:12-39:23 (synthetic)) │ │ │ + │ │ GraphML: true; server: false │ │ YAML loc: loops.c:39:8-39:23 │ │ │ + │ │ │ │ GraphML: true; server: false │ │ │ + │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ │ │ i = 0 │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:39:8-39:23 (synthetic) │ │ │ + │ │ │ (loops.c:39:12-39:23 (synthetic)) │ │ │ + │ │ │ GraphML: true; server: false │ │ │ + │ │ └───────────────────────────────────┘ │ │ + │ │ │ │ │ + │ ┌────┘ │ k = i │ │ + │ │ ▼ │ │ + │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ + │ │ │ loops.c:40:5-40:23 │ │ loops.c:39:3-41:3 (synthetic) │ │ │ + │ │ │ (loops.c:40:5-40:23) │ │ (loops.c:39:7-39:36 (synthetic)) │ │ │ + │ │ │ YAML loc: loops.c:40:5-40:23 │ │ YAML loop: loops.c:39:3-41:3 │ │ │ + │ │ │ GraphML: true; server: true │ Pos(i < 10) │ GraphML: true; server: false │ i = i + 1 │ │ + │ │ │ │ ◀───────────── │ loop: loops.c:39:3-41:3 │ ◀─────────────────────┼────┼─────────────┐ + │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ │ + │ │ ▼ ▼ │ │ │ + │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ + │ │ │ loops.c:39:8-39:23 (synthetic) │ │ loops.c:44:3-44:8 │ │ │ │ + │ │ │ (loops.c:39:12-39:23 (synthetic)) │ │ (loops.c:44:3-44:8) │ │ │ │ + │ │ │ GraphML: true; server: false │ │ YAML loc: loops.c:44:3-44:8 │ │ │ │ + │ │ │ │ │ GraphML: true; server: true │ │ │ │ + │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ i = 0 │ │ │ + │ │ │ ▼ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ loops.c:46:5-46:8 │ │ │ │ + │ │ │ │ (loops.c:46:5-46:8) │ │ │ │ + │ │ │ │ YAML loc: loops.c:46:5-46:8 │ │ │ │ + │ │ │ │ YAML loop: loops.c:45:3-47:19 │ │ │ │ + │ │ │ │ GraphML: true; server: true │ │ │ │ + │ │ │ │ loop: loops.c:45:3-47:19 │ ◀┐ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ │ + │ │ │ │ │ │ │ │ + │ │ │ │ i = i + 1 │ Pos(i < 10) │ │ │ + │ │ │ ▼ │ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ │ + │ │ │ │ loops.c:45:3-47:19 (synthetic) │ │ │ │ │ + │ │ │ │ (loops.c:47:12-47:19 (synthetic)) │ │ │ │ │ + │ │ │ │ GraphML: true; server: false │ ─┘ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ │ │ │ Neg(i < 10) │ │ │ + │ │ │ ▼ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ loops.c:49:3-49:11 │ │ │ │ + │ │ │ │ (loops.c:49:10-49:11) │ │ │ │ + │ │ │ │ YAML loc: loops.c:49:3-49:11 │ │ │ │ + │ │ │ │ GraphML: true; server: true │ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ │ + │ └────┼────────────────────────────────────┐ │ return 0 │ │ │ + │ │ │ ▼ │ │ │ + │ │ │ ┌───────────────────────────────────┐ │ │ │ + │ │ │ │ return of main() │ │ │ │ + │ │ │ └───────────────────────────────────┘ │ │ │ + │ │ │ │ │ │ + └─────────┼────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┘ │ │ + │ │ │ │ + │ │ │ │ + │ └──────────────────────────────────────────────────────────────────────────────┘ │ + │ │ + │ │ + └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ $ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant", "loop_invariant"]' loops.c [Success][Assert] Assertion "1" will succeed (loops.c:14:5-14:23) [Success][Assert] Assertion "1" will succeed (loops.c:30:5-30:23) [Success][Assert] Assertion "1" will succeed (loops.c:35:5-35:23) + [Success][Assert] Assertion "1" will succeed (loops.c:40:5-40:23) [Info][Deadcode] Logical lines of code (LLoC) summary: - live: 18 + live: 20 dead: 0 - total lines: 18 + total lines: 20 [Info][Witness] witness generation summary: - total generation entries: 39 + total generation entries: 53 $ yamlWitnessStrip < witness.yml - entry_type: loop_invariant location: file_name: loops.c file_hash: $FILE_HASH - line: 40 + line: 45 column: 2 function: main loop_invariant: - string: j == 0 + string: k == 0 type: assertion format: C - entry_type: loop_invariant location: file_name: loops.c file_hash: $FILE_HASH - line: 40 + line: 45 + column: 2 + function: main + loop_invariant: + string: j == 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 45 column: 2 function: main loop_invariant: @@ -225,7 +259,51 @@ location: file_name: loops.c file_hash: $FILE_HASH - line: 40 + line: 45 + column: 2 + function: main + loop_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 + column: 2 + function: main + loop_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 + column: 2 + function: main + loop_invariant: + string: j == 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 + column: 2 + function: main + loop_invariant: + string: i <= 10 + type: assertion + format: C + - entry_type: loop_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 39 column: 2 function: main loop_invariant: @@ -240,7 +318,7 @@ column: 2 function: main loop_invariant: - string: j == 0 + string: j <= 10 type: assertion format: C - entry_type: loop_invariant @@ -251,7 +329,7 @@ column: 2 function: main loop_invariant: - string: i <= 10 + string: i == 10 type: assertion format: C - entry_type: loop_invariant @@ -262,7 +340,7 @@ column: 2 function: main loop_invariant: - string: 0 <= i + string: 0 <= j type: assertion format: C - entry_type: loop_invariant @@ -375,6 +453,94 @@ string: 0 <= i type: assertion format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 49 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 49 + column: 2 + function: main + location_invariant: + string: j == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 49 + column: 2 + function: main + location_invariant: + string: i == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 46 + column: 4 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 46 + column: 4 + function: main + location_invariant: + string: j == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 46 + column: 4 + function: main + location_invariant: + string: i <= 9 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 46 + column: 4 + function: main + location_invariant: + string: 0 <= i + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 44 + column: 2 + function: main + location_invariant: + string: k == 0 + type: assertion + format: C - entry_type: location_invariant location: file_name: loops.c @@ -383,7 +549,7 @@ column: 2 function: main location_invariant: - string: j == 0 + string: j == 10 type: assertion format: C - entry_type: location_invariant @@ -401,18 +567,29 @@ location: file_name: loops.c file_hash: $FILE_HASH - line: 41 + line: 40 column: 4 function: main location_invariant: - string: j == 0 + string: k == 0 type: assertion format: C - entry_type: location_invariant location: file_name: loops.c file_hash: $FILE_HASH - line: 41 + line: 40 + column: 4 + function: main + location_invariant: + string: j == 10 + type: assertion + format: C + - entry_type: location_invariant + location: + file_name: loops.c + file_hash: $FILE_HASH + line: 40 column: 4 function: main location_invariant: @@ -423,7 +600,7 @@ location: file_name: loops.c file_hash: $FILE_HASH - line: 41 + line: 40 column: 4 function: main location_invariant: @@ -438,7 +615,7 @@ column: 2 function: main location_invariant: - string: j == 0 + string: j == 10 type: assertion format: C - entry_type: location_invariant @@ -460,7 +637,7 @@ column: 4 function: main location_invariant: - string: j == 0 + string: j <= 9 type: assertion format: C - entry_type: location_invariant @@ -471,7 +648,7 @@ column: 4 function: main location_invariant: - string: i <= 9 + string: i == 10 type: assertion format: C - entry_type: location_invariant @@ -482,7 +659,7 @@ column: 4 function: main location_invariant: - string: 0 <= i + string: 0 <= j type: assertion format: C - entry_type: location_invariant From b21c8843fe0730303f8d61dc51a307da9edfb2db Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Fri, 1 Mar 2024 13:24:59 +0200 Subject: [PATCH 39/40] Fix statement location for for initializer declaration --- goblint.opam | 2 +- goblint.opam.locked | 2 +- goblint.opam.template | 2 +- tests/regression/cfg/loops.t/run.t | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/goblint.opam b/goblint.opam index 5f16b5842ae..0d53da497b4 100644 --- a/goblint.opam +++ b/goblint.opam @@ -78,7 +78,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git" available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ae3a4949d478fad77e004c6fe15a7c83427df59f" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/goblint.opam.locked b/goblint.opam.locked index d6c156c9dc5..0ec1f958650 100644 --- a/goblint.opam.locked +++ b/goblint.opam.locked @@ -134,7 +134,7 @@ post-messages: [ pin-depends: [ [ "goblint-cil.2.0.3" - "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" + "git+https://github.com/goblint/cil.git#ae3a4949d478fad77e004c6fe15a7c83427df59f" ] [ "ppx_deriving.5.2.1" diff --git a/goblint.opam.template b/goblint.opam.template index a3bb99ff5cb..2d5ef10bc92 100644 --- a/goblint.opam.template +++ b/goblint.opam.template @@ -3,7 +3,7 @@ available: os-distribution != "alpine" & arch != "arm64" pin-depends: [ # published goblint-cil 2.0.3 is currently up-to-date, so no pin needed - [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#fb471582d7e9685ab705ba57f7a6675b97ca8f64" ] + [ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#ae3a4949d478fad77e004c6fe15a7c83427df59f" ] # TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252) [ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ] ] diff --git a/tests/regression/cfg/loops.t/run.t b/tests/regression/cfg/loops.t/run.t index bcbe66d1260..01216a624e6 100644 --- a/tests/regression/cfg/loops.t/run.t +++ b/tests/regression/cfg/loops.t/run.t @@ -115,9 +115,9 @@ │ __goblint_check(1) │ Neg(i < 10) │ ▼ ▼ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ - │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:8-34:17 │ │ + │ loops.c:29:3-31:3 (synthetic) │ │ loops.c:34:3-36:3 │ │ │ (loops.c:29:7-29:21 (synthetic)) │ │ (loops.c:34:12-34:17 (synthetic)) │ │ - │ GraphML: true; server: false │ │ YAML loc: loops.c:34:8-34:17 │ │ + │ GraphML: true; server: false │ │ YAML loc: loops.c:34:3-36:3 │ │ ┌────── │ │ │ GraphML: true; server: false │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ @@ -134,16 +134,16 @@ │ │ __goblint_check(1) │ Neg(j < 10) │ │ │ ▼ ▼ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ - │ │ loops.c:34:8-34:17 (synthetic) │ │ loops.c:39:8-39:23 │ │ │ + │ │ loops.c:34:3-36:3 (synthetic) │ │ loops.c:39:3-41:3 │ │ │ │ │ (loops.c:34:12-34:17 (synthetic)) │ │ (loops.c:39:12-39:23 (synthetic)) │ │ │ - │ │ GraphML: true; server: false │ │ YAML loc: loops.c:39:8-39:23 │ │ │ + │ │ GraphML: true; server: false │ │ YAML loc: loops.c:39:3-41:3 │ │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ └───────────────────────────────────┘ └───────────────────────────────────┘ │ │ │ │ │ │ │ │ │ │ i = 0 │ │ │ │ ▼ │ │ │ │ ┌───────────────────────────────────┐ │ │ - │ │ │ loops.c:39:8-39:23 (synthetic) │ │ │ + │ │ │ loops.c:39:3-41:3 (synthetic) │ │ │ │ │ │ (loops.c:39:12-39:23 (synthetic)) │ │ │ │ │ │ GraphML: true; server: false │ │ │ │ │ └───────────────────────────────────┘ │ │ @@ -161,7 +161,7 @@ │ │ │ __goblint_check(1) │ Neg(i < 10) │ │ │ │ │ ▼ ▼ │ │ │ │ │ ┌───────────────────────────────────┐ ┌───────────────────────────────────┐ │ │ │ - │ │ │ loops.c:39:8-39:23 (synthetic) │ │ loops.c:44:3-44:8 │ │ │ │ + │ │ │ loops.c:39:3-41:3 (synthetic) │ │ loops.c:44:3-44:8 │ │ │ │ │ │ │ (loops.c:39:12-39:23 (synthetic)) │ │ (loops.c:44:3-44:8) │ │ │ │ │ │ │ GraphML: true; server: false │ │ YAML loc: loops.c:44:3-44:8 │ │ │ │ │ │ │ │ │ GraphML: true; server: true │ │ │ │ From bb1a2aedc6f93c0b321d0601a3c6e04d123e60e6 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Fri, 1 Mar 2024 16:37:17 +0200 Subject: [PATCH 40/40] Suppress backtraces in cram tests --- .../regression/55-loop-unrolling/11-unrolled-loop-invariant.t | 3 +++ tests/regression/70-transform/01-ordering.t | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t index c46c468642d..b154f8f57ac 100644 --- a/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t +++ b/tests/regression/55-loop-unrolling/11-unrolled-loop-invariant.t @@ -1,3 +1,6 @@ +Suppress backtrace with code locations, especially for CI. + $ export OCAMLRUNPARAM=b=0 + $ goblint --set lib.activated '[]' --set exp.unrolling-factor 5 --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.entry-types '["location_invariant", "loop_invariant"]' 11-unrolled-loop-invariant.c [Error] YAML witnesses are incompatible with syntactic loop unrolling (https://github.com/goblint/analyzer/pull/1370). Fatal error: exception Failure("Option error") diff --git a/tests/regression/70-transform/01-ordering.t b/tests/regression/70-transform/01-ordering.t index cd7ec8e36a6..9ff5a9b739d 100644 --- a/tests/regression/70-transform/01-ordering.t +++ b/tests/regression/70-transform/01-ordering.t @@ -1,3 +1,6 @@ +Suppress backtrace with code locations, especially for CI. + $ export OCAMLRUNPARAM=b=0 + Check that assert transform is not allowed to happen after dead code removal $ ./transform.sh --stderr remove_dead_code assert -- 01-empty.c [Error] trans.activated: the 'assert' transform may not occur after the 'remove_dead_code' transform