From 033eab96f0259c73d826cfe4902562d32e8cb4e5 Mon Sep 17 00:00:00 2001 From: Vincent Lafeychine <vincent.lafeychine@proton.me> Date: Wed, 24 Apr 2024 15:46:03 +0200 Subject: [PATCH] feat(cargo): Fetch analysis crate directly from the upstream git --- rr_frontend/.cargo/config.toml | 7 + rr_frontend/Cargo.lock | 388 +++---- rr_frontend/Cargo.toml | 7 +- rr_frontend/analysis/Cargo.toml | 28 - rr_frontend/analysis/README.md | 10 - .../abstract_interpretation/abstract_state.rs | 68 -- .../fixpoint_engine.rs | 174 --- .../src/abstract_interpretation/mod.rs | 11 - rr_frontend/analysis/src/analysis_error.rs | 46 - .../domains/definitely_accessible/analysis.rs | 134 --- .../src/domains/definitely_accessible/mod.rs | 12 - .../domains/definitely_accessible/state.rs | 263 ----- .../domains/definitely_allocated/analysis.rs | 78 -- .../src/domains/definitely_allocated/mod.rs | 11 - .../src/domains/definitely_allocated/state.rs | 120 --- .../definitely_initialized/analysis.rs | 102 -- .../src/domains/definitely_initialized/mod.rs | 11 - .../domains/definitely_initialized/state.rs | 389 ------- .../analysis/src/domains/framing/analysis.rs | 113 -- .../analysis/src/domains/framing/mod.rs | 12 - .../analysis/src/domains/framing/state.rs | 98 -- .../src/domains/maybe_borrowed/analysis.rs | 119 --- .../src/domains/maybe_borrowed/mod.rs | 12 - .../src/domains/maybe_borrowed/state.rs | 48 - rr_frontend/analysis/src/domains/mod.rs | 19 - .../domains/reaching_definitions/analysis.rs | 80 -- .../src/domains/reaching_definitions/mod.rs | 12 - .../src/domains/reaching_definitions/state.rs | 179 ---- rr_frontend/analysis/src/lib.rs | 18 - rr_frontend/analysis/src/mir_utils.rs | 321 ------ rr_frontend/analysis/src/pointwise_state.rs | 161 --- .../testbins/analysis_driver/Cargo.lock | 318 ------ .../testbins/analysis_driver/Cargo.toml | 15 - .../testbins/analysis_driver/src/main.rs | 291 ----- .../gen_accessibility_driver/Cargo.lock | 318 ------ .../gen_accessibility_driver/Cargo.toml | 14 - .../gen_accessibility_driver/src/main.rs | 225 ---- .../analysis/tests/test_accessibility.rs | 167 --- rr_frontend/analysis/tests/test_analysis.rs | 57 - .../definitely_accessible/expired.rs | 13 - .../definitely_accessible/expired.stdout | 462 -------- .../definitely_accessible/fields.rs | 30 - .../definitely_accessible/fields.stdout | 978 ----------------- .../definitely_accessible/infinite_list.rs | 16 - .../infinite_list.stdout | 436 -------- .../definitely_accessible/ref_field.rs | 12 - .../definitely_accessible/ref_field.stdout | 999 ------------------ .../test_cases/definitely_initialized/abs.rs | 16 - .../definitely_initialized/abs.stdout | 288 ----- .../definitely_initialized/array.rs | 9 - .../definitely_initialized/array.stdout | 314 ------ .../definitely_initialized/calls.rs | 12 - .../definitely_initialized/calls.stdout | 333 ------ .../definitely_initialized/fields.rs | 30 - .../definitely_initialized/fields.stdout | 695 ------------ .../repeated_assignment.rs | 16 - .../repeated_assignment.stdout | 318 ------ .../definitely_initialized/scopes.rs | 9 - .../definitely_initialized/scopes.stdout | 90 -- .../very_simple_assignment.rs | 6 - .../very_simple_assignment.stdout | 93 -- .../tests/test_cases/framing/ref_field.rs | 9 - .../tests/test_cases/framing/ref_field.stdout | 589 ----------- .../test_cases/framing/rust_issue_63787.rs | 17 - .../framing/rust_issue_63787.stdout | 712 ------------- .../gen_accessibility/basic-move.rs | 10 - .../gen_accessibility/check-move.rs | 8 - .../gen_accessibility/consume-call.rs | 25 - .../gen_accessibility/create-box.rs | 11 - .../test_cases/gen_accessibility/deref.rs | 34 - .../test_cases/gen_accessibility/expired.rs | 12 - .../expiring-loans/borrow-die-with-if.rs | 26 - .../expiring-loans/borrow-die-with-magic.rs | 31 - .../expiring-loans/borrow-die-with-moves.rs | 24 - .../expiring-loans/borrow-die.rs | 76 -- .../expiring-loans/issue-25-simpl.rs | 7 - .../expiring-loans/simple-expire-borrows.rs | 18 - .../gen_accessibility/external-call-fail.rs | 4 - .../gen_accessibility/field-types.rs | 25 - .../test_cases/gen_accessibility/fields.rs | 27 - .../test_cases/gen_accessibility/join.rs | 15 - .../gen_accessibility/loops/array-mut-loop.rs | 11 - .../gen_accessibility/loops/break-continue.rs | 48 - .../gen_accessibility/loops/loops.rs | 9 - .../gen_accessibility/loops/tmp-in-guard.rs | 51 - .../gen_accessibility/multiple-branches.rs | 47 - .../gen_accessibility/nll-rfc/borrow-first.rs | 21 - .../gen_accessibility/nll-rfc/message.rs | 26 - .../gen_accessibility/nll-rfc/wrong-case1.rs | 12 - .../test_cases/gen_accessibility/paths.rs | 50 - .../gen_accessibility/predicate-old-expr.rs | 25 - .../gen_accessibility/reassignment.rs | 19 - .../test_cases/gen_accessibility/ref_field.rs | 11 - .../gen_accessibility/simple-assert.rs | 21 - .../test_cases/gen_accessibility/structs.rs | 18 - .../test_cases/maybe_borrowed/linked_list.rs | 35 - .../maybe_borrowed/linked_list.stdout | 846 --------------- .../test_cases/reaching_definitions/abs.rs | 16 - .../reaching_definitions/abs.stdout | 710 ------------- .../test_cases/reaching_definitions/calls.rs | 12 - .../reaching_definitions/calls.stdout | 792 -------------- .../repeated_assignment.rs | 16 - .../repeated_assignment.stdout | 717 ------------- .../very_simple_assignment.rs | 6 - .../very_simple_assignment.stdout | 149 --- .../relaxed_definitely_initialized/abs.rs | 16 - .../relaxed_definitely_initialized/abs.stdout | 323 ------ rr_frontend/analysis/tests/utils.rs | 20 - rr_frontend/translation/Cargo.toml | 2 +- 109 files changed, 143 insertions(+), 15197 deletions(-) delete mode 100644 rr_frontend/analysis/Cargo.toml delete mode 100644 rr_frontend/analysis/README.md delete mode 100644 rr_frontend/analysis/src/abstract_interpretation/abstract_state.rs delete mode 100644 rr_frontend/analysis/src/abstract_interpretation/fixpoint_engine.rs delete mode 100644 rr_frontend/analysis/src/abstract_interpretation/mod.rs delete mode 100644 rr_frontend/analysis/src/analysis_error.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_accessible/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_accessible/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_accessible/state.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_allocated/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_allocated/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_allocated/state.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_initialized/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_initialized/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/definitely_initialized/state.rs delete mode 100644 rr_frontend/analysis/src/domains/framing/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/framing/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/framing/state.rs delete mode 100644 rr_frontend/analysis/src/domains/maybe_borrowed/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/maybe_borrowed/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/maybe_borrowed/state.rs delete mode 100644 rr_frontend/analysis/src/domains/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/reaching_definitions/analysis.rs delete mode 100644 rr_frontend/analysis/src/domains/reaching_definitions/mod.rs delete mode 100644 rr_frontend/analysis/src/domains/reaching_definitions/state.rs delete mode 100644 rr_frontend/analysis/src/lib.rs delete mode 100644 rr_frontend/analysis/src/mir_utils.rs delete mode 100644 rr_frontend/analysis/src/pointwise_state.rs delete mode 100644 rr_frontend/analysis/testbins/analysis_driver/Cargo.lock delete mode 100644 rr_frontend/analysis/testbins/analysis_driver/Cargo.toml delete mode 100644 rr_frontend/analysis/testbins/analysis_driver/src/main.rs delete mode 100644 rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.lock delete mode 100644 rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.toml delete mode 100644 rr_frontend/analysis/testbins/gen_accessibility_driver/src/main.rs delete mode 100644 rr_frontend/analysis/tests/test_accessibility.rs delete mode 100644 rr_frontend/analysis/tests/test_analysis.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/array.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/array.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/framing/ref_field.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/framing/ref_field.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/basic-move.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/check-move.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/consume-call.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/create-box.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/deref.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expired.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-if.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-magic.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-moves.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/issue-25-simpl.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/simple-expire-borrows.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/external-call-fail.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/field-types.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/fields.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/join.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/array-mut-loop.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/break-continue.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/loops.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/tmp-in-guard.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/multiple-branches.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/borrow-first.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/message.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/wrong-case1.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/paths.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/predicate-old-expr.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/reassignment.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/ref_field.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/simple-assert.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/gen_accessibility/structs.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.stdout delete mode 100644 rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.rs delete mode 100644 rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.stdout delete mode 100644 rr_frontend/analysis/tests/utils.rs diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml index cd4087df..cb84d39a 100644 --- a/rr_frontend/.cargo/config.toml +++ b/rr_frontend/.cargo/config.toml @@ -209,3 +209,10 @@ rustflags = [ "-Aclippy::let_underscore_untyped", "-Aclippy::let_unit_value", ] + +[unstable.gitoxide] +checkout = true +fetch = true +internal_use_git2 = false +shallow_deps = true +shallow_index = true diff --git a/rr_frontend/Cargo.lock b/rr_frontend/Cargo.lock index 0aca372a..8cce03fa 100644 --- a/rr_frontend/Cargo.lock +++ b/rr_frontend/Cargo.lock @@ -14,16 +14,16 @@ dependencies = [ [[package]] name = "analysis" version = "0.1.0" +source = "git+https://github.com/viperproject/prusti-dev.git?rev=24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d#24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d" dependencies = [ - "compiletest_rs", - "env_logger", - "glob", + "derive_more", + "env_logger 0.10.2", "log", - "rr_rustc_interface", + "prusti-rustc-interface", "serde", "serde_json", - "syn", - "test-binary", + "syn 1.0.109", + "tracing 0.1.0", ] [[package]] @@ -78,12 +78,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "anyhow" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" - [[package]] name = "async-trait" version = "0.1.77" @@ -92,7 +86,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -108,12 +102,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.4.2" @@ -132,38 +120,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "camino" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -176,28 +132,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "compiletest_rs" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7225fee1bcf9247bb3a1b1a2d7ecfe2f7a990e549a09d766a257a4ae30dac0d6" -dependencies = [ - "diff", - "filetime", - "getopts", - "lazy_static", - "libc", - "log", - "miow", - "regex", - "rustfix", - "serde", - "serde_derive", - "serde_json", - "tester", - "winapi", -] - [[package]] name = "config" version = "0.14.0" @@ -205,7 +139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ "async-trait", - "convert_case", + "convert_case 0.6.0", "json5", "lazy_static", "nom", @@ -238,6 +172,12 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "convert_case" version = "0.6.0" @@ -300,10 +240,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69" [[package]] -name = "diff" -version = "0.1.13" +name = "derive_more" +version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case 0.4.0", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.109", +] [[package]] name = "digest" @@ -315,27 +262,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dlv-list" version = "0.5.2" @@ -355,6 +281,19 @@ dependencies = [ "regex", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "env_logger" version = "0.11.1" @@ -374,18 +313,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "filetime" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "windows-sys", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -396,15 +323,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getopts" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" -dependencies = [ - "unicode-width", -] - [[package]] name = "getrandom" version = "0.2.12" @@ -416,12 +334,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "hashbrown" version = "0.13.2" @@ -462,6 +374,17 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + [[package]] name = "itoa" version = "1.0.10" @@ -491,17 +414,6 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -526,15 +438,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - [[package]] name = "nom" version = "7.1.3" @@ -545,16 +448,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -571,12 +464,6 @@ dependencies = [ "hashbrown 0.13.2", ] -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - [[package]] name = "path-clean" version = "1.0.1" @@ -620,7 +507,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -634,6 +521,22 @@ dependencies = [ "sha2", ] +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "proc-macro-tracing" +version = "0.1.0" +source = "git+https://github.com/viperproject/prusti-dev.git?rev=24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d#24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "proc-macro2" version = "1.0.78" @@ -643,6 +546,11 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prusti-rustc-interface" +version = "0.1.0" +source = "git+https://github.com/viperproject/prusti-dev.git?rev=24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d#24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d" + [[package]] name = "quote" version = "1.0.35" @@ -661,31 +569,11 @@ dependencies = [ "rrconfig", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - [[package]] name = "refinedrust_frontend" version = "0.1.0" dependencies = [ - "env_logger", + "env_logger 0.11.1", "log", "rr_rustc_interface", "rrconfig", @@ -729,7 +617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags 2.4.2", + "bitflags", "serde", "serde_derive", ] @@ -768,23 +656,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "rustfix" -version = "0.6.1" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd2853d9e26988467753bd9912c3a126f642d05d229a4b53f5752ee36c56481" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "anyhow", - "log", - "serde", - "serde_json", + "semver", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "ryu" version = "1.0.16" @@ -796,9 +675,6 @@ name = "semver" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" -dependencies = [ - "serde", -] [[package]] name = "serde" @@ -817,7 +693,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -859,9 +735,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.48" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -869,40 +745,23 @@ dependencies = [ ] [[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - -[[package]] -name = "test-binary" -version = "3.0.2" +name = "syn" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c7cb854285c40b61c0fade358bf63a2bb1226688a1ea11432ea65349209e6e3" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ - "camino", - "cargo_metadata", - "once_cell", - "paste", - "thiserror", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "tester" -version = "0.9.1" +name = "termcolor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ - "cfg-if", - "getopts", - "libc", - "num_cpus", - "term", + "winapi-util", ] [[package]] @@ -922,7 +781,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -974,6 +833,46 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" +[[package]] +name = "tracing" +version = "0.1.0" +source = "git+https://github.com/viperproject/prusti-dev.git?rev=24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d#24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d" +dependencies = [ + "proc-macro-tracing", + "tracing 0.1.40", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + [[package]] name = "translation" version = "0.1.0" @@ -1025,12 +924,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -1056,27 +949,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "winapi" -version = "0.3.9" +name = "winapi-util" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "134306a13c5647ad6453e8deaec55d3a44d6021970129e6188735e74bf546697" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-sys", ] -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/rr_frontend/Cargo.toml b/rr_frontend/Cargo.toml index 35d1f882..fbd251ea 100644 --- a/rr_frontend/Cargo.toml +++ b/rr_frontend/Cargo.toml @@ -1,6 +1,5 @@ [workspace] members = [ - "analysis", "annotations", "attribute_parse", "radium", @@ -12,20 +11,18 @@ members = [ resolver = "2" [workspace.dependencies] -analysis.path = "analysis" attribute_parse.path = "attribute_parse" radium.path = "radium" rr_rustc_interface.path = "rr_rustc_interface" rrconfig.path = "rrconfig" translation.path = "translation" -compiletest_rs = "0.10" +analysis = { git = "https://github.com/viperproject/prusti-dev.git", rev = "24bd4c5575ff1c0b13eb18cfe1a82992dfdb120d" } config = "0.14" csv = "1" datafrog = "2" derive_more = { version = "1.0.0-beta.6", features = ["display"] } env_logger = "0.11" -glob = "0.3" indent_write = "2" lazy_static = "1" log = "0.4" @@ -35,8 +32,6 @@ rustc-hash = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" shlex = "1.3" -syn = { version = "2", features = ["full", "parsing"] } -test-binary = "3" toml = "0.8" topological-sort = "0.2" typed-arena = "2" diff --git a/rr_frontend/analysis/Cargo.toml b/rr_frontend/analysis/Cargo.toml deleted file mode 100644 index 46f98f05..00000000 --- a/rr_frontend/analysis/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "analysis" -authors = ["Federico Poli <federpoli@gmail.com>"] -license = "MPL-2.0" - -edition.workspace = true -repository.workspace = true -version.workspace = true - -[dependencies] -rr_rustc_interface.workspace = true - -env_logger.workspace = true -log.workspace = true -serde.workspace = true -serde_json.workspace = true -syn = { optional = true, workspace = true } - -[dev-dependencies] -compiletest_rs.workspace = true -glob.workspace = true -test-binary.workspace = true - -[features] -test-utils = ["dep:syn"] - -[package.metadata.rust-analyzer] -rustc_private = true diff --git a/rr_frontend/analysis/README.md b/rr_frontend/analysis/README.md deleted file mode 100644 index efaa5942..00000000 --- a/rr_frontend/analysis/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Analysis -======== - -Intra-procedural static analysis of MIR functions. - -Each analysis compute a state for each program point: -* `DefinitelyInitializedAnalysis` computes the places that are definitely initialized. By enabling a flag, this analysis also considers "initialized" the places of `Copy` types after a *move* operation. -* `ReachingDefinitionAnalysis` computes for each local variable the set of assignments or function arguments from which the value of the local variable might come from. -* `MaybeBorrowedAnalysis` computes the places that are blocked due to a mutable reference or frozen due to a shared reference. -* `DefinitelyAccessibleAnalysis` computes the places that are are surely owned (i.e. can be borrowed by a mutable reference) or accessible (i.e. can be borrowed by a shared reference). diff --git a/rr_frontend/analysis/src/abstract_interpretation/abstract_state.rs b/rr_frontend/analysis/src/abstract_interpretation/abstract_state.rs deleted file mode 100644 index 3d08ca2c..00000000 --- a/rr_frontend/analysis/src/abstract_interpretation/abstract_state.rs +++ /dev/null @@ -1,68 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use serde::Serialize; - -/// Trait to be used to define an abstract domain by defining the type of its elements. -/// These elements can be used in the ``Analyzer`` to represent an abstraction of the concrete -/// state at program points. -/// -/// To ensure that the analysis is converging to a correct fixed point implementations `S` of this -/// trait should fulfill the following properties: -/// * `join()` implicitly defines a partial order of abstraction `<=`, such that forall x,y: S :: `x <= -/// x.join(y)` && `y <= x.join(y)`; i.e. `join()` computes an upper bound in that order, which means it -/// abstracts more (or equally many) concrete states, in particular it represents all concrete states that -/// were abstracted by either `x` or `y`. -/// * `new_bottom()` should return the least element in that order. -/// * If the 'height' of the order, i.e. how many elements can be traversed until a maximum is reached, is not -/// known to be finite, the following properties should additionally hold for proper widening: -/// - exists i: u32 :: `need_to_widen(i) == true` -/// - forall x,y: S :: `x <= x.widen(y)` && `y <= x.widen(y)` -/// - for every ascending chain of domain elements x_i the ascending chain y_i defined as y_0 := x_0, -/// y_(i+1) := x_i.widen(y_i) reaches a fixed-point after a finite number of steps -/// * The 'abstract transformers' `apply_statement_effect` and `apply_terminator_effect` should correctly -/// abstract the concrete semantics of the given operation, i.e. the resulting abstraction should represent -/// a superset of the possible concrete states after applying the statement or terminator to any of the -/// concrete states represented by the abstraction before. (If an operation is not supported an -/// `AnalysisError::UnsupportedStatement` can be returned.) -/// * `apply_terminator_effect` should assign an abstract state to every successor basic block, otherwise -/// `NoStateAfterSuccessor` error will be returned by the analysis. -/// -/// To get a result that is as precise as possible implementers probably also want to fulfill the -/// following properties: -/// * `join()` should return the **least** least upper bound. In particular it should hold: forall x: S :: -/// `x.join(S::new_bottom(_)) == x` && `S::new_bottom(_).join(x) == x`. -/// * The 'abstract transformers' `apply_statement_effect` and `apply_terminator_effect` should abstract the -/// concrete semantics as precise as possible. -// Sized needed for apply_terminator_effect's return type -pub trait AbstractState: Clone + Eq + Sized + Serialize { - //fn make_top(&mut self) -> Self; - //fn make_bottom(&mut self) -> Self; - - /// Checks if the current state corresponds to the bottom element in the lattice - fn is_bottom(&self) -> bool; - - //fn new_top(&self) -> Self; - //fn is_top(&self) -> bool; - - //fn less_equal(&self, other: &Self) -> bool; - - /// Lattice operation to join `other` into this state, producing the (least) upper bound - fn join(&mut self, other: &Self); - - /// Lattice operation to join all `others` into this state, producing the (least) upper bound - fn join_all(&mut self, others: &[&Self]) { - for other in others.iter() { - self.join(other) - } - } - - //fn meet(&mut self, other: &Self) -> Self; - - /// Make the state less precise to make the iteration stop by using the difference to the state - /// from the previous iteration given in `previous`. - fn widen(&mut self, previous: &Self); -} diff --git a/rr_frontend/analysis/src/abstract_interpretation/fixpoint_engine.rs b/rr_frontend/analysis/src/abstract_interpretation/fixpoint_engine.rs deleted file mode 100644 index 6cccc36d..00000000 --- a/rr_frontend/analysis/src/abstract_interpretation/fixpoint_engine.rs +++ /dev/null @@ -1,174 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::collections::BTreeSet; -use std::iter::FromIterator; - -use rr_rustc_interface::data_structures::fx::FxHashMap; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::AbstractState; -use crate::analysis_error::AnalysisError::NoStateAfterSuccessor; -pub use crate::domains::*; -pub use crate::AnalysisError; -use crate::PointwiseState; - -pub type AnalysisResult<T> = std::result::Result<T, AnalysisError>; - -/// Trait to be used to define an abstract-interpreation-based static analysis of a MIR body. -pub trait FixpointEngine<'mir, 'tcx: 'mir> { - type State: AbstractState; - - /// Return the DefId of the MIR body to be analyzed. - fn def_id(&self) -> DefId; - - /// Return the MIR body to be analyzed. - fn body(&self) -> &'mir mir::Body<'tcx>; - - /// Creates a new abstract state which corresponds to the bottom element in the lattice - fn new_bottom(&self) -> Self::State; - - //fn new_top(&self) -> Self::State; - - /// Creates the abstract state at the beginning of the `mir` body. - /// In particular this should take the arguments into account. - fn new_initial(&self) -> Self::State; - - /// Determines if the number of times a block was traversed by the analyzer given in `counter` - /// is large enough to widen the state - fn need_to_widen(counter: u32) -> bool; - - /// Modify a state according to the statement at `location`. - /// - /// The statement can be extracted using - /// `self.mir[location.block].statements[location.statement_index]`. - fn apply_statement_effect(&self, state: &mut Self::State, location: mir::Location) -> AnalysisResult<()>; - - /// Compute the states after a terminator at `location`. - /// - /// The statement can be extracted using `self.mir[location.block].terminator()`. - fn apply_terminator_effect( - &self, - state: &Self::State, - location: mir::Location, - ) -> AnalysisResult<Vec<(mir::BasicBlock, Self::State)>>; - - /// Produces an abstract state for every program point in `mir` by iterating over all statements - /// in program order until a fixed point is reached (i.e. by abstract interpretation). - // TODO: add tracing like in initialization.rs? - fn run_fwd_analysis(&self) -> AnalysisResult<PointwiseState<'mir, 'tcx, Self::State>> { - let mir = self.body(); - let mut p_state = PointwiseState::new(mir); - // use https://crates.io/crates/linked_hash_set for set preserving insertion order? - let mut work_set: BTreeSet<mir::BasicBlock> = BTreeSet::from_iter(mir.basic_blocks.indices()); - - let mut counters: FxHashMap<mir::BasicBlock, u32> = - FxHashMap::with_capacity_and_hasher(mir.basic_blocks.len(), Default::default()); - - //'block_loop: - // extract the bb with the minimal index -> hopefully better performance - // use pop_first when it becomes stable? - while let Some(&bb) = work_set.iter().next() { - work_set.remove(&bb); - - let mut state_before_block = if bb == mir::START_BLOCK { - // entry block - self.new_initial() - } else { - self.new_bottom() - }; - - for &pred_bb in &mir.basic_blocks.predecessors()[bb] { - if let Some(map) = p_state.lookup_after_block(pred_bb) { - // map should contain bb, because we ensure that we have a state for every - // successor - state_before_block.join(map.get(&bb).unwrap()); - } - // if no state is present: assume bottom => no effect on join - } - - // widen if needed - let counter = counters.entry(bb).or_insert(0); - *counter += 1; - - if Self::need_to_widen(*counter) { - let location = mir::Location { - block: bb, - statement_index: 0, - }; - state_before_block.widen(p_state.lookup_before(location).unwrap()) - } - - let statements = &mir[bb].statements; - let mut current_state = state_before_block; - for statement_index in 0..statements.len() { - let location = mir::Location { - block: bb, - statement_index, - }; - /* Too much performance overhead to check for every statement? - let prev_state = p_state.lookup_before(location); - // use .contains when it becomes stable - if prev_state.into_iter().any(|s| s == ¤t_state) { - // same state, don't need to reiterate - continue 'block_loop; - } - */ - p_state.set_before(location, current_state.clone()); - // normal statement - self.apply_statement_effect(&mut current_state, location)?; - } - - // terminator effect - let location = mir.terminator_loc(bb); - /* Too much performance overhead to check for every statement? - let prev_state = p_state.lookup_before(location); - if prev_state.into_iter().any(|s| s == ¤t_state) { - // same state, don't need to reiterate - continue 'block_loop; - } - */ - p_state.set_before(location, current_state.clone()); - - let next_states = self.apply_terminator_effect(¤t_state, location)?; - - let mut new_map: FxHashMap<mir::BasicBlock, Self::State> = FxHashMap::default(); - for (next_bb, state) in next_states { - if let Some(s) = new_map.get_mut(&next_bb) { - // join states with same destination for Map - s.join(&state); - } else { - new_map.insert(next_bb, state); - } - } - - let terminator = mir[bb].terminator(); - for next_bb in terminator.successors() { - if !new_map.contains_key(&next_bb) { - return Err(NoStateAfterSuccessor(bb, next_bb)); - } - } - debug_assert_eq!( - terminator.successors().collect::<BTreeSet<_>>(), - new_map.keys().copied().collect::<BTreeSet<_>>(), - ); - let map_after_block = p_state.lookup_mut_after_block(bb); - for next_bb in terminator.successors() { - if let Some(s) = new_map.remove(&next_bb) { - let prev_state = map_after_block.insert(next_bb, s); - let new_state_ref = map_after_block.get(&next_bb); - // TODO: use .contains when it becomes stable? - if !prev_state.iter().any(|ps| ps == new_state_ref.unwrap()) { - // input state has changed => add next_bb to worklist - work_set.insert(next_bb); - } - } - } - } - AnalysisResult::Ok(p_state) - } -} diff --git a/rr_frontend/analysis/src/abstract_interpretation/mod.rs b/rr_frontend/analysis/src/abstract_interpretation/mod.rs deleted file mode 100644 index dd2bffc3..00000000 --- a/rr_frontend/analysis/src/abstract_interpretation/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod abstract_state; -mod fixpoint_engine; - -pub use abstract_state::*; -pub use fixpoint_engine::*; diff --git a/rr_frontend/analysis/src/analysis_error.rs b/rr_frontend/analysis/src/analysis_error.rs deleted file mode 100644 index a66c6818..00000000 --- a/rr_frontend/analysis/src/analysis_error.rs +++ /dev/null @@ -1,46 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::middle::mir; - -use crate::mir_utils::location_to_stmt_str; - -#[derive(Debug)] -pub enum AnalysisError { - UnsupportedStatement(mir::Location), - /// The state is not defined before the given location. - NoStateBeforeLocation(mir::Location), - /// The state is not defined after the given MIR block. - NoStateAfterBlock(mir::BasicBlock), - /// The state is not defined on the edge between two MIR blocks (source, destination). - NoStateAfterSuccessor(mir::BasicBlock, mir::BasicBlock), -} - -impl AnalysisError { - pub fn to_pretty_str(&self, mir: &mir::Body) -> String { - match self { - Self::UnsupportedStatement(location) => { - let stmt = location_to_stmt_str(*location, mir); - format!("Unsupported statement at {:?}: {}", location, stmt) - }, - Self::NoStateBeforeLocation(location) => { - let stmt = location_to_stmt_str(*location, mir); - format!("There is no state before the statement at {:?} ({})", location, stmt) - }, - Self::NoStateAfterBlock(bb) => { - let terminator = &mir[*bb].terminator(); - format!("There is no state after the terminator of block {:?} ({:?})", bb, terminator.kind) - }, - Self::NoStateAfterSuccessor(bb_src, bb_dst) => { - let terminator = &mir[*bb_src].terminator(); - format!( - "There is no state for the block {:?} after the terminator of block {:?} ({:?})", - bb_dst, bb_src, terminator.kind - ) - }, - } - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_accessible/analysis.rs b/rr_frontend/analysis/src/domains/definitely_accessible/analysis.rs deleted file mode 100644 index c1e081d0..00000000 --- a/rr_frontend/analysis/src/domains/definitely_accessible/analysis.rs +++ /dev/null @@ -1,134 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::borrowck::consumers::BodyWithBorrowckFacts; -use rr_rustc_interface::data_structures::fx::{FxHashMap, FxHashSet}; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::{AnalysisResult, FixpointEngine}; -use crate::domains::{ - DefinitelyAccessibleState, DefinitelyInitializedAnalysis, DefinitelyInitializedState, - MaybeBorrowedAnalysis, MaybeBorrowedState, -}; -use crate::mir_utils::remove_place_from_set; -use crate::PointwiseState; - -pub struct DefinitelyAccessibleAnalysis<'mir, 'tcx: 'mir> { - tcx: TyCtxt<'tcx>, - def_id: DefId, - body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>, -} - -impl<'mir, 'tcx: 'mir> DefinitelyAccessibleAnalysis<'mir, 'tcx> { - pub const fn new( - tcx: TyCtxt<'tcx>, - def_id: DefId, - body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>, - ) -> Self { - DefinitelyAccessibleAnalysis { - tcx, - def_id, - body_with_facts, - } - } - - pub fn run_analysis( - &self, - ) -> AnalysisResult<PointwiseState<'mir, 'tcx, DefinitelyAccessibleState<'tcx>>> { - let body = &self.body_with_facts.body; - let def_init_analysis = DefinitelyInitializedAnalysis::new_relaxed(self.tcx, self.def_id, body); - let borrowed_analysis = MaybeBorrowedAnalysis::new(self.tcx, self.body_with_facts); - let def_init = def_init_analysis.run_fwd_analysis()?; - let borrowed = borrowed_analysis.run_analysis()?; - let location_table = self.body_with_facts.location_table.as_ref().unwrap(); - let borrowck_out_facts = self.body_with_facts.output_facts.as_ref().unwrap().as_ref(); - let var_live_on_entry: FxHashMap<_, _> = borrowck_out_facts - .var_live_on_entry - .iter() - .map(|(&point, live_vars)| (point, FxHashSet::from_iter(live_vars.iter().cloned()))) - .collect(); - let empty_locals_set: FxHashSet<mir::Local> = FxHashSet::default(); - let mut analysis_state = PointwiseState::default(body); - - for (block, block_data) in body.basic_blocks.iter_enumerated() { - // Initialize the state before each statement - for statement_index in 0..=block_data.statements.len() { - let location = mir::Location { - block, - statement_index, - }; - let def_init_before = def_init - .lookup_before(location) - .unwrap_or_else(|| panic!("No 'def_init' state before location {location:?}")); - let borrowed_before = borrowed - .lookup_before(location) - .unwrap_or_else(|| panic!("No 'borrowed' state before location {location:?}")); - let liveness_before = - var_live_on_entry.get(&location_table.start_index(location)).unwrap_or(&empty_locals_set); - let state = self.compute_accessible_state(def_init_before, borrowed_before, liveness_before); - state.check_invariant(location); - analysis_state.set_before(location, state); - } - - // Initialize the state of successors of terminators - let def_init_after_block = def_init - .lookup_after_block(block) - .unwrap_or_else(|| panic!("No 'def_init' state after block {block:?}")); - let borrowed_after_block = borrowed - .lookup_after_block(block) - .unwrap_or_else(|| panic!("No 'borrowed' state after block {block:?}")); - let available_after_block = analysis_state.lookup_mut_after_block(block); - for successor in block_data.terminator().successors() { - let def_init_after = def_init_after_block - .get(&successor) - .unwrap_or_else(|| panic!("No 'def_init' state from {block:?} to {successor:?}")); - let borrowed_after = borrowed_after_block - .get(&successor) - .unwrap_or_else(|| panic!("No 'borrowed' state from {block:?} to {successor:?}")); - let liveness_after = var_live_on_entry - .get(&location_table.start_index(successor.start_location())) - .unwrap_or(&empty_locals_set); - let state = self.compute_accessible_state(def_init_after, borrowed_after, liveness_after); - state.check_invariant(successor); - available_after_block.insert(successor, state); - } - } - - Ok(analysis_state) - } - - /// Compute the `definitely_available` state by subtracting the `maybe_borrowed` state from - /// the `definitely_initialized` one. - fn compute_accessible_state( - &self, - def_init: &DefinitelyInitializedState<'mir, 'tcx>, - borrowed: &MaybeBorrowedState<'tcx>, - live_vars: &FxHashSet<mir::Local>, - ) -> DefinitelyAccessibleState<'tcx> { - let body = &self.body_with_facts.body; - let mut definitely_accessible: FxHashSet<_> = def_init.get_def_init_places().clone(); - for (local, local_decl) in body.local_decls.iter_enumerated() { - let has_lifetimes = self.tcx.any_free_region_meets(&local_decl.ty, |_| true); - let maybe_expired = !live_vars.contains(&local); - if has_lifetimes && maybe_expired { - remove_place_from_set(body, self.tcx, local.into(), &mut definitely_accessible); - } - } - for &place in borrowed.get_maybe_mut_borrowed().iter() { - remove_place_from_set(body, self.tcx, place, &mut definitely_accessible); - } - let mut definitely_owned = definitely_accessible.clone(); - for &place in borrowed.get_maybe_shared_borrowed().iter() { - remove_place_from_set(body, self.tcx, place, &mut definitely_owned); - } - DefinitelyAccessibleState { - definitely_accessible, - definitely_owned, - } - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_accessible/mod.rs b/rr_frontend/analysis/src/domains/definitely_accessible/mod.rs deleted file mode 100644 index 811bedea..00000000 --- a/rr_frontend/analysis/src/domains/definitely_accessible/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use state::*; - -pub use self::analysis::*; diff --git a/rr_frontend/analysis/src/domains/definitely_accessible/state.rs b/rr_frontend/analysis/src/domains/definitely_accessible/state.rs deleted file mode 100644 index 05a191c0..00000000 --- a/rr_frontend/analysis/src/domains/definitely_accessible/state.rs +++ /dev/null @@ -1,263 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::fmt; - -use log::info; -use rr_rustc_interface::abi::FieldIdx; -use rr_rustc_interface::data_structures::fx::{FxHashMap, FxHashSet}; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::middle::{mir, ty}; -use rr_rustc_interface::span::source_map::SourceMap; -use rr_rustc_interface::target::abi::VariantIdx; -use serde::ser::SerializeMap; -use serde::{Serialize, Serializer}; - -use crate::mir_utils::{is_prefix, Place}; -use crate::PointwiseState; - -#[derive(Clone, Eq, PartialEq, Default)] -pub struct DefinitelyAccessibleState<'tcx> { - /// Places that are definitely not moved-out nor blocked by a *mutable* reference. - pub(super) definitely_accessible: FxHashSet<Place<'tcx>>, - /// Places that are definitely not moved-out nor blocked by a *mutable or shared* reference. - /// Considering pack/unpack operations, this should always be a subset of `definitely_accessible`. - pub(super) definitely_owned: FxHashSet<Place<'tcx>>, -} - -impl<'tcx> DefinitelyAccessibleState<'tcx> { - pub const fn get_definitely_accessible(&self) -> &FxHashSet<Place<'tcx>> { - &self.definitely_accessible - } - - pub const fn get_definitely_owned(&self) -> &FxHashSet<Place<'tcx>> { - &self.definitely_owned - } - - pub fn check_invariant(&self, location: impl fmt::Debug) { - for &owned_place in self.definitely_owned.iter() { - debug_assert!( - self.definitely_accessible - .iter() - .any(|&place| place == owned_place || is_prefix(owned_place, place)), - "In the state before {location:?} the place {owned_place:?} is owned but not accessible" - ); - } - } -} - -impl<'tcx> Serialize for DefinitelyAccessibleState<'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut seq = serializer.serialize_map(Some(2))?; - - let mut definitely_accessible_set: Vec<_> = self.definitely_accessible.iter().collect(); - definitely_accessible_set.sort_unstable(); - let definitely_accessible_strings: Vec<_> = - definitely_accessible_set.into_iter().map(|place| format!("{place:?}")).collect(); - seq.serialize_entry("accessible", &definitely_accessible_strings)?; - - let mut definitely_owned_set: Vec<_> = self.definitely_owned.iter().collect(); - definitely_owned_set.sort_unstable(); - let definitely_owned_strings: Vec<_> = - definitely_owned_set.into_iter().map(|place| format!("{place:?}")).collect(); - seq.serialize_entry("owned", &definitely_owned_strings)?; - - seq.end() - } -} - -impl fmt::Debug for DefinitelyAccessibleState<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", serde_json::to_string_pretty(&self).unwrap()) - } -} - -impl<'mir, 'tcx: 'mir> PointwiseState<'mir, 'tcx, DefinitelyAccessibleState<'tcx>> { - #[cfg(feature = "test-utils")] - /// Make a best-effort at injecting statements to check the analysis state. - pub fn generate_test_program(&self, tcx: TyCtxt<'tcx>, source_map: &SourceMap) -> String { - let mir_span = self.mir.span; - let source_file = source_map.lookup_source_file(mir_span.data().lo); - let source_lines_num = source_file.count_lines(); - let mut result: Vec<String> = (0..source_lines_num) - .map(|line_index| source_file.get_line(line_index).unwrap().to_string()) - .collect(); - let mut first_location_on_line: FxHashMap<usize, mir::Location> = FxHashMap::default(); - for (block, block_data) in self.mir.basic_blocks.iter_enumerated() { - for statement_index in 0..=block_data.statements.len() { - let location = mir::Location { - block, - statement_index, - }; - let span = self.mir.source_info(location).span; - if span.parent_callsite().is_some() { - info!("Statement {location:?} is generated by a macro"); - continue; - } - if source_map.is_multiline(span) { - info!("Statement {location:?} is on multiple lines"); - continue; - } - if let Ok(file_lines) = source_map.span_to_lines(span) { - if file_lines.lines.len() == 1 { - let line = file_lines.lines.first().unwrap(); - let line_num = line.line_index + 1; - info!("Statement {location:?} is on a single line at {line_num}"); - // Check that it parses as a statement - let line_seems_stmt = syn::parse_str::<syn::Stmt>(&result[line.line_index]).is_ok(); - if !line_seems_stmt { - info!("Statement {location:?} doesn't parse as a statement"); - continue; - } - // Keep the first span - let insert_or_replace = - if let Some(other_location) = first_location_on_line.get(&line_num) { - let other_span = self.mir.source_info(*other_location).span; - span < other_span - } else { - true - }; - if insert_or_replace { - first_location_on_line.insert(line_num, location); - } - } - } else { - info!("Statement {location:?} has no lines"); - } - } - } - let mut line_locations: Vec<_> = first_location_on_line.iter().collect(); - line_locations.sort_unstable_by(|left, right| right.0.cmp(left.0)); // From last to first - for (&line_num, &location) in line_locations { - info!("The first single-line statement on line {line_num} is {location:?}",); - let before = "\t\t\t"; - let after = " // Check analysis"; - let state = self.lookup_before(location).unwrap(); - let mut check_stmts = vec![]; - for &place in state.definitely_accessible.iter() { - if let Some(place_expr) = pretty_print_place(tcx, self.mir, place) { - check_stmts.push(format!("{before}let _ = & {place_expr};{after}")); - } - } - for &place in state.definitely_owned.iter() { - if let Some(place_expr) = pretty_print_place(tcx, self.mir, place) { - let local_decl = &self.mir.local_decls[place.local]; - // &mut cannot be used on locals that are not marked as mut - if local_decl.mutability != mir::Mutability::Not { - check_stmts.push(format!("{before}let _ = &mut {place_expr};{after}")); - } - } - } - // Inject the checks - result.insert(line_num - 1, check_stmts.join("\n")); - } - result.join("\n") - } -} - -fn pretty_print_place<'tcx>(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>, place: Place<'tcx>) -> Option<String> { - let mut pieces = vec![]; - - // Open parenthesis - for elem in place.projection.iter().rev() { - match elem { - mir::ProjectionElem::Deref => pieces.push("(*".to_string()), - mir::ProjectionElem::Field(..) => pieces.push("(".to_string()), - _ => {}, - } - } - - // Skip compiler-generated variables - if body.local_decls[place.local].from_compiler_desugaring() { - return None; - } - - // Find name of the local - let local_name = body - .var_debug_info - .iter() - .find(|var_debug_info| { - if let mir::VarDebugInfoContents::Place(debug_place) = var_debug_info.value { - if let Some(debug_local) = debug_place.as_local() { - return debug_local == place.local; - } - }; - false - }) - .map(|var_debug_info| var_debug_info.name); - if let Some(name) = local_name { - pieces.push(format!("{name}")); - } else { - return None; - } - - // Close parenthesis - let mut prev_ty = body.local_decls[place.local].ty; - let mut variant = None; - for (proj_base, elem) in place.iter_projections() { - match elem { - mir::ProjectionElem::Deref => { - pieces.push(")".to_string()); - }, - mir::ProjectionElem::Downcast(_, variant_index) => { - prev_ty = proj_base.ty(body, tcx).ty; - variant = Some(variant_index); - }, - mir::ProjectionElem::Field(field, field_ty) => { - let field_name = describe_field_from_ty(tcx, prev_ty, field, variant)?; - pieces.push(format!(".{field_name})")); - prev_ty = field_ty; - variant = None; - }, - mir::ProjectionElem::Index(..) - | mir::ProjectionElem::ConstantIndex { .. } - | mir::ProjectionElem::OpaqueCast(..) - | mir::ProjectionElem::Subslice { .. } => { - // It's not possible to move-out or borrow an individual element. - unreachable!() - }, - } - } - - Some(pieces.join("")) -} - -/// End-user visible description of the `field_index`nth field of `ty` -fn describe_field_from_ty( - tcx: TyCtxt<'_>, - ty: ty::Ty<'_>, - field: FieldIdx, - variant_index: Option<VariantIdx>, -) -> Option<String> { - if ty.is_box() { - // If the type is a box, the field is described from the boxed type - describe_field_from_ty(tcx, ty.boxed_ty(), field, variant_index) - } else { - match *ty.kind() { - ty::TyKind::Adt(def, _) => { - let variant = if let Some(idx) = variant_index { - assert!(def.is_enum()); - &def.variants()[idx] - } else { - def.non_enum_variant() - }; - Some(variant.fields[field].ident(tcx).to_string()) - }, - ty::TyKind::Tuple(_) => Some(field.index().to_string()), - ty::TyKind::Ref(_, ty, _) | ty::TyKind::RawPtr(ty::TypeAndMut { ty, .. }) => { - describe_field_from_ty(tcx, ty, field, variant_index) - }, - ty::TyKind::Array(ty, _) | ty::TyKind::Slice(ty) => { - describe_field_from_ty(tcx, ty, field, variant_index) - }, - ty::TyKind::Closure(..) | ty::TyKind::Generator(..) => { - // Supporting these cases is complex - None - }, - _ => unreachable!("Unexpected type `{:?}`", ty), - } - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_allocated/analysis.rs b/rr_frontend/analysis/src/domains/definitely_allocated/analysis.rs deleted file mode 100644 index 1805b4af..00000000 --- a/rr_frontend/analysis/src/domains/definitely_allocated/analysis.rs +++ /dev/null @@ -1,78 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::{AnalysisResult, FixpointEngine}; -use crate::domains::DefinitelyAllocatedState; - -pub struct DefinitelyAllocatedAnalysis<'mir, 'tcx: 'mir> { - def_id: DefId, - mir: &'mir mir::Body<'tcx>, -} - -impl<'mir, 'tcx: 'mir> DefinitelyAllocatedAnalysis<'mir, 'tcx> { - pub const fn new(def_id: DefId, mir: &'mir mir::Body<'tcx>) -> Self { - DefinitelyAllocatedAnalysis { def_id, mir } - } -} - -impl<'mir, 'tcx: 'mir> FixpointEngine<'mir, 'tcx> for DefinitelyAllocatedAnalysis<'mir, 'tcx> { - type State = DefinitelyAllocatedState<'mir, 'tcx>; - - fn def_id(&self) -> DefId { - self.def_id - } - - fn body(&self) -> &'mir mir::Body<'tcx> { - self.mir - } - - /// The bottom element of the lattice contains all possible places, - /// meaning all locals (which includes all their fields) - fn new_bottom(&self) -> Self::State { - DefinitelyAllocatedState { - def_allocated_locals: self.mir.local_decls.indices().collect(), - mir: self.mir, - } - } - - fn new_initial(&self) -> Self::State { - let mut locals_without_explicit_allocation: FxHashSet<_> = self.mir.vars_and_temps_iter().collect(); - for block in self.mir.basic_blocks.iter() { - for statement in &block.statements { - match statement.kind { - mir::StatementKind::StorageLive(local) | mir::StatementKind::StorageDead(local) => { - locals_without_explicit_allocation.remove(&local); - }, - _ => {}, - } - } - } - DefinitelyAllocatedState { - def_allocated_locals: locals_without_explicit_allocation, - mir: self.mir, - } - } - - fn need_to_widen(_counter: u32) -> bool { - false - } - - fn apply_statement_effect(&self, state: &mut Self::State, location: mir::Location) -> AnalysisResult<()> { - state.apply_statement_effect(location) - } - - fn apply_terminator_effect( - &self, - state: &Self::State, - location: mir::Location, - ) -> AnalysisResult<Vec<(mir::BasicBlock, Self::State)>> { - state.apply_terminator_effect(location) - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_allocated/mod.rs b/rr_frontend/analysis/src/domains/definitely_allocated/mod.rs deleted file mode 100644 index 8af925a3..00000000 --- a/rr_frontend/analysis/src/domains/definitely_allocated/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use self::analysis::*; -pub use self::state::*; diff --git a/rr_frontend/analysis/src/domains/definitely_allocated/state.rs b/rr_frontend/analysis/src/domains/definitely_allocated/state.rs deleted file mode 100644 index 367c8c6d..00000000 --- a/rr_frontend/analysis/src/domains/definitely_allocated/state.rs +++ /dev/null @@ -1,120 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::collections::BTreeSet; -use std::fmt; - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use rr_rustc_interface::middle::mir; -use serde::ser::SerializeSeq; -use serde::{Serialize, Serializer}; - -use crate::abstract_interpretation::AbstractState; -use crate::AnalysisError; - -/// A set of MIR locals that are definitely allocated at a program point -#[derive(Clone)] -pub struct DefinitelyAllocatedState<'mir, 'tcx: 'mir> { - pub(super) def_allocated_locals: FxHashSet<mir::Local>, - pub(super) mir: &'mir mir::Body<'tcx>, -} - -impl<'mir, 'tcx: 'mir> fmt::Debug for DefinitelyAllocatedState<'mir, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // ignore mir - f.debug_struct("DefinitelyAllocatedState") - .field("def_allocated_locals", &self.def_allocated_locals) - .finish() - } -} - -impl<'mir, 'tcx: 'mir> PartialEq for DefinitelyAllocatedState<'mir, 'tcx> { - fn eq(&self, other: &Self) -> bool { - self.def_allocated_locals == other.def_allocated_locals - } -} - -impl<'mir, 'tcx: 'mir> Eq for DefinitelyAllocatedState<'mir, 'tcx> {} - -impl<'mir, 'tcx: 'mir> Serialize for DefinitelyAllocatedState<'mir, 'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut seq = serializer.serialize_seq(Some(self.def_allocated_locals.len()))?; - let oredered_set: BTreeSet<_> = self.def_allocated_locals.iter().collect(); - for local in oredered_set { - seq.serialize_element(&format!("{:?}", local))?; - } - seq.end() - } -} - -impl<'mir, 'tcx: 'mir> DefinitelyAllocatedState<'mir, 'tcx> { - pub const fn get_def_allocated_locals(&self) -> &FxHashSet<mir::Local> { - &self.def_allocated_locals - } - - /// The top element of the lattice contains no locals - pub fn new_top(mir: &'mir mir::Body<'tcx>) -> Self { - Self { - def_allocated_locals: FxHashSet::default(), - mir, - } - } - - pub fn is_top(&self) -> bool { - self.def_allocated_locals.is_empty() - } - - /// Sets `local` as allocated. - fn set_local_allocated(&mut self, local: mir::Local) { - self.def_allocated_locals.insert(local); - } - - /// Sets `local` as (possibly) not allocated. - fn set_place_unallocated(&mut self, local: mir::Local) { - self.def_allocated_locals.remove(&local); - } - - pub(super) fn apply_statement_effect(&mut self, location: mir::Location) -> Result<(), AnalysisError> { - let statement = &self.mir[location.block].statements[location.statement_index]; - match statement.kind { - mir::StatementKind::StorageLive(local) => { - self.set_local_allocated(local); - }, - mir::StatementKind::StorageDead(local) => { - self.set_place_unallocated(local); - }, - _ => {}, - } - Ok(()) - } - - pub(super) fn apply_terminator_effect( - &self, - location: mir::Location, - ) -> Result<Vec<(mir::BasicBlock, Self)>, AnalysisError> { - let mut res_vec = Vec::new(); - let terminator = self.mir[location.block].terminator(); - for bb in terminator.successors() { - res_vec.push((bb, self.clone())); - } - Ok(res_vec) - } -} - -impl<'mir, 'tcx: 'mir> AbstractState for DefinitelyAllocatedState<'mir, 'tcx> { - fn is_bottom(&self) -> bool { - self.def_allocated_locals.len() == self.mir.local_decls.len() - } - - /// The lattice join intersects the two sets of locals - fn join(&mut self, other: &Self) { - self.def_allocated_locals.retain(|local| other.def_allocated_locals.contains(local)); - } - - fn widen(&mut self, _previous: &Self) { - unimplemented!() - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_initialized/analysis.rs b/rr_frontend/analysis/src/domains/definitely_initialized/analysis.rs deleted file mode 100644 index 093ade62..00000000 --- a/rr_frontend/analysis/src/domains/definitely_initialized/analysis.rs +++ /dev/null @@ -1,102 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::{AnalysisResult, FixpointEngine}; -use crate::domains::DefinitelyInitializedState; - -pub struct DefinitelyInitializedAnalysis<'mir, 'tcx: 'mir> { - tcx: TyCtxt<'tcx>, - def_id: DefId, - mir: &'mir mir::Body<'tcx>, - /// If the place is a Copy type, uninitialise the place iif `move_out_copy_types` is true. - move_out_copy_types: bool, -} - -impl<'mir, 'tcx: 'mir> DefinitelyInitializedAnalysis<'mir, 'tcx> { - pub const fn new(tcx: TyCtxt<'tcx>, def_id: DefId, mir: &'mir mir::Body<'tcx>) -> Self { - DefinitelyInitializedAnalysis { - tcx, - def_id, - mir, - move_out_copy_types: true, - } - } - - /// This analysis will not uninitialize Copy types when they are moved. - pub const fn new_relaxed(tcx: TyCtxt<'tcx>, def_id: DefId, mir: &'mir mir::Body<'tcx>) -> Self { - DefinitelyInitializedAnalysis { - tcx, - def_id, - mir, - move_out_copy_types: false, - } - } -} - -impl<'mir, 'tcx: 'mir> FixpointEngine<'mir, 'tcx> for DefinitelyInitializedAnalysis<'mir, 'tcx> { - type State = DefinitelyInitializedState<'mir, 'tcx>; - - fn def_id(&self) -> DefId { - self.def_id - } - - fn body(&self) -> &'mir mir::Body<'tcx> { - self.mir - } - - /// The bottom element of the lattice contains all possible places, - /// meaning all locals (which includes all their fields) - fn new_bottom(&self) -> Self::State { - let mut places = FxHashSet::default(); - for local in self.mir.local_decls.indices() { - places.insert(local.into()); - } - DefinitelyInitializedState { - def_init_places: places, - def_id: self.def_id, - mir: self.mir, - tcx: self.tcx, - } - } - - fn new_initial(&self) -> Self::State { - // Top = empty set - let mut places = FxHashSet::default(); - // join/insert places in arguments - // they are guaranteed to be disjoint and not prefixes of each other, - // therefore insert them directly - for local in self.mir.args_iter() { - places.insert(local.into()); - } - DefinitelyInitializedState { - def_init_places: places, - def_id: self.def_id, - mir: self.mir, - tcx: self.tcx, - } - } - - fn need_to_widen(_counter: u32) -> bool { - false // TODO: check - } - - fn apply_statement_effect(&self, state: &mut Self::State, location: mir::Location) -> AnalysisResult<()> { - state.apply_statement_effect(location, self.move_out_copy_types) - } - - fn apply_terminator_effect( - &self, - state: &Self::State, - location: mir::Location, - ) -> AnalysisResult<Vec<(mir::BasicBlock, Self::State)>> { - state.apply_terminator_effect(location, self.move_out_copy_types) - } -} diff --git a/rr_frontend/analysis/src/domains/definitely_initialized/mod.rs b/rr_frontend/analysis/src/domains/definitely_initialized/mod.rs deleted file mode 100644 index 8af925a3..00000000 --- a/rr_frontend/analysis/src/domains/definitely_initialized/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use self::analysis::*; -pub use self::state::*; diff --git a/rr_frontend/analysis/src/domains/definitely_initialized/state.rs b/rr_frontend/analysis/src/domains/definitely_initialized/state.rs deleted file mode 100644 index a5938fae..00000000 --- a/rr_frontend/analysis/src/domains/definitely_initialized/state.rs +++ /dev/null @@ -1,389 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::collections::BTreeSet; -use std::{fmt, mem}; - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::span::def_id::DefId; -use serde::ser::SerializeSeq; -use serde::{Serialize, Serializer}; - -use crate::abstract_interpretation::AbstractState; -use crate::mir_utils::*; -use crate::AnalysisError; - -/// A set of MIR places that are definitely initialized at a program point -/// -/// Invariant: we never have a place and any of its descendants in the -/// set at the same time. For example, having `x.f` and `x.f.g` in the -/// set at the same time is illegal. -#[derive(Clone)] -pub struct DefinitelyInitializedState<'mir, 'tcx: 'mir> { - pub(super) def_init_places: FxHashSet<Place<'tcx>>, - pub(super) def_id: DefId, - pub(super) mir: &'mir mir::Body<'tcx>, - pub(super) tcx: TyCtxt<'tcx>, -} - -impl<'mir, 'tcx: 'mir> fmt::Debug for DefinitelyInitializedState<'mir, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // ignore tcx & mir - f.debug_struct("DefinitelyInitializedState") - .field("def_init_places", &self.def_init_places) - .finish() - } -} - -impl<'mir, 'tcx: 'mir> PartialEq for DefinitelyInitializedState<'mir, 'tcx> { - fn eq(&self, other: &Self) -> bool { - // TODO: This assert is commented out because the stable hasher crashes - // on MIR that has region ids. - // - // debug_assert_eq!( - // { - // let mut stable_hasher = StableHasher::new(); - // self.mir.hash_stable( - // &mut self.tcx.get_stable_hashing_context(), - // &mut stable_hasher, - // ); - // stable_hasher.finish::<Fingerprint>() - // }, - // { - // let mut stable_hasher = StableHasher::new(); - // other.mir.hash_stable( - // &mut other.tcx.get_stable_hashing_context(), - // &mut stable_hasher, - // ); - // stable_hasher.finish::<Fingerprint>() - // }, - // ); - self.def_init_places == other.def_init_places - } -} - -impl<'mir, 'tcx: 'mir> Eq for DefinitelyInitializedState<'mir, 'tcx> {} - -impl<'mir, 'tcx: 'mir> Serialize for DefinitelyInitializedState<'mir, 'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut seq = serializer.serialize_seq(Some(self.def_init_places.len()))?; - let ordered_place_set: BTreeSet<_> = self.def_init_places.iter().collect(); - for place in ordered_place_set { - seq.serialize_element(&format!("{place:?}"))?; - } - seq.end() - } -} - -impl<'mir, 'tcx: 'mir> DefinitelyInitializedState<'mir, 'tcx> { - pub const fn get_def_init_places(&self) -> &FxHashSet<Place<'tcx>> { - &self.def_init_places - } - - pub fn get_def_init_mir_places(&self) -> FxHashSet<mir::Place<'tcx>> { - self.def_init_places.iter().map(|place| **place).collect() - } - - /// The top element of the lattice contains no places - pub fn new_top(def_id: DefId, mir: &'mir mir::Body<'tcx>, tcx: TyCtxt<'tcx>) -> Self { - Self { - def_init_places: FxHashSet::default(), - def_id, - mir, - tcx, - } - } - - pub fn is_top(&self) -> bool { - self.def_init_places.is_empty() - } - - pub fn check_invariant(&self) { - for &place1 in self.def_init_places.iter() { - for &place2 in self.def_init_places.iter() { - if place1 != place2 { - debug_assert!( - !is_prefix(place1, place2), - "The place {place2:?} is a prefix of the place {place1:?}" - ); - debug_assert!( - !is_prefix(place2, place1), - "The place {place1:?} is a prefix of the place {place2:?}" - ); - } - } - } - } - - /// Sets `place` as definitely initialized (see place_set/insert() - fn set_place_initialised(&mut self, place: mir::Place<'tcx>) { - let place = place.into(); - if cfg!(debug_assertions) { - self.check_invariant(); - } - - // First, check that the place is not already marked as - // definitely initialized. - if !self.def_init_places.iter().any(|¤t| is_prefix(place, current)) { - // To maintain the invariant that we do not have a place and its - // prefix in the set, we remove all places for which the given - // one is a prefix. - self.def_init_places.retain(|¤t| !is_prefix(current, place)); - self.def_init_places.insert(place); - // If all fields of a struct are definitely initialized, - // just keep info that the struct is definitely initialized. - collapse(self.mir, self.tcx, &mut self.def_init_places, place); - } - - if cfg!(debug_assertions) { - self.check_invariant(); - } - } - - /// Sets `place` as (possibly) uninitialised (see place_set/remove()) - fn set_place_uninitialised(&mut self, place: mir::Place<'tcx>) { - let place = place.into(); - if cfg!(debug_assertions) { - self.check_invariant(); - } - - let old_places = mem::take(&mut self.def_init_places); - for old_place in old_places { - if is_prefix(place, old_place) { - // We are uninitializing a field of the place `old_place`. - self.def_init_places.extend(expand(self.mir, self.tcx, old_place, place)); - } else if is_prefix(old_place, place) { - // We are uninitializing a place of which only some - // fields are initialized. Just remove all initialized - // fields. - // This happens when the target place is already - // initialized. - } else { - self.def_init_places.insert(old_place); - } - } - - // Check that place is properly removed - for &place1 in self.def_init_places.iter() { - debug_assert!( - !is_prefix(place1, place) && !is_prefix(place, place1), - "Bug: failed to ensure that there are no prefixes: place={place:?} place1={place1:?}" - ); - } - - if cfg!(debug_assertions) { - self.check_invariant(); - } - } - - /// If the operand is move, make the place uninitialised - /// If the place is a Copy type, uninitialise the place iif `move_out_copy_types` is true. - fn apply_operand_effect(&mut self, operand: &mir::Operand<'tcx>, move_out_copy_types: bool) { - if let mir::Operand::Move(place) = operand { - let uninitialise = if move_out_copy_types { - true - } else { - let ty = place.ty(&self.mir.local_decls, self.tcx).ty; - let param_env = self.tcx.param_env(self.def_id); - !is_copy(self.tcx, ty, param_env) - }; - - if uninitialise { - self.set_place_uninitialised(*place); - } - } - } - - /// If the place is a Copy type, uninitialise the place iif `move_out_copy_types` is true. - pub(super) fn apply_statement_effect( - &mut self, - location: mir::Location, - move_out_copy_types: bool, - ) -> Result<(), AnalysisError> { - let statement = &self.mir[location.block].statements[location.statement_index]; - match statement.kind { - mir::StatementKind::Assign(box (target, ref source)) => { - match source { - mir::Rvalue::Repeat(ref operand, _) - | mir::Rvalue::Cast(_, ref operand, _) - | mir::Rvalue::UnaryOp(_, ref operand) - | mir::Rvalue::Use(ref operand) => { - self.apply_operand_effect(operand, move_out_copy_types); - }, - mir::Rvalue::BinaryOp(_, box (ref operand1, ref operand2)) - | mir::Rvalue::CheckedBinaryOp(_, box (ref operand1, ref operand2)) => { - self.apply_operand_effect(operand1, move_out_copy_types); - self.apply_operand_effect(operand2, move_out_copy_types); - }, - mir::Rvalue::Aggregate(_, ref operands) => { - for operand in operands.iter() { - self.apply_operand_effect(operand, move_out_copy_types); - } - }, - _ => {}, - } - - self.set_place_initialised(target); - }, - mir::StatementKind::StorageDead(local) => { - self.set_place_uninitialised(local.into()); - }, - _ => {}, - } - - Ok(()) - } - - /// If the place is a Copy type, uninitialise the place iif `move_out_copy_types` is true. - pub(super) fn apply_terminator_effect( - &self, - location: mir::Location, - move_out_copy_types: bool, - ) -> Result<Vec<(mir::BasicBlock, Self)>, AnalysisError> { - let mut new_state = self.clone(); - let mut res_vec = Vec::new(); - let terminator = self.mir[location.block].terminator(); - match terminator.kind { - mir::TerminatorKind::SwitchInt { ref discr, .. } => { - // only operand has an effect on definitely initialized places, all successors - // get the same state - new_state.apply_operand_effect(discr, move_out_copy_types); - - for bb in terminator.successors() { - res_vec.push((bb, new_state.clone())); - } - }, - mir::TerminatorKind::Drop { - place, - target, - unwind, - .. - } => { - new_state.set_place_uninitialised(place); - res_vec.push((target, new_state)); - - if let mir::UnwindAction::Cleanup(bb) = unwind { - // imprecision for error states - res_vec.push((bb, Self::new_top(self.def_id, self.mir, self.tcx))); - } - }, - mir::TerminatorKind::Call { - ref func, - ref args, - destination, - target, - unwind, - .. - } => { - for arg in args.iter() { - new_state.apply_operand_effect(arg, move_out_copy_types); - } - new_state.apply_operand_effect(func, move_out_copy_types); - if let Some(bb) = target { - new_state.set_place_initialised(destination); - res_vec.push((bb, new_state)); - } - - if let mir::UnwindAction::Cleanup(bb) = unwind { - // imprecision for error states - res_vec.push((bb, Self::new_top(self.def_id, self.mir, self.tcx))); - } - }, - mir::TerminatorKind::Assert { - ref cond, - target, - unwind, - .. - } => { - new_state.apply_operand_effect(cond, move_out_copy_types); - res_vec.push((target, new_state)); - - if let mir::UnwindAction::Cleanup(bb) = unwind { - // imprecision for error states - res_vec.push((bb, Self::new_top(self.def_id, self.mir, self.tcx))); - } - }, - mir::TerminatorKind::Yield { - ref value, - resume, - drop, - .. - } => { - // TODO: resume_arg? - new_state.apply_operand_effect(value, move_out_copy_types); - res_vec.push((resume, new_state)); - - if let Some(bb) = drop { - // imprecision for error states - res_vec.push((bb, Self::new_top(self.def_id, self.mir, self.tcx))); - } - }, - mir::TerminatorKind::InlineAsm { .. } => { - return Err(AnalysisError::UnsupportedStatement(location)); - }, - - _ => { - for bb in terminator.successors() { - // no operation -> no change of state - res_vec.push((bb, self.clone())); - } - }, - } - - Ok(res_vec) - } -} - -impl<'mir, 'tcx: 'mir> AbstractState for DefinitelyInitializedState<'mir, 'tcx> { - fn is_bottom(&self) -> bool { - if self.def_init_places.len() == self.mir.local_decls.len() { - self.mir.local_decls.indices().all(|local| self.def_init_places.contains(&local.into())) - } else { - false - } - } - - /// The lattice join intersects the two place sets - fn join(&mut self, other: &Self) { - if cfg!(debug_assertions) { - self.check_invariant(); - other.check_invariant(); - } - - let mut intersection = FxHashSet::default(); - // TODO: make more efficient/modify self directly? - let mut propagate_places_fn = - |place_set1: &FxHashSet<Place<'tcx>>, place_set2: &FxHashSet<Place<'tcx>>| { - for &place in place_set1.iter() { - // find matching place in place_set2: - // if there is a matching place that contains exactly the same or more memory - // locations, place can be added to the resulting intersection - for &potential_prefix in place_set2.iter() { - if is_prefix(place, potential_prefix) { - intersection.insert(place); - break; - } - } - } - }; - - let self_places = &self.def_init_places; - let other_places = &other.def_init_places; - propagate_places_fn(self_places, other_places); - propagate_places_fn(other_places, self_places); - self.def_init_places = intersection; - - if cfg!(debug_assertions) { - self.check_invariant(); - } - } - - fn widen(&mut self, _previous: &Self) { - unimplemented!() - } -} diff --git a/rr_frontend/analysis/src/domains/framing/analysis.rs b/rr_frontend/analysis/src/domains/framing/analysis.rs deleted file mode 100644 index d27910e8..00000000 --- a/rr_frontend/analysis/src/domains/framing/analysis.rs +++ /dev/null @@ -1,113 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::borrowck::consumers::BodyWithBorrowckFacts; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor}; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::AnalysisResult; -use crate::domains::{DefinitelyAccessibleAnalysis, DefinitelyAccessibleState, FramingState}; -use crate::mir_utils::{get_blocked_place, remove_place_from_set}; -use crate::PointwiseState; - -pub struct FramingAnalysis<'mir, 'tcx: 'mir> { - tcx: TyCtxt<'tcx>, - def_id: DefId, - body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>, -} - -impl<'mir, 'tcx: 'mir> FramingAnalysis<'mir, 'tcx> { - pub const fn new( - tcx: TyCtxt<'tcx>, - def_id: DefId, - body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>, - ) -> Self { - FramingAnalysis { - tcx, - def_id, - body_with_facts, - } - } - - pub fn run_analysis(&self) -> AnalysisResult<PointwiseState<'mir, 'tcx, FramingState<'tcx>>> { - let acc_analysis = DefinitelyAccessibleAnalysis::new(self.tcx, self.def_id, self.body_with_facts); - let accessibility = acc_analysis.run_analysis()?; - let body = &self.body_with_facts.body; - let mut analysis_state = PointwiseState::default(body); - - // Set state_after_block - for (block, block_data) in body.basic_blocks.iter_enumerated() { - // Initialize the state before each statement and terminator - for statement_index in 0..=block_data.statements.len() { - let location = mir::Location { - block, - statement_index, - }; - let acc_before = accessibility - .lookup_before(location) - .unwrap_or_else(|| panic!("No 'accessibility' state before location {location:?}")); - let mut compute_framing = ComputeFramingState::initial(body, self.tcx, acc_before); - if let Some(stmt) = body.stmt_at(location).left() { - compute_framing.visit_statement(stmt, location); - } - if let Some(term) = body.stmt_at(location).right() { - compute_framing.visit_terminator(term, location); - } - let state = compute_framing.state; - state.check_invariant(acc_before, location); - analysis_state.set_before(location, state); - } - - // Leave empty the state after terminators - } - - Ok(analysis_state) - } -} - -struct ComputeFramingState<'mir, 'tcx: 'mir> { - body: &'mir mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - state: FramingState<'tcx>, -} - -impl<'mir, 'tcx: 'mir> ComputeFramingState<'mir, 'tcx> { - pub fn initial( - body: &'mir mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - acc: &DefinitelyAccessibleState<'tcx>, - ) -> Self { - let state = FramingState { - framed_accessible: acc.get_definitely_accessible().clone(), - framed_owned: acc.get_definitely_owned().clone(), - }; - ComputeFramingState { body, tcx, state } - } -} - -impl<'mir, 'tcx: 'mir> Visitor<'tcx> for ComputeFramingState<'mir, 'tcx> { - fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, _location: mir::Location) { - let place = (*place).into(); - match context { - PlaceContext::MutatingUse(_) | PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => { - // No permission can be framed - let blocked_place = get_blocked_place(self.tcx, place); - remove_place_from_set(self.body, self.tcx, blocked_place, &mut self.state.framed_owned); - remove_place_from_set(self.body, self.tcx, blocked_place, &mut self.state.framed_accessible); - }, - PlaceContext::NonMutatingUse(_) => { - // Read permission can be framed - let frozen_place = get_blocked_place(self.tcx, place); - remove_place_from_set(self.body, self.tcx, frozen_place, &mut self.state.framed_owned); - }, - PlaceContext::NonUse(_) => { - // Any permission can be framed - }, - } - } -} diff --git a/rr_frontend/analysis/src/domains/framing/mod.rs b/rr_frontend/analysis/src/domains/framing/mod.rs deleted file mode 100644 index 811bedea..00000000 --- a/rr_frontend/analysis/src/domains/framing/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use state::*; - -pub use self::analysis::*; diff --git a/rr_frontend/analysis/src/domains/framing/state.rs b/rr_frontend/analysis/src/domains/framing/state.rs deleted file mode 100644 index 12f48976..00000000 --- a/rr_frontend/analysis/src/domains/framing/state.rs +++ /dev/null @@ -1,98 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::fmt; - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use serde::ser::SerializeMap; -use serde::{Serialize, Serializer}; - -use crate::domains::DefinitelyAccessibleState; -use crate::mir_utils::{is_prefix, Place}; - -#[derive(Clone, Eq, PartialEq, Default)] -pub struct FramingState<'tcx> { - /// Places of `definitely_accessible` that can be framed across the *next* statement. - pub(super) framed_accessible: FxHashSet<Place<'tcx>>, - /// Places of `definitely_owned` that can be framed across the *next* statement. - pub(super) framed_owned: FxHashSet<Place<'tcx>>, -} - -impl<'tcx> FramingState<'tcx> { - pub const fn get_framed_accessible(&self) -> &FxHashSet<Place<'tcx>> { - &self.framed_accessible - } - - pub const fn get_framed_owned(&self) -> &FxHashSet<Place<'tcx>> { - &self.framed_owned - } - - pub fn check_invariant( - &self, - accessibility: &DefinitelyAccessibleState<'tcx>, - location: impl fmt::Debug, - ) { - for &owned_place in self.framed_owned.iter() { - debug_assert!( - self.framed_accessible - .iter() - .any(|&place| place == owned_place || is_prefix(owned_place, place)), - "In the state before {:?} the framed place {:?} is owned but not accessible", - location, - owned_place - ); - } - for &owned_place in self.framed_accessible.iter() { - debug_assert!( - accessibility - .get_definitely_accessible() - .iter() - .any(|&place| place == owned_place || is_prefix(owned_place, place)), - "In the state before {:?} the place {:?} is not accessible, but it is framed as accessible", - location, - owned_place - ); - } - for &owned_place in self.framed_owned.iter() { - debug_assert!( - accessibility - .get_definitely_owned() - .iter() - .any(|&place| place == owned_place || is_prefix(owned_place, place)), - "In the state before {:?} the place {:?} is not owned, but it is framed as owned", - location, - owned_place - ); - } - } -} - -impl<'tcx> Serialize for FramingState<'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut seq = serializer.serialize_map(Some(2))?; - let mut definitely_accessible_set: Vec<_> = self.framed_accessible.iter().collect(); - definitely_accessible_set.sort(); - let mut definitely_accessible_strings = vec![]; - for &place in definitely_accessible_set { - definitely_accessible_strings.push(format!("{:?}", place)); - } - seq.serialize_entry("frame_accessible", &definitely_accessible_strings)?; - let mut definitely_owned_set: Vec<_> = self.framed_owned.iter().collect(); - definitely_owned_set.sort(); - let mut definitely_owned_strings = vec![]; - for &place in definitely_owned_set { - definitely_owned_strings.push(format!("{:?}", place)); - } - seq.serialize_entry("frame_owned", &definitely_owned_strings)?; - seq.end() - } -} - -impl fmt::Debug for FramingState<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", serde_json::to_string_pretty(&self).unwrap()) - } -} diff --git a/rr_frontend/analysis/src/domains/maybe_borrowed/analysis.rs b/rr_frontend/analysis/src/domains/maybe_borrowed/analysis.rs deleted file mode 100644 index da788e04..00000000 --- a/rr_frontend/analysis/src/domains/maybe_borrowed/analysis.rs +++ /dev/null @@ -1,119 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use log::{error, trace}; -use rr_rustc_interface::borrowck::consumers::{BodyWithBorrowckFacts, RichLocation}; -use rr_rustc_interface::data_structures::fx::FxHashMap; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; - -use crate::abstract_interpretation::AnalysisResult; -use crate::domains::MaybeBorrowedState; -use crate::mir_utils::get_blocked_place; -use crate::{AnalysisError, PointwiseState}; - -pub struct MaybeBorrowedAnalysis<'mir, 'tcx: 'mir> { - tcx: TyCtxt<'tcx>, - body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>, -} - -impl<'mir, 'tcx: 'mir> MaybeBorrowedAnalysis<'mir, 'tcx> { - pub const fn new(tcx: TyCtxt<'tcx>, body_with_facts: &'mir BodyWithBorrowckFacts<'tcx>) -> Self { - MaybeBorrowedAnalysis { - tcx, - body_with_facts, - } - } - - pub fn run_analysis(&self) -> AnalysisResult<PointwiseState<'mir, 'tcx, MaybeBorrowedState<'tcx>>> { - let body = &self.body_with_facts.body; - let location_table = self.body_with_facts.location_table.as_ref().unwrap(); - let borrowck_in_facts = self.body_with_facts.input_facts.as_ref().unwrap(); - let borrowck_out_facts = self.body_with_facts.output_facts.as_ref().unwrap().as_ref(); - let loan_issued_at = &borrowck_in_facts.loan_issued_at; - let loan_live_at = &borrowck_out_facts.loan_live_at; - let loan_issued_at_location: FxHashMap<_, mir::Location> = loan_issued_at - .iter() - .map(|&(_, loan, point_index)| { - let rich_location = location_table.to_location(point_index); - let location = match rich_location { - RichLocation::Start(loc) | RichLocation::Mid(loc) => loc, - }; - (loan, location) - }) - .collect(); - let mut analysis_state: PointwiseState<MaybeBorrowedState> = PointwiseState::default(body); - - trace!("There are {} loan_live_at output facts", loan_live_at.len()); - for (&point_index, loans) in loan_live_at.iter() { - let rich_location = location_table.to_location(point_index); - if let RichLocation::Start(location) = rich_location { - trace!(" Location {:?}:", rich_location); - let state = analysis_state.lookup_mut_before(location).unwrap(); - for loan in loans { - let loan_location = loan_issued_at_location[loan]; - let loan_stmt = &body[loan_location.block].statements[loan_location.statement_index]; - if let mir::StatementKind::Assign(box (lhs, rhs)) = &loan_stmt.kind { - if let mir::Rvalue::Ref(_region, borrow_kind, borrowed_place) = rhs { - trace!( - " Loan {:?}: {:?} = & {:?} {:?}", - loan, - lhs, - borrow_kind, - borrowed_place, - ); - let blocked_place = get_blocked_place(self.tcx, (*borrowed_place).into()); - trace!(" Blocking {:?}: {:?}", borrow_kind, blocked_place); - match borrow_kind { - mir::BorrowKind::Shared => { - state.maybe_shared_borrowed.insert(blocked_place); - }, - mir::BorrowKind::Mut { .. } => { - state.maybe_mut_borrowed.insert(blocked_place); - }, - _ => { - error!("Unexpected borrow kind: {:?}", borrow_kind); - return Err(AnalysisError::UnsupportedStatement(loan_location)); - }, - } - } else { - error!("Unexpected RHS: {:?}", rhs); - return Err(AnalysisError::UnsupportedStatement(loan_location)); - } - } else { - error!( - "Loan {:?} issued by an unexpected statement {:?} at {:?}", - loan, loan_stmt, loan_location, - ); - return Err(AnalysisError::UnsupportedStatement(loan_location)); - } - } - } - } - - // Set state_after_block - for (block, block_data) in body.basic_blocks.iter_enumerated() { - for successor in block_data.terminator().successors() { - let state = analysis_state - .lookup_before(mir::Location { - block: successor, - statement_index: 0, - }) - .unwrap() - .to_owned(); - let state_after = analysis_state.lookup_mut_after_block(block).get_mut(&successor).unwrap(); - debug_assert!( - (state_after.maybe_shared_borrowed.is_empty() - && state_after.maybe_mut_borrowed.is_empty()) - || state_after == &state - ); - *state_after = state; - } - } - - Ok(analysis_state) - } -} diff --git a/rr_frontend/analysis/src/domains/maybe_borrowed/mod.rs b/rr_frontend/analysis/src/domains/maybe_borrowed/mod.rs deleted file mode 100644 index 811bedea..00000000 --- a/rr_frontend/analysis/src/domains/maybe_borrowed/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use state::*; - -pub use self::analysis::*; diff --git a/rr_frontend/analysis/src/domains/maybe_borrowed/state.rs b/rr_frontend/analysis/src/domains/maybe_borrowed/state.rs deleted file mode 100644 index 65caaa3c..00000000 --- a/rr_frontend/analysis/src/domains/maybe_borrowed/state.rs +++ /dev/null @@ -1,48 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use serde::ser::SerializeMap; -use serde::{Serialize, Serializer}; - -use crate::mir_utils::Place; - -#[derive(Clone, Eq, PartialEq, Default)] -pub struct MaybeBorrowedState<'tcx> { - pub(super) maybe_shared_borrowed: FxHashSet<Place<'tcx>>, - pub(super) maybe_mut_borrowed: FxHashSet<Place<'tcx>>, -} - -impl<'tcx> MaybeBorrowedState<'tcx> { - pub const fn get_maybe_shared_borrowed(&self) -> &FxHashSet<Place<'tcx>> { - &self.maybe_shared_borrowed - } - - pub const fn get_maybe_mut_borrowed(&self) -> &FxHashSet<Place<'tcx>> { - &self.maybe_mut_borrowed - } -} - -impl<'tcx> Serialize for MaybeBorrowedState<'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut seq = serializer.serialize_map(Some(2))?; - let mut maybe_shared_borrowed_set: Vec<_> = self.maybe_shared_borrowed.iter().collect(); - maybe_shared_borrowed_set.sort(); - let mut maybe_shared_borrowed_strings = vec![]; - for &place in maybe_shared_borrowed_set { - maybe_shared_borrowed_strings.push(format!("{:?}", place)); - } - seq.serialize_entry("frozen", &maybe_shared_borrowed_strings)?; - let mut maybe_mut_borrowed_set: Vec<_> = self.maybe_mut_borrowed.iter().collect(); - maybe_mut_borrowed_set.sort(); - let mut maybe_mut_borrowed_strings = vec![]; - for &place in maybe_mut_borrowed_set { - maybe_mut_borrowed_strings.push(format!("{:?}", place)); - } - seq.serialize_entry("blocked", &maybe_mut_borrowed_strings)?; - seq.end() - } -} diff --git a/rr_frontend/analysis/src/domains/mod.rs b/rr_frontend/analysis/src/domains/mod.rs deleted file mode 100644 index 33551965..00000000 --- a/rr_frontend/analysis/src/domains/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod definitely_accessible; -mod definitely_allocated; -mod definitely_initialized; -mod framing; -mod maybe_borrowed; -mod reaching_definitions; - -pub use definitely_accessible::*; -pub use definitely_allocated::*; -pub use definitely_initialized::*; -pub use framing::*; -pub use maybe_borrowed::*; -pub use reaching_definitions::*; diff --git a/rr_frontend/analysis/src/domains/reaching_definitions/analysis.rs b/rr_frontend/analysis/src/domains/reaching_definitions/analysis.rs deleted file mode 100644 index 58271092..00000000 --- a/rr_frontend/analysis/src/domains/reaching_definitions/analysis.rs +++ /dev/null @@ -1,80 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use rr_rustc_interface::data_structures::fx::{FxHashMap, FxHashSet}; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; -use rr_rustc_interface::span::def_id::DefId; - -use crate::abstract_interpretation::{AnalysisResult, FixpointEngine}; -use crate::domains::{DefLocation, ReachingDefsState}; - -pub struct ReachingDefsAnalysis<'mir, 'tcx: 'mir> { - tcx: TyCtxt<'tcx>, - def_id: DefId, - mir: &'mir mir::Body<'tcx>, -} - -impl<'mir, 'tcx: 'mir> ReachingDefsAnalysis<'mir, 'tcx> { - pub const fn new(tcx: TyCtxt<'tcx>, def_id: DefId, mir: &'mir mir::Body<'tcx>) -> Self { - ReachingDefsAnalysis { tcx, def_id, mir } - } -} - -impl<'mir, 'tcx: 'mir> FixpointEngine<'mir, 'tcx> for ReachingDefsAnalysis<'mir, 'tcx> { - type State = ReachingDefsState<'mir, 'tcx>; - - fn def_id(&self) -> DefId { - self.def_id - } - - fn body(&self) -> &'mir mir::Body<'tcx> { - self.mir - } - - /// The bottom element of the lattice contains no definitions, - /// i.e. all sets of reaching definitions are empty - /// - /// For a completely new bottom element we do not even insert any locals with sets into the map. - fn new_bottom(&self) -> Self::State { - ReachingDefsState { - reaching_defs: FxHashMap::default(), - mir: self.mir, - tcx: self.tcx, - } - } - - fn new_initial(&self) -> Self::State { - let mut reaching_defs: FxHashMap<mir::Local, FxHashSet<DefLocation>> = FxHashMap::default(); - // insert parameters - for (idx, local) in self.mir.args_iter().enumerate() { - let location_set = reaching_defs.entry(local).or_default(); - location_set.insert(DefLocation::Parameter(idx)); - } - ReachingDefsState { - reaching_defs, - mir: self.mir, - tcx: self.tcx, - } - } - - fn need_to_widen(_counter: u32) -> bool { - // only consider static information (assignments) => no lattice of infinite height - false - } - - fn apply_statement_effect(&self, state: &mut Self::State, location: mir::Location) -> AnalysisResult<()> { - state.apply_statement_effect(location) - } - - fn apply_terminator_effect( - &self, - state: &Self::State, - location: mir::Location, - ) -> AnalysisResult<Vec<(mir::BasicBlock, Self::State)>> { - state.apply_terminator_effect(location) - } -} diff --git a/rr_frontend/analysis/src/domains/reaching_definitions/mod.rs b/rr_frontend/analysis/src/domains/reaching_definitions/mod.rs deleted file mode 100644 index 811bedea..00000000 --- a/rr_frontend/analysis/src/domains/reaching_definitions/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mod analysis; -mod state; - -pub use state::*; - -pub use self::analysis::*; diff --git a/rr_frontend/analysis/src/domains/reaching_definitions/state.rs b/rr_frontend/analysis/src/domains/reaching_definitions/state.rs deleted file mode 100644 index 9b5a3c04..00000000 --- a/rr_frontend/analysis/src/domains/reaching_definitions/state.rs +++ /dev/null @@ -1,179 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::collections::{BTreeMap, BTreeSet}; -use std::fmt; - -use rr_rustc_interface::data_structures::fingerprint::Fingerprint; -use rr_rustc_interface::data_structures::fx::{FxHashMap, FxHashSet}; -use rr_rustc_interface::data_structures::stable_hasher::{HashStable, StableHasher}; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::TyCtxt; -use serde::ser::SerializeMap; -use serde::{Serialize, Serializer}; - -use crate::abstract_interpretation::AbstractState; -use crate::mir_utils::location_to_stmt_str; -use crate::AnalysisError; - -/// A set of definition locations and function parameter indices per Local, -/// meaning that the Local might still have the value -/// which was assigned at the location or passed as a parameter -/// -/// derived from prusti-interface/.../mir_analyses/liveness -#[derive(Clone)] -pub struct ReachingDefsState<'mir, 'tcx: 'mir> { - // Local -> Location OR index of function parameter - pub(super) reaching_defs: FxHashMap<mir::Local, FxHashSet<DefLocation>>, - pub(super) mir: &'mir mir::Body<'tcx>, // just for context - pub(super) tcx: TyCtxt<'tcx>, -} - -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] -pub enum DefLocation { - Assignment(mir::Location), - /// The value is the index of the function parameter in ``mir.args_iter()`` - Parameter(usize), -} - -impl<'mir, 'tcx: 'mir> fmt::Debug for ReachingDefsState<'mir, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // ignore mir - f.debug_struct("ReachingDefsState").field("reaching_defs", &self.reaching_defs).finish() - } -} - -#[allow(clippy::debug_assert_with_mut_call)] -impl<'mir, 'tcx: 'mir> PartialEq for ReachingDefsState<'mir, 'tcx> { - fn eq(&self, other: &Self) -> bool { - debug_assert_eq!( - { - let mut stable_hasher = StableHasher::new(); - self.tcx.with_stable_hashing_context(|mut ctx| { - self.mir.hash_stable(&mut ctx, &mut stable_hasher) - }); - stable_hasher.finish::<Fingerprint>() - }, - { - let mut stable_hasher = StableHasher::new(); - other.tcx.with_stable_hashing_context(|mut ctx| { - other.mir.hash_stable(&mut ctx, &mut stable_hasher) - }); - stable_hasher.finish::<Fingerprint>() - }, - ); - // Ignore the `mir` field. - self.reaching_defs == other.reaching_defs - } -} -impl<'mir, 'tcx: 'mir> Eq for ReachingDefsState<'mir, 'tcx> {} - -impl<'mir, 'tcx: 'mir> Serialize for ReachingDefsState<'mir, 'tcx> { - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut map = serializer.serialize_map(Some(self.reaching_defs.len()))?; - let ordered_ass_map: BTreeMap<_, _> = self.reaching_defs.iter().collect(); - for (local, location_set) in ordered_ass_map { - let ordered_loc_set: BTreeSet<_> = location_set.iter().collect(); - let mut location_vec = Vec::with_capacity(ordered_loc_set.len()); - for location in ordered_loc_set { - match location { - DefLocation::Assignment(l) => { - let stmt = location_to_stmt_str(*l, self.mir); - // Include the location to differentiate between same statement on - // different lines. - location_vec.push(format!("{l:?}: {stmt}")); - }, - DefLocation::Parameter(idx) => location_vec.push(format!("arg{idx}")), - } - } - map.serialize_entry(&format!("{local:?}"), &location_vec)?; - } - map.end() - } -} - -impl<'mir, 'tcx: 'mir> ReachingDefsState<'mir, 'tcx> { - pub(super) fn apply_statement_effect(&mut self, location: mir::Location) -> Result<(), AnalysisError> { - let stmt = &self.mir[location.block].statements[location.statement_index]; - if let mir::StatementKind::Assign(box (ref target, _)) = stmt.kind { - if let Some(local) = target.as_local() { - let location_set = self.reaching_defs.entry(local).or_default(); - location_set.clear(); - location_set.insert(DefLocation::Assignment(location)); - } - } - - Ok(()) - } - - pub(super) fn apply_terminator_effect( - &self, - location: mir::Location, - ) -> Result<Vec<(mir::BasicBlock, Self)>, AnalysisError> { - let mut res_vec = Vec::new(); - let terminator = self.mir[location.block].terminator(); - match terminator.kind { - mir::TerminatorKind::Call { - ref destination, - target, - unwind, - .. - } => { - if let Some(bb) = target { - let mut dest_state = self.clone(); - if let Some(local) = destination.as_local() { - let location_set = dest_state.reaching_defs.entry(local).or_default(); - location_set.clear(); - location_set.insert(DefLocation::Assignment(location)); - } - res_vec.push((bb, dest_state)); - } - - if let mir::UnwindAction::Cleanup(bb) = unwind { - let mut cleanup_state = self.clone(); - // error state -> be conservative & add destination as possible reaching def - // while keeping all others - if target.is_some() { - if let Some(local) = destination.as_local() { - let location_set = cleanup_state.reaching_defs.entry(local).or_default(); - location_set.insert(DefLocation::Assignment(location)); - } - } - res_vec.push((bb, cleanup_state)); - } - }, - mir::TerminatorKind::InlineAsm { .. } => { - return Err(AnalysisError::UnsupportedStatement(location)); - }, - _ => { - for bb in terminator.successors() { - // no assignment -> no change of state - res_vec.push((bb, self.clone())); - } - }, - } - - Ok(res_vec) - } -} - -impl<'mir, 'tcx: 'mir> AbstractState for ReachingDefsState<'mir, 'tcx> { - fn is_bottom(&self) -> bool { - self.reaching_defs.iter().all(|(_, set)| set.is_empty()) - } - - fn join(&mut self, other: &Self) { - for (local, other_locations) in other.reaching_defs.iter() { - let location_set = self.reaching_defs.entry(*local).or_default(); - location_set.extend(other_locations); - } - } - - fn widen(&mut self, _previous: &Self) { - // assignments are static info => cannot grow infinitely => widening should not be needed - unimplemented!() - } -} diff --git a/rr_frontend/analysis/src/lib.rs b/rr_frontend/analysis/src/lib.rs deleted file mode 100644 index b64a5266..00000000 --- a/rr_frontend/analysis/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#![feature(rustc_private)] -#![feature(box_patterns)] -#![allow(clippy::all)] - -pub mod abstract_interpretation; -mod analysis_error; -pub mod domains; -pub mod mir_utils; -mod pointwise_state; - -pub use analysis_error::AnalysisError; -pub use pointwise_state::PointwiseState; diff --git a/rr_frontend/analysis/src/mir_utils.rs b/rr_frontend/analysis/src/mir_utils.rs deleted file mode 100644 index cffd8a87..00000000 --- a/rr_frontend/analysis/src/mir_utils.rs +++ /dev/null @@ -1,321 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -//! Various helper functions for working with `mir` types. -//! copied from prusti-interface/utils - -//use rustc_abi::FieldIdx; -use std::mem; - -use rr_rustc_interface::data_structures::fx::FxHashSet; -use rr_rustc_interface::infer::infer::TyCtxtInferExt; -use rr_rustc_interface::middle::mir; -use rr_rustc_interface::middle::ty::{self, TyCtxt}; -use rr_rustc_interface::trait_selection::infer::InferCtxtExt; - -#[repr(transparent)] -#[derive(Clone, Copy, Eq, PartialEq, Hash)] -/// A wrapper for `mir::Place` that implements `Ord`. -pub struct Place<'tcx>(mir::Place<'tcx>); - -/// A trait enabling `Place` and `mir::Place` to be treated in the same way -pub trait PlaceImpl<'tcx> { - fn from_mir_place(_: mir::Place<'tcx>) -> Self; - fn to_mir_place(self) -> mir::Place<'tcx>; -} - -impl<'tcx> From<mir::Place<'tcx>> for Place<'tcx> { - fn from(place: mir::Place<'tcx>) -> Self { - Self(place) - } -} - -impl<'tcx> From<mir::Local> for Place<'tcx> { - fn from(local: mir::Local) -> Self { - Self(local.into()) - } -} - -impl<'tcx> PartialOrd for Place<'tcx> { - fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { - Some(self.cmp(other)) - } -} - -impl<'tcx> Ord for Place<'tcx> { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.0.local.cmp(&other.0.local).then(self.0.projection.cmp(other.0.projection)) - } -} - -impl<'tcx> std::fmt::Debug for Place<'tcx> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} - -impl<'tcx> std::ops::Deref for Place<'tcx> { - type Target = mir::Place<'tcx>; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl<'tcx> PlaceImpl<'tcx> for Place<'tcx> { - fn from_mir_place(place: mir::Place<'tcx>) -> Place<'tcx> { - Place(place) - } - - fn to_mir_place(self) -> mir::Place<'tcx> { - self.0 - } -} - -impl<'tcx> PlaceImpl<'tcx> for mir::Place<'tcx> { - fn from_mir_place(place: mir::Place<'tcx>) -> mir::Place<'tcx> { - place - } - - fn to_mir_place(self) -> mir::Place<'tcx> { - self - } -} - -/// Convert a `location` to a string representing the statement or terminator at that `location` -pub fn location_to_stmt_str(location: mir::Location, mir: &mir::Body) -> String { - let bb_mir = &mir[location.block]; - if location.statement_index < bb_mir.statements.len() { - let stmt = &bb_mir.statements[location.statement_index]; - format!("{stmt:?}") - } else { - // location = terminator - let terminator = bb_mir.terminator(); - format!("{:?}", terminator.kind) - } -} - -/// Check if the place `potential_prefix` is a prefix of `place`. For example: -/// -/// + `is_prefix(x.f, x.f) == true` -/// + `is_prefix(x.f.g, x.f) == true` -/// + `is_prefix(x.f, x.f.g) == false` -pub(crate) fn is_prefix<'tcx>(place: Place<'tcx>, potential_prefix: Place<'tcx>) -> bool { - if place.local != potential_prefix.local || place.projection.len() < potential_prefix.projection.len() { - false - } else { - place.projection.iter().zip(potential_prefix.projection.iter()).all(|(e1, e2)| e1 == e2) - } -} - -/// Expands a place `x.f.g` of type struct into a vector of places for -/// each of the struct's fields `{x.f.g.f, x.f.g.g, x.f.g.h}`. If -/// `without_field` is not `None`, then omits that field from the final -/// vector. -pub fn expand_struct_place<'tcx, P: PlaceImpl<'tcx> + std::marker::Copy>( - place: P, - mir: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - without_field: Option<usize>, -) -> Vec<P> { - let mut places: Vec<P> = Vec::new(); - let typ = place.to_mir_place().ty(mir, tcx); - if !matches!(typ.ty.kind(), ty::Adt(..)) { - assert!( - typ.variant_index.is_none(), - "We have assumed that only enums can have variant_index set. Got {typ:?}." - ); - } - match typ.ty.kind() { - ty::Adt(def, substs) => { - let variant = typ.variant_index.map(|i| def.variant(i)).unwrap_or_else(|| def.non_enum_variant()); - for (index, field_def) in variant.fields.iter().enumerate() { - if Some(index) != without_field { - let field_place = - tcx.mk_place_field(place.to_mir_place(), index.into(), field_def.ty(tcx, substs)); - places.push(P::from_mir_place(field_place)); - } - } - }, - ty::Tuple(slice) => { - for (index, arg) in slice.iter().enumerate() { - if Some(index) != without_field { - let field_place = tcx.mk_place_field(place.to_mir_place(), index.into(), arg); - places.push(P::from_mir_place(field_place)); - } - } - }, - ty::Closure(_, substs) => { - for (index, subst_ty) in substs.as_closure().upvar_tys().iter().enumerate() { - if Some(index) != without_field { - let field_place = tcx.mk_place_field(place.to_mir_place(), index.into(), subst_ty); - places.push(P::from_mir_place(field_place)); - } - } - }, - ty::Generator(_, substs, _) => { - for (index, subst_ty) in substs.as_generator().upvar_tys().iter().enumerate() { - if Some(index) != without_field { - let field_place = tcx.mk_place_field(place.to_mir_place(), index.into(), subst_ty); - places.push(P::from_mir_place(field_place)); - } - } - }, - ty => unreachable!("ty={:?}", ty), - } - places -} - -/// Expand `current_place` one level down by following the `guide_place`. -/// Returns the new `current_place` and a vector containing other places that -/// could have resulted from the expansion. -pub fn expand_one_level<'tcx>( - mir: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - current_place: Place<'tcx>, - guide_place: Place<'tcx>, -) -> (Place<'tcx>, Vec<Place<'tcx>>) { - let index = current_place.projection.len(); - let new_projection = - tcx.mk_place_elems_from_iter(current_place.projection.iter().chain([guide_place.projection[index]])); - let new_current_place = Place(mir::Place { - local: current_place.local, - projection: new_projection, - }); - let other_places = match guide_place.projection[index] { - mir::ProjectionElem::Field(projected_field, _field_ty) => { - expand_struct_place(current_place, mir, tcx, Some(projected_field.index())) - }, - mir::ProjectionElem::Deref - | mir::ProjectionElem::Index(..) - | mir::ProjectionElem::ConstantIndex { .. } - | mir::ProjectionElem::Subslice { .. } - | mir::ProjectionElem::Downcast(..) - | mir::ProjectionElem::OpaqueCast(..) => vec![], - }; - (new_current_place, other_places) -} - -/// Subtract the `subtrahend` place from the `minuend` place. The -/// subtraction is defined as set minus between `minuend` place replaced -/// with a set of places that are unrolled up to the same level as -/// `subtrahend` and the singleton `subtrahend` set. For example, -/// `subtract(x.f, x.f.g.h)` is performed by unrolling `x.f` into -/// `{x.g, x.h, x.f.f, x.f.h, x.f.g.f, x.f.g.g, x.f.g.h}` and -/// subtracting `{x.f.g.h}` from it, which results into `{x.g, x.h, -/// x.f.f, x.f.h, x.f.g.f, x.f.g.g}`. -pub(crate) fn expand<'tcx>( - mir: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - mut minuend: Place<'tcx>, - subtrahend: Place<'tcx>, -) -> Vec<Place<'tcx>> { - assert!(is_prefix(subtrahend, minuend), "The minuend must be the prefix of the subtrahend."); - let mut place_set = Vec::new(); - while minuend.projection.len() < subtrahend.projection.len() { - let (new_minuend, places) = expand_one_level(mir, tcx, minuend, subtrahend); - minuend = new_minuend; - place_set.extend(places); - } - place_set -} - -/// Try to collapse all places in `places` by following the -/// `guide_place`. This function is basically the reverse of -/// `expand_struct_place`. -pub(crate) fn collapse<'tcx>( - mir: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - places: &mut FxHashSet<Place<'tcx>>, - guide_place: Place<'tcx>, -) { - fn recurse<'tcx>( - mir: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - places: &mut FxHashSet<Place<'tcx>>, - current_place: Place<'tcx>, - guide_place: Place<'tcx>, - ) { - if current_place != guide_place { - let (new_current_place, mut expansion) = expand_one_level(mir, tcx, current_place, guide_place); - recurse(mir, tcx, places, new_current_place, guide_place); - expansion.push(new_current_place); - if expansion.iter().all(|place| places.contains(place)) { - for place in expansion { - places.remove(&place); - } - places.insert(current_place); - } - } - } - recurse(mir, tcx, places, guide_place.local.into(), guide_place); -} - -/// Remove all extensions of a place from a set, unpacking prefixes as much as needed. -pub fn remove_place_from_set<'tcx>( - body: &mir::Body<'tcx>, - tcx: TyCtxt<'tcx>, - to_remove: Place<'tcx>, - set: &mut FxHashSet<Place<'tcx>>, -) { - let old_set = mem::take(set); - for old_place in old_set { - if is_prefix(to_remove, old_place) { - // Unpack `old_place` and remove `to_remove`. - set.extend(expand(body, tcx, old_place, to_remove)); - } else if is_prefix(old_place, to_remove) { - // `to_remove` is a prefix of `old_place`. So, it should *not* be added to `set`. - } else { - // `old_place` and `to_remove` are unrelated. - set.insert(old_place); - } - } -} - -pub fn is_copy<'tcx>(tcx: ty::TyCtxt<'tcx>, ty: ty::Ty<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool { - if let ty::TyKind::Ref(_, _, mutability) = ty.kind() { - // Shared references are copy, mutable references are not. - // `type_implements_trait` doesn't consider that. - matches!(mutability, mir::Mutability::Not) - } else if let Some(copy_trait) = tcx.lang_items().copy_trait() { - let infcx = tcx.infer_ctxt().build(); - // If `ty` has any inference variables (e.g. a region variable), then using it with - // the freshly-created `InferCtxt` (i.e. `tcx.infer_ctxt().enter(..)`) will cause - // a panic, since those inference variables don't exist in the new `InferCtxt`. - // See: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20Panic.20in.20is_copy_modulo_regions - infcx - .type_implements_trait(copy_trait, [infcx.freshen(ty)], param_env) - .must_apply_considering_regions() - } else { - false - } -} - -/// Given an assignment `let _ = & <borrowed_place>`, this function returns the place that is -/// blocked by the loan. -/// For example, `let _ = &x.f.g` blocks just `x.f.g`, but `let _ = &x.f[0].g` blocks `x.f`. -pub fn get_blocked_place<'tcx>(tcx: TyCtxt<'tcx>, borrowed: Place<'tcx>) -> Place<'tcx> { - for (place_ref, place_elem) in borrowed.iter_projections() { - match place_elem { - mir::ProjectionElem::Deref - | mir::ProjectionElem::Index(..) - | mir::ProjectionElem::ConstantIndex { .. } - | mir::ProjectionElem::Subslice { .. } => { - return (mir::Place { - local: place_ref.local, - projection: tcx.mk_place_elems(place_ref.projection), - }) - .into(); - }, - mir::ProjectionElem::Field(..) - | mir::ProjectionElem::Downcast(..) - | mir::ProjectionElem::OpaqueCast(..) => { - // Continue - }, - } - } - borrowed -} diff --git a/rr_frontend/analysis/src/pointwise_state.rs b/rr_frontend/analysis/src/pointwise_state.rs deleted file mode 100644 index 7dd0bff6..00000000 --- a/rr_frontend/analysis/src/pointwise_state.rs +++ /dev/null @@ -1,161 +0,0 @@ -// © 2021, ETH Zurich -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -use std::collections::BTreeMap; -use std::fmt; - -use rr_rustc_interface::data_structures::fx::FxHashMap; -use rr_rustc_interface::middle::mir; -use serde::ser::SerializeMap; -use serde::{Serialize, Serializer}; - -/// Records the state of the analysis at every program point and CFG edge of `mir`. -pub struct PointwiseState<'mir, 'tcx: 'mir, S: Serialize> { - state_before: FxHashMap<mir::Location, S>, - /// Maps each basic block to a map of its successor blocks to the state on the CFG edge. - state_after_block: FxHashMap<mir::BasicBlock, FxHashMap<mir::BasicBlock, S>>, - // Needed for translation of location to statement/terminator in serialization. - pub(crate) mir: &'mir mir::Body<'tcx>, -} - -impl<'mir, 'tcx: 'mir, S> fmt::Debug for PointwiseState<'mir, 'tcx, S> -where - S: Serialize + fmt::Debug, -{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // ignore tcx - f.debug_struct("PointwiseState") - .field("state_before", &self.state_before) - .field("state_after_block", &self.state_after_block) - .field("mir", &self.mir) - .finish() - } -} - -impl<'mir, 'tcx: 'mir, S: Serialize> Serialize for PointwiseState<'mir, 'tcx, S> { - /// Serialize PointwiseState by translating it to a combination of vectors, tuples and maps, - /// such that serde can automatically translate it. - fn serialize<Se: Serializer>(&self, serializer: Se) -> Result<Se::Ok, Se::Error> { - let mut map = serializer.serialize_map(Some(self.mir.basic_blocks.len()))?; - - for bb in self.mir.basic_blocks.indices() { - let mir::BasicBlockData { ref statements, .. } = self.mir[bb]; - let mut stmt_vec: Vec<_> = Vec::new(); - for (statement_index, stmt) in statements.iter().enumerate() { - let location = mir::Location { - block: bb, - statement_index, - }; - let state = self.lookup_before(location).unwrap(); - - // output statement - stmt_vec.push(("state:", state, format!("statement: {:?}", stmt))); - } - - let term_location = self.mir.terminator_loc(bb); - let state_before = self.lookup_before(term_location).unwrap(); - - let terminator_str = format!("terminator: {:?}", self.mir[bb].terminator().kind); - - let new_map = FxHashMap::default(); - let map_after = self.lookup_after_block(bb).unwrap_or(&new_map); - let ordered_succ_map: BTreeMap<_, _> = - map_after.iter().map(|(bb, s)| (format!("{:?}", bb), ("state:", s))).collect(); - - map.serialize_entry( - &format!("{:?}", bb), - &(stmt_vec, "state before terminator:", state_before, terminator_str, ordered_succ_map), - )?; - } - map.end() - } -} - -impl<'mir, 'tcx: 'mir, S: Serialize> PointwiseState<'mir, 'tcx, S> { - pub fn new(mir: &'mir mir::Body<'tcx>) -> Self { - Self { - state_before: FxHashMap::default(), - state_after_block: FxHashMap::default(), - mir, - } - } - - /// Look up the state before the `location`. - /// The `location` can point to a statement or terminator. - pub fn lookup_before(&self, location: mir::Location) -> Option<&S> { - self.state_before.get(&location) - } - - /// Look up the mutable state before the `location`. - /// The `location` can point to a statement or terminator. - pub fn lookup_mut_before(&mut self, location: mir::Location) -> Option<&mut S> { - self.state_before.get_mut(&location) - } - - /// Look up the state after the `location`. - /// The `location` should point to a statement, not a terminator. - pub fn lookup_after(&self, location: mir::Location) -> Option<&S> { - debug_assert!(location.statement_index < self.mir[location.block].statements.len()); - self.state_before.get(&location.successor_within_block()) - } - - /// Look up the state on the outgoing CFG edges of `block`. - /// The return value maps all successor blocks to the state on the CFG edge from `block` to - /// that block. - pub fn lookup_after_block(&self, block: mir::BasicBlock) -> Option<&FxHashMap<mir::BasicBlock, S>> { - self.state_after_block.get(&block) - } - - /// Return the mutable state of the analysis on the outgoing CFG edges of `block`. - /// The return value maps all successor blocks to the state on the CFG edge from `block` to - /// that block. - pub(crate) fn lookup_mut_after_block( - &mut self, - block: mir::BasicBlock, - ) -> &mut FxHashMap<mir::BasicBlock, S> { - self.state_after_block.entry(block).or_insert_with(FxHashMap::default) - } - - /// Update the state before the `location`. - /// The `location` can point to a statement or terminator. - pub(crate) fn set_before(&mut self, location: mir::Location, state: S) { - self.state_before.insert(location, state); - } -} - -impl<'mir, 'tcx: 'mir, S: Serialize + Default> PointwiseState<'mir, 'tcx, S> { - pub fn default(mir: &'mir mir::Body<'tcx>) -> Self { - let state_before: FxHashMap<_, _> = mir - .basic_blocks - .iter_enumerated() - .flat_map(|(block, bb_data)| { - (0..=bb_data.statements.len()).map(move |statement_index| { - ( - mir::Location { - block, - statement_index, - }, - S::default(), - ) - }) - }) - .collect(); - let state_after_block: FxHashMap<_, _> = mir - .basic_blocks - .iter_enumerated() - .map(|(block, bb_data)| { - let successors: FxHashMap<_, _> = - bb_data.terminator().successors().map(|successor| (successor, S::default())).collect(); - (block, successors) - }) - .collect(); - Self { - state_before, - state_after_block, - mir, - } - } -} diff --git a/rr_frontend/analysis/testbins/analysis_driver/Cargo.lock b/rr_frontend/analysis/testbins/analysis_driver/Cargo.lock deleted file mode 100644 index f7254702..00000000 --- a/rr_frontend/analysis/testbins/analysis_driver/Cargo.lock +++ /dev/null @@ -1,318 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "analysis" -version = "0.1.0" -dependencies = [ - "env_logger", - "log", - "rr_rustc_interface", - "serde", - "serde_json", -] - -[[package]] -name = "analysis_driver" -version = "1.0.0" -dependencies = [ - "analysis", - "env_logger", - "rr_rustc_interface", - "serde_json", -] - -[[package]] -name = "anstream" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" - -[[package]] -name = "anstyle-parse" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "proc-macro2" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[package]] -name = "rr_rustc_interface" -version = "0.1.0" - -[[package]] -name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.116" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "syn" -version = "2.0.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/rr_frontend/analysis/testbins/analysis_driver/Cargo.toml b/rr_frontend/analysis/testbins/analysis_driver/Cargo.toml deleted file mode 100644 index 432cee42..00000000 --- a/rr_frontend/analysis/testbins/analysis_driver/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "analysis_driver" -edition = "2021" -version = "1.0.0" -authors = ["Federico Poli <federpoli@gmail.com>"] -license = "MPL-2.0" - -[dependencies] -analysis.path = "../.." -rr_rustc_interface.path = "../../../rr_rustc_interface" - -env_logger = "0.11" -serde_json = "1" - -[workspace] diff --git a/rr_frontend/analysis/testbins/analysis_driver/src/main.rs b/rr_frontend/analysis/testbins/analysis_driver/src/main.rs deleted file mode 100644 index 44584cb7..00000000 --- a/rr_frontend/analysis/testbins/analysis_driver/src/main.rs +++ /dev/null @@ -1,291 +0,0 @@ -#![feature(rustc_private)] - -// Sources: -// https://github.com/rust-lang/miri/blob/master/benches/helpers/miri_helper.rs -// https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/obtain-borrowck/driver.rs - -use std::cell::RefCell; -use std::rc::Rc; - -use analysis::abstract_interpretation::FixpointEngine; -use analysis::domains::{ - DefinitelyAccessibleAnalysis, DefinitelyInitializedAnalysis, FramingAnalysis, MaybeBorrowedAnalysis, - ReachingDefsAnalysis, -}; -use rr_rustc_interface::ast::ast; -use rr_rustc_interface::borrowck::consumers::{self, BodyWithBorrowckFacts}; -use rr_rustc_interface::data_structures::fx::FxHashMap; -use rr_rustc_interface::driver::Compilation; -use rr_rustc_interface::errors; -use rr_rustc_interface::hir::def_id::{DefId, LocalDefId}; -use rr_rustc_interface::interface::{interface, Config, Queries}; -use rr_rustc_interface::middle::query::queries::mir_borrowck::ProvidedValue; -use rr_rustc_interface::middle::query::{ExternProviders, Providers}; -use rr_rustc_interface::middle::ty; -use rr_rustc_interface::polonius_engine::{Algorithm, Output}; -use rr_rustc_interface::session::{self, Attribute, EarlyErrorHandler, Session}; - -struct OurCompilerCalls { - args: Vec<String>, -} - -fn get_attributes(tcx: ty::TyCtxt<'_>, def_id: DefId) -> &[rr_rustc_interface::ast::ast::Attribute] { - if let Some(local_def_id) = def_id.as_local() { - tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(local_def_id)) - } else { - tcx.item_attrs(def_id) - } -} - -fn get_attribute<'tcx>( - tcx: ty::TyCtxt<'tcx>, - def_id: DefId, - segment1: &str, - segment2: &str, -) -> Option<&'tcx Attribute> { - get_attributes(tcx, def_id).iter().find(|attr| match &attr.kind { - ast::AttrKind::Normal(normal_attr) => match &normal_attr.item { - ast::AttrItem { - path: - ast::Path { - span: _, - segments, - tokens: _, - }, - args: ast::AttrArgs::Empty, - tokens: _, - } => { - segments.len() == 2 - && segments[0].ident.as_str() == segment1 - && segments[1].ident.as_str() == segment2 - }, - _ => false, - }, - _ => false, - }) -} - -mod mir_storage { - use super::*; - - // Since mir_borrowck does not have access to any other state, we need to use a - // thread-local for storing the obtained MIR bodies. - // - // Note: We are using 'static lifetime here, which is in general unsound. - // Unfortunately, that is the only lifetime allowed here. Our use is safe - // because we cast it back to `'tcx` before using. - thread_local! { - static MIR_BODIES: - RefCell<FxHashMap<LocalDefId, BodyWithBorrowckFacts<'static>>> = - RefCell::new(FxHashMap::default()); - } - - pub unsafe fn store_mir_body<'tcx>( - _tcx: ty::TyCtxt<'tcx>, - def_id: LocalDefId, - body_with_facts: BodyWithBorrowckFacts<'tcx>, - ) { - // SAFETY: See the module level comment. - let body_with_facts: BodyWithBorrowckFacts<'static> = std::mem::transmute(body_with_facts); - MIR_BODIES.with(|state| { - let mut map = state.borrow_mut(); - assert!(map.insert(def_id, body_with_facts).is_none()); - }); - } - - #[allow(clippy::needless_lifetimes)] // We want to be very explicit about lifetimes here. - pub unsafe fn retrieve_mir_body<'tcx>( - _tcx: ty::TyCtxt<'tcx>, - def_id: LocalDefId, - ) -> BodyWithBorrowckFacts<'tcx> { - let body_with_facts: BodyWithBorrowckFacts<'static> = MIR_BODIES.with(|state| { - let mut map = state.borrow_mut(); - map.remove(&def_id).unwrap() - }); - // SAFETY: See the module level comment. - std::mem::transmute(body_with_facts) - } -} - -#[allow(clippy::needless_lifetimes)] -fn mir_borrowck<'tcx>(tcx: ty::TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> { - let body_with_facts = - consumers::get_body_with_borrowck_facts(tcx, def_id, consumers::ConsumerOptions::PoloniusOutputFacts); - // SAFETY: This is safe because we are feeding in the same `tcx` that is - // going to be used as a witness when pulling out the data. - unsafe { - mir_storage::store_mir_body(tcx, def_id, body_with_facts); - } - let mut providers = Providers::default(); - rr_rustc_interface::borrowck::provide(&mut providers); - let original_mir_borrowck = providers.mir_borrowck; - original_mir_borrowck(tcx, def_id) -} - -fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) { - local.mir_borrowck = mir_borrowck; -} - -impl rr_rustc_interface::driver::Callbacks for OurCompilerCalls { - // In this callback we override the mir_borrowck query. - fn config(&mut self, config: &mut Config) { - assert!(config.override_queries.is_none()); - config.override_queries = Some(override_queries); - } - - fn after_analysis<'tcx>( - &mut self, - compiler: &interface::Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - let session = compiler.session(); - session.abort_if_errors(); - - let abstract_domain: &str = self - .args - .iter() - .filter(|a| a.starts_with("--analysis")) - .flat_map(|a| a.rsplit('=')) - .next() - .expect("Please add --analysis=<DOMAIN>"); - - println!( - "Analyzing file {} using {}...", - compiler.session().io.input.source_name().prefer_local(), - abstract_domain - ); - - queries.global_ctxt().unwrap().enter(|tcx| { - // collect all functions with attribute #[analyzer::run] - let mut local_def_ids: Vec<_> = tcx - .mir_keys(()) - .iter() - .filter(|id| get_attribute(tcx, id.to_def_id(), "analyzer", "run").is_some()) - .collect(); - - // sort according to argument span to ensure deterministic output - local_def_ids.sort_unstable_by_key(|id| { - get_attribute(tcx, id.to_def_id(), "analyzer", "run").unwrap().span - }); - - for &local_def_id in local_def_ids { - println!("Result for function {}():", tcx.item_name(local_def_id.to_def_id())); - - // SAFETY: This is safe because we are feeding in the same `tcx` - // that was used to store the data. - let mut body_with_facts = unsafe { self::mir_storage::retrieve_mir_body(tcx, local_def_id) }; - body_with_facts.output_facts = Some(Rc::new(Output::compute( - body_with_facts.input_facts.as_ref().unwrap(), - Algorithm::Naive, - true, - ))); - assert!(!body_with_facts.input_facts.as_ref().unwrap().cfg_edge.is_empty()); - let body = &body_with_facts.body; - - match abstract_domain { - "ReachingDefsAnalysis" => { - let result = - ReachingDefsAnalysis::new(tcx, local_def_id.to_def_id(), body).run_fwd_analysis(); - match result { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()) - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - "DefinitelyInitializedAnalysis" => { - let result = DefinitelyInitializedAnalysis::new(tcx, local_def_id.to_def_id(), body) - .run_fwd_analysis(); - match result { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()) - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - "RelaxedDefinitelyInitializedAnalysis" => { - let result = - DefinitelyInitializedAnalysis::new_relaxed(tcx, local_def_id.to_def_id(), body) - .run_fwd_analysis(); - match result { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()) - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - "MaybeBorrowedAnalysis" => { - let analyzer = MaybeBorrowedAnalysis::new(tcx, &body_with_facts); - match analyzer.run_analysis() { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()) - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - "DefinitelyAccessibleAnalysis" => { - let analyzer = DefinitelyAccessibleAnalysis::new( - tcx, - local_def_id.to_def_id(), - &body_with_facts, - ); - match analyzer.run_analysis() { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()); - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - "FramingAnalysis" => { - let analyzer = FramingAnalysis::new(tcx, local_def_id.to_def_id(), &body_with_facts); - match analyzer.run_analysis() { - Ok(state) => { - println!("{}", serde_json::to_string_pretty(&state).unwrap()); - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - }, - _ => panic!("Unknown domain argument: {abstract_domain}"), - } - } - }); - - Compilation::Stop - } -} - -/// Run an analysis by calling like it rustc -/// -/// Give arguments to the analyzer by prefixing them with '--analysis' -/// A abstract domain has to be provided by using '--analysis=' (without spaces), e.g.: -/// --analysis=ReachingDefsState or --analysis=DefinitelyInitializedAnalysis -fn main() { - env_logger::init(); - let error_handler = EarlyErrorHandler::new(session::config::ErrorOutputType::HumanReadable( - errors::emitter::HumanReadableErrorType::Default(errors::emitter::ColorConfig::Auto), - )); - rr_rustc_interface::driver::init_rustc_env_logger(&error_handler); - let mut compiler_args = Vec::new(); - let mut callback_args = Vec::new(); - for arg in std::env::args() { - if arg.starts_with("--analysis") { - callback_args.push(arg); - } else { - compiler_args.push(arg); - } - } - - compiler_args.push("-Zpolonius".to_owned()); - compiler_args.push("-Zalways-encode-mir".to_owned()); - compiler_args.push("-Zcrate-attr=feature(register_tool)".to_owned()); - compiler_args.push("-Zcrate-attr=register_tool(analyzer)".to_owned()); - - let mut callbacks = OurCompilerCalls { - args: callback_args, - }; - // Invoke compiler, and handle return code. - let exit_code = rr_rustc_interface::driver::catch_with_exit_code(move || { - rr_rustc_interface::driver::RunCompiler::new(&compiler_args, &mut callbacks).run() - }); - std::process::exit(exit_code) -} diff --git a/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.lock b/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.lock deleted file mode 100644 index 8ee02aca..00000000 --- a/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.lock +++ /dev/null @@ -1,318 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "analysis" -version = "0.1.0" -dependencies = [ - "env_logger", - "log", - "rr_rustc_interface", - "serde", - "serde_json", - "syn", -] - -[[package]] -name = "anstream" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" - -[[package]] -name = "anstyle-parse" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - -[[package]] -name = "gen_accessibility_driver" -version = "1.0.0" -dependencies = [ - "analysis", - "env_logger", - "rr_rustc_interface", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "proc-macro2" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[package]] -name = "rr_rustc_interface" -version = "0.1.0" - -[[package]] -name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.116" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "syn" -version = "2.0.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.toml b/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.toml deleted file mode 100644 index 5a24696d..00000000 --- a/rr_frontend/analysis/testbins/gen_accessibility_driver/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "gen_accessibility_driver" -edition = "2021" -version = "1.0.0" -authors = ["Federico Poli <federpoli@gmail.com>"] -license = "MPL-2.0" - -[dependencies] -analysis = { path = "../..", features = ["test-utils"] } -rr_rustc_interface.path = "../../../rr_rustc_interface" - -env_logger = "0.11" - -[workspace] diff --git a/rr_frontend/analysis/testbins/gen_accessibility_driver/src/main.rs b/rr_frontend/analysis/testbins/gen_accessibility_driver/src/main.rs deleted file mode 100644 index c7bb80ee..00000000 --- a/rr_frontend/analysis/testbins/gen_accessibility_driver/src/main.rs +++ /dev/null @@ -1,225 +0,0 @@ -#![feature(rustc_private)] - -// Sources: -// https://github.com/rust-lang/miri/blob/master/benches/helpers/miri_helper.rs -// https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/obtain-borrowck/driver.rs - -use std::cell::RefCell; -use std::path::PathBuf; -use std::rc::Rc; - -use analysis::domains::DefinitelyAccessibleAnalysis; -use rr_rustc_interface::borrowck::consumers::{self, BodyWithBorrowckFacts}; -use rr_rustc_interface::data_structures::fx::FxHashMap; -use rr_rustc_interface::driver::Compilation; -use rr_rustc_interface::hir::def_id::LocalDefId; -use rr_rustc_interface::interface::{interface, Config, Queries}; -use rr_rustc_interface::middle::query::queries::mir_borrowck::ProvidedValue; -use rr_rustc_interface::middle::query::{ExternProviders, Providers}; -use rr_rustc_interface::middle::ty; -use rr_rustc_interface::polonius_engine::{Algorithm, Output}; -use rr_rustc_interface::session::{self, EarlyErrorHandler, Session}; -use rr_rustc_interface::span::FileName; -use rr_rustc_interface::{errors, hir}; - -struct OurCompilerCalls { - args: Vec<String>, -} - -mod mir_storage { - use super::*; - - // Since mir_borrowck does not have access to any other state, we need to use a - // thread-local for storing the obtained MIR bodies. - // - // Note: We are using 'static lifetime here, which is in general unsound. - // Unfortunately, that is the only lifetime allowed here. Our use is safe - // because we cast it back to `'tcx` before using. - thread_local! { - static MIR_BODIES: - RefCell<FxHashMap<LocalDefId, BodyWithBorrowckFacts<'static>>> = - RefCell::new(FxHashMap::default()); - } - - pub unsafe fn store_mir_body<'tcx>( - _tcx: ty::TyCtxt<'tcx>, - def_id: LocalDefId, - body_with_facts: BodyWithBorrowckFacts<'tcx>, - ) { - // SAFETY: See the module level comment. - let body_with_facts: BodyWithBorrowckFacts<'static> = std::mem::transmute(body_with_facts); - MIR_BODIES.with(|state| { - let mut map = state.borrow_mut(); - assert!(map.insert(def_id, body_with_facts).is_none()); - }); - } - - #[allow(clippy::needless_lifetimes)] // We want to be very explicit about lifetimes here. - pub unsafe fn retrieve_mir_body<'tcx>( - _tcx: ty::TyCtxt<'tcx>, - def_id: LocalDefId, - ) -> BodyWithBorrowckFacts<'tcx> { - let body_with_facts: BodyWithBorrowckFacts<'static> = MIR_BODIES.with(|state| { - let mut map = state.borrow_mut(); - map.remove(&def_id).unwrap() - }); - // SAFETY: See the module level comment. - std::mem::transmute(body_with_facts) - } -} - -#[allow(clippy::needless_lifetimes)] -fn mir_borrowck<'tcx>(tcx: ty::TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> { - let body_with_facts = - consumers::get_body_with_borrowck_facts(tcx, def_id, consumers::ConsumerOptions::PoloniusOutputFacts); - // SAFETY: This is safe because we are feeding in the same `tcx` that is - // going to be used as a witness when pulling out the data. - unsafe { - mir_storage::store_mir_body(tcx, def_id, body_with_facts); - } - let mut providers = Providers::default(); - rr_rustc_interface::borrowck::provide(&mut providers); - let original_mir_borrowck = providers.mir_borrowck; - original_mir_borrowck(tcx, def_id) -} - -fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) { - local.mir_borrowck = mir_borrowck; -} - -impl rr_rustc_interface::driver::Callbacks for OurCompilerCalls { - // In this callback we override the mir_borrowck query. - fn config(&mut self, config: &mut Config) { - assert!(config.override_queries.is_none()); - config.override_queries = Some(override_queries); - } - - fn after_analysis<'tcx>( - &mut self, - compiler: &interface::Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - let session = compiler.session(); - session.abort_if_errors(); - - assert!(self.args.iter().any(|a| a == "--generate-test-program")); - - queries.global_ctxt().unwrap().enter(|tcx| { - // Retrieve the MIR body of all user-written functions and run Polonius. - let mut def_ids_with_body: Vec<_> = tcx - .mir_keys(()) - .iter() - .flat_map(|&local_def_id| { - // Skip items that are not functions or methods. - let hir_id = tcx.hir().local_def_id_to_hir_id(local_def_id); - let hir_node = tcx.hir().get(hir_id); - match hir_node { - hir::Node::Item(hir::Item { - kind: hir::ItemKind::Fn(..), - .. - }) - | hir::Node::ImplItem(hir::ImplItem { - kind: hir::ImplItemKind::Fn(..), - .. - }) - | hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Fn(..), - .. - }) => {}, - _ => return None, - } - - // SAFETY: This is safe because we are feeding in the same `tcx` - // that was used to store the data. - let mut body_with_facts = - unsafe { self::mir_storage::retrieve_mir_body(tcx, local_def_id) }; - body_with_facts.output_facts = Some(Rc::new(Output::compute( - body_with_facts.input_facts.as_ref().unwrap(), - Algorithm::Naive, - true, - ))); - - // Skip macro expansions - let mir_span = body_with_facts.body.span; - if mir_span.parent_callsite().is_some() { - return None; - } - - // Skip short functions - if !session.source_map().is_multiline(mir_span) { - return None; - } - - // Skip functions that are in an external file. - let source_file = session.source_map().lookup_source_file(mir_span.data().lo); - if let FileName::Real(filename) = &source_file.name { - if session.local_crate_source_file() != filename.local_path().map(PathBuf::from) { - return None; - } - } else { - return None; - } - - Some((local_def_id, body_with_facts)) - }) - .collect(); - - assert!(!def_ids_with_body.is_empty()); - - // Sort according to span to ensure deterministic output - def_ids_with_body.sort_unstable_by_key(|(_, bwf)| bwf.body.span); - - // Generate and print the programs with the additional statements to check accessibility. - for (num, (local_def_id, body_with_facts)) in def_ids_with_body.iter().enumerate() { - assert!(!body_with_facts.input_facts.as_ref().unwrap().cfg_edge.is_empty()); - let body = &body_with_facts.body; - - if num > 0 { - println!("\n/* NEW PROGRAM */\n"); - } - - let analyzer = - DefinitelyAccessibleAnalysis::new(tcx, local_def_id.to_def_id(), body_with_facts); - match analyzer.run_analysis() { - Ok(state) => { - println!("{}", state.generate_test_program(tcx, session.source_map(),)); - }, - Err(e) => eprintln!("{}", e.to_pretty_str(body)), - } - } - }); - - Compilation::Stop - } -} - -/// Run an analysis by calling like it rustc -fn main() { - env_logger::init(); - let error_handler = EarlyErrorHandler::new(session::config::ErrorOutputType::HumanReadable( - errors::emitter::HumanReadableErrorType::Default(errors::emitter::ColorConfig::Auto), - )); - rr_rustc_interface::driver::init_rustc_env_logger(&error_handler); - let mut compiler_args = Vec::new(); - let mut callback_args = Vec::new(); - for arg in std::env::args() { - if arg.starts_with("--generate-test-program") { - callback_args.push(arg); - } else { - compiler_args.push(arg); - } - } - - compiler_args.push("-Zpolonius".to_owned()); - compiler_args.push("-Zalways-encode-mir".to_owned()); - compiler_args.push("-Zcrate-attr=feature(register_tool)".to_owned()); - - let mut callbacks = OurCompilerCalls { - args: callback_args, - }; - // Invoke compiler, and handle return code. - let exit_code = rr_rustc_interface::driver::catch_with_exit_code(move || { - rr_rustc_interface::driver::RunCompiler::new(&compiler_args, &mut callbacks).run() - }); - std::process::exit(exit_code) -} diff --git a/rr_frontend/analysis/tests/test_accessibility.rs b/rr_frontend/analysis/tests/test_accessibility.rs deleted file mode 100644 index 61b2cd44..00000000 --- a/rr_frontend/analysis/tests/test_accessibility.rs +++ /dev/null @@ -1,167 +0,0 @@ -mod utils; - -use std::ffi::OsStr; -use std::path::{Path, PathBuf}; -use std::process::{Command, Stdio}; -use std::{env, fmt, fs}; - -use glob::glob; -use test_binary::build_test_binary_once; -use utils::*; - -/// Prepend paths to an environment variable -fn env_prepend_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) { - let old_value = env::var_os(name); - let mut parts = value; - if let Some(ref v) = old_value { - parts.extend(env::split_paths(v)); - }; - match env::join_paths(parts) { - Ok(new_value) => { - cmd.env(name, new_value); - }, - Err(err) => panic!("Error: {:?}", err), - } -} - -/// Append paths to the loader environment variable -fn add_to_loader_path(paths: Vec<PathBuf>, cmd: &mut Command) { - #[cfg(target_os = "windows")] - const LOADER_PATH: &str = "PATH"; - #[cfg(target_os = "linux")] - const LOADER_PATH: &str = "LD_LIBRARY_PATH"; - #[cfg(target_os = "macos")] - const LOADER_PATH: &str = "DYLD_FALLBACK_LIBRARY_PATH"; - env_prepend_path(LOADER_PATH, paths, cmd); -} - -fn generate_program_testing_accessible_paths(program_path: impl AsRef<OsStr> + fmt::Debug) -> Vec<String> { - let compiler_sysroot = PathBuf::from(find_sysroot()); - let compiler_bin = compiler_sysroot.join("bin"); - let compiler_lib = compiler_sysroot.join("lib"); - - build_test_binary_once!(gen_accessibility_driver, "testbins"); - let executable_path = path_to_gen_accessibility_driver(); - - let mut cmd = Command::new(executable_path); - cmd.args(["--edition=2018", "--crate-type=lib", "--sysroot"]) - .arg( - compiler_sysroot - .into_os_string() - .into_string() - .expect("sysroot is not a valid utf-8 string"), - ) - .arg("--generate-test-program") - .arg(&program_path); - - add_to_loader_path(vec![compiler_lib, compiler_bin], &mut cmd); - - println!("Running {:?}", cmd); - let output = cmd - .env("RUST_BACKTRACE", "1") - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .unwrap_or_else(|err| panic!("Failed to execute process: {:?}", err)); - - let stdout = String::from_utf8_lossy(&output.stdout); - if !output.status.success() { - println!("Test case {:?} unexpectedly failed.", program_path); - println!("Exit status: {:?}", output.status); - println!("┌─── Begin of stdout ───â”"); - println!("{}", stdout); - println!("└──── End of stdout ────┘"); - println!("┌─── Begin of stderr ───â”"); - println!("{}", String::from_utf8_lossy(&output.stderr)); - println!("└──── End of stderr ────┘"); - panic!("Test case unexpectedly failed. See the output for details."); - } - - stdout.to_string().split("\n/* NEW PROGRAM */\n\n").map(|s| s.to_string()).collect() -} - -fn check_compile_pass(cwd: impl AsRef<Path>, program_path: impl AsRef<OsStr> + fmt::Debug) { - let mut cmd = Command::new("rustc"); - cmd.args(["--edition=2018", "--crate-type=lib", "-Zpolonius"]).arg(&program_path); - println!("Running {:?}", cmd); - let output = cmd - .current_dir(cwd) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .unwrap_or_else(|err| panic!("Failed to execute process: {:?}", err)); - if !output.status.success() { - println!("Program {:?} failed to compile.", &program_path); - println!("Exit status: {:?}", output.status); - println!("┌─── Begin of stdout ───â”"); - println!("{}", String::from_utf8_lossy(&output.stdout)); - println!("└──── End of stdout ────┘"); - println!("┌─── Begin of stderr ───â”"); - println!("{}", String::from_utf8_lossy(&output.stderr)); - println!("└──── End of stderr ────┘"); - panic!("Test case unexpectedly failed. See the output for details."); - } -} - -/// Collect test programs composed of just one file. -fn collect_standalone_test_programs() -> Vec<PathBuf> { - let mut programs = vec![]; - let glob_paths = [ - "tests/test_cases/gen_accessibility/*.rs", - "tests/test_cases/gen_accessibility/**/*.rs", - //"../prusti-tests/tests/verify*/fail/no-annotations/*.rs", - //"../prusti-tests/tests/verify*/pass/no-annotations/*.rs", - ]; - for glob_path in &glob_paths { - let mut new_programs: Vec<_> = glob(glob_path).unwrap().map(|result| result.unwrap()).collect(); - println!("Collected {} test programs from {:?}", new_programs.len(), glob_path); - assert!(!new_programs.is_empty()); - new_programs.sort(); - programs.append(&mut new_programs); - } - assert!(programs.len() >= glob_paths.len()); - programs -} - -/// Test the correctness of the analysis by injecting `let _ = & <place>` (respectively, -/// `let _ = &mut <place>`) statements wherever the `DefinitelyAccessibleAnalysis` believes that -/// a place is accessible by read (respectively, write) operations. -#[test] -fn test_accessibility() { - let test_programs = collect_standalone_test_programs(); - println!("Collected {} test programs", test_programs.len()); - let out_dir = env::temp_dir().join("prusti_test_analysis"); - if out_dir.exists() { - fs::remove_dir_all(&out_dir).expect("Failed to remove output directory"); - } - fs::create_dir(&out_dir).expect("Failed to create output directory"); - println!("Output directory: {:?}", out_dir); - - for (test_num, test_program) in test_programs.iter().enumerate() { - println!("Testing on {:?} ({}/{})", test_program, test_num, test_programs.len()); - let gen_programs = generate_program_testing_accessible_paths(test_program); - assert!(!gen_programs.is_empty()); - println!("The analysis generated {} programs", gen_programs.len()); - let limit = 10; - if gen_programs.len() > limit { - println!("Too many generated programs. Only the first {} will be considered.", limit); - } - for (gen_num, gen_program) in gen_programs.iter().take(limit).enumerate() { - let test_filename = test_program.file_name().unwrap().to_str().unwrap(); - let gen_path = out_dir.join(format!("{:03}_{:02}_{}", test_num, gen_num, test_filename)); - println!("Generated program: {:?} ({}/{})", gen_path, gen_num, gen_programs.len()); - println!("┌─── Begin of generated program ───â”"); - println!("{}", gen_program); - println!("└──── End of generated program ────┘"); - - // Check that it compiles successfully - std::fs::write(&gen_path, gen_program).unwrap(); - check_compile_pass(&out_dir, gen_path); - } - } - - println!("All tests passed. Removing output directory {:?}", out_dir); - // Note that this does *not* remove the output directory in case of failures. - // It's done on purpose to help debugging. - fs::remove_dir_all(&out_dir).expect("Failed to remove output directory"); -} diff --git a/rr_frontend/analysis/tests/test_analysis.rs b/rr_frontend/analysis/tests/test_analysis.rs deleted file mode 100644 index 4365c9a5..00000000 --- a/rr_frontend/analysis/tests/test_analysis.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![feature(custom_test_frameworks)] -#![test_runner(test_runner)] - -mod utils; - -use std::env; -use std::path::PathBuf; - -/// Source: https://github.com/rust-lang/miri/blob/master/tests/compiletest.rs -use compiletest_rs as compiletest; -use test_binary::build_test_binary_once; -use utils::*; - -fn run_tests(mode: &str, path: &str, custom_args: Vec<String>) { - let mut config = compiletest::Config::default(); - - build_test_binary_once!(analysis_driver, "testbins"); - - let mut flags = Vec::new(); - flags.push("--edition 2018".to_owned()); - flags.push(format!("--sysroot {}", find_sysroot())); - flags.extend(custom_args); - config.target_rustcflags = Some(flags.join(" ")); - config.mode = mode.parse().expect("Invalid mode"); - config.rustc_path = path_to_analysis_driver().into(); - config.src_base = PathBuf::from(path); - assert!(config.src_base.is_dir()); - - // Filter the tests to run - if let Some(filter) = env::args().nth(1) { - config.filters.push(filter); - } - - if let Some(lib_path) = option_env!("RUSTC_LIB_PATH") { - config.run_lib_path = PathBuf::from(lib_path); - config.compile_lib_path = PathBuf::from(lib_path); - } - - compiletest::run_tests(&config); -} - -fn test_runner(_tests: &[&()]) { - env::set_var("RUST_BACKTRACE", "1"); - - run_tests("ui", "tests/test_cases/reaching_definitions", vec!["--analysis=ReachingDefsAnalysis".into()]); - run_tests("ui", "tests/test_cases/definitely_initialized", vec![ - "--analysis=DefinitelyInitializedAnalysis".into(), - ]); - run_tests("ui", "tests/test_cases/relaxed_definitely_initialized", vec![ - "--analysis=RelaxedDefinitelyInitializedAnalysis".into(), - ]); - run_tests("ui", "tests/test_cases/maybe_borrowed", vec!["--analysis=MaybeBorrowedAnalysis".into()]); - run_tests("ui", "tests/test_cases/definitely_accessible", vec![ - "--analysis=DefinitelyAccessibleAnalysis".into(), - ]); - run_tests("ui", "tests/test_cases/framing", vec!["--analysis=FramingAnalysis".into()]); -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.rs b/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.rs deleted file mode 100644 index 5d97c5ce..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(box_patterns)] - -fn foo<T>(x: T) {} - -#[analyzer::run] -fn main() { - let mut x = Box::new(123); - let y = &x; - foo(y); - // `y` should expire here - let z = &mut x; - foo(z); -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.stdout b/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.stdout deleted file mode 100644 index 6375b524..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/expired.stdout +++ /dev/null @@ -1,462 +0,0 @@ -Analyzing file $DIR/expired.rs using DefinitelyAccessibleAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: _1 = std::boxed::Box::<i32>::new(const 123_i32) -> [return: bb1, unwind: bb6]", - { - "bb1": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ], - "bb6": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _2 = &_1" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: _4 = _2" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1", - "_4" - ], - "owned": [ - "_4" - ] - }, - "terminator: _3 = foo::<&std::boxed::Box<i32>>(move _4) -> [return: bb2, unwind: bb5]", - { - "bb2": [ - "state:", - { - "accessible": [ - "_1", - "_3" - ], - "owned": [ - "_1", - "_3" - ] - } - ], - "bb5": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "accessible": [ - "_1", - "_3" - ], - "owned": [ - "_1", - "_3" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_3" - ], - "owned": [ - "_1", - "_3" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _5 = &mut _1" - ], - [ - "state:", - { - "accessible": [ - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: FakeRead(ForLet(None), _5)" - ], - [ - "state:", - { - "accessible": [ - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "accessible": [ - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "accessible": [ - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: _7 = move _5" - ] - ], - "state before terminator:", - { - "accessible": [ - "_7" - ], - "owned": [ - "_7" - ] - }, - "terminator: _6 = foo::<&mut std::boxed::Box<i32>>(move _7) -> [return: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - { - "accessible": [ - "_1", - "_6" - ], - "owned": [ - "_1", - "_6" - ] - } - ], - "bb5": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "accessible": [ - "_1", - "_6" - ], - "owned": [ - "_1", - "_6" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_6" - ], - "owned": [ - "_1", - "_6" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "accessible": [ - "_0", - "_1" - ], - "owned": [ - "_0", - "_1" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "accessible": [ - "_0", - "_1" - ], - "owned": [ - "_0", - "_1" - ] - }, - "statement: StorageDead(_2)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0", - "_1" - ], - "owned": [ - "_0", - "_1" - ] - }, - "terminator: drop(_1) -> [return: bb4, unwind: bb6]", - { - "bb4": [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - } - ], - "bb6": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_1) -> [return: bb6, unwind terminate(cleanup)]", - { - "bb6": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb6": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.rs b/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.rs deleted file mode 100644 index bcbc0bf2..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![allow(dropping_references)] - -#[derive(Clone, Default)] -struct T { - // Wrap in Box to have non-Copy types - value1: Box<u32>, - value2: Box<u32>, - value3: Box<u32>, -} - -#[analyzer::run] -fn main() { - let mut x = T::default(); - // Move out value1 - drop(x.value1); - // Block value2 - let borrow_value2 = &mut x.value2; - let block_value2 = &borrow_value2; - // Freeze value3 - let shared_ref = &x.value3; - // Nothing should be owned here - drop(shared_ref); - // Now value3 should be owned - drop(block_value2); - // Now value2 should be owned - x.value1 = Box::new(123); - // Now everything should be owned - drop(x); - // Now the state should be empty -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.stdout b/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.stdout deleted file mode 100644 index 6106b9d1..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/fields.stdout +++ /dev/null @@ -1,978 +0,0 @@ -Analyzing file $DIR/fields.rs using DefinitelyAccessibleAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: _1 = <T as std::default::Default>::default() -> [return: bb1, unwind: bb14]", - { - "bb1": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ], - "bb14": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _3 = move (_1.0: std::boxed::Box<u32>)" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_3" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_3" - ] - }, - "terminator: _2 = std::mem::drop::<std::boxed::Box<u32>>(move _3) -> [return: bb2, unwind: bb12]", - { - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb2": [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ] - }, - "statement: _4 = &mut (_1.1: std::boxed::Box<u32>)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ] - }, - "statement: FakeRead(ForLet(None), _4)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_4" - ] - }, - "statement: _5 = &_4" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: FakeRead(ForLet(None), _5)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: _6 = &(_1.2: std::boxed::Box<u32>)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_6" - ], - "owned": [ - "_5", - "_6" - ] - }, - "statement: FakeRead(ForLet(None), _6)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_6" - ], - "owned": [ - "_5", - "_6" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_6" - ], - "owned": [ - "_5", - "_6" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_6" - ], - "owned": [ - "_5", - "_6" - ] - }, - "statement: _8 = _6" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_8" - ], - "owned": [ - "_5", - "_8" - ] - }, - "terminator: _7 = std::mem::drop::<&std::boxed::Box<u32>>(move _8) -> [return: bb3, unwind: bb13]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb3": [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5", - "_7" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: StorageLive(_9)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: StorageLive(_10)" - ], - [ - "state:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_5" - ] - }, - "statement: _10 = _5" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.2: std::boxed::Box<u32>)", - "_10" - ], - "owned": [ - "(_1.2: std::boxed::Box<u32>)", - "_10" - ] - }, - "terminator: _9 = std::mem::drop::<&&mut std::boxed::Box<u32>>(move _10) -> [return: bb4, unwind: bb13]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb4": [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ] - }, - "statement: StorageDead(_10)" - ], - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_9" - ] - }, - "statement: StorageDead(_9)" - ], - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ] - }, - "statement: StorageLive(_11)" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ] - }, - "terminator: _11 = std::boxed::Box::<u32>::new(const 123_u32) -> [return: bb5, unwind: bb13]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb5": [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ] - } - ] - } - ], - "bb5": [ - [], - "state before terminator:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ] - }, - "terminator: drop((_1.0: std::boxed::Box<u32>)) -> [return: bb6, unwind: bb7]", - { - "bb6": [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ] - } - ], - "bb7": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb6": [ - [ - [ - "state:", - { - "accessible": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ], - "owned": [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_11" - ] - }, - "statement: (_1.0: std::boxed::Box<u32>) = move _11" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "terminator: drop(_11) -> [return: bb8, unwind: bb13]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb8": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ] - } - ], - "bb7": [ - [ - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: (_1.0: std::boxed::Box<u32>) = move _11" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.0: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.0: std::boxed::Box<u32>)" - ] - }, - "terminator: drop(_11) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - { - "accessible": [ - "(_1.0: std::boxed::Box<u32>)" - ], - "owned": [ - "(_1.0: std::boxed::Box<u32>)" - ] - } - ] - } - ], - "bb8": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageDead(_11)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_12)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_13)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _13 = move _1" - ] - ], - "state before terminator:", - { - "accessible": [ - "_13" - ], - "owned": [ - "_13" - ] - }, - "terminator: _12 = std::mem::drop::<T>(move _13) -> [return: bb9, unwind: bb11]", - { - "bb11": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb9": [ - "state:", - { - "accessible": [ - "_12" - ], - "owned": [ - "_12" - ] - } - ] - } - ], - "bb9": [ - [ - [ - "state:", - { - "accessible": [ - "_12" - ], - "owned": [ - "_12" - ] - }, - "statement: StorageDead(_13)" - ], - [ - "state:", - { - "accessible": [ - "_12" - ], - "owned": [ - "_12" - ] - }, - "statement: StorageDead(_12)" - ], - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_4)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: drop(_1) -> [return: bb10, unwind: bb14]", - { - "bb10": [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - } - ], - "bb14": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb10": [ - [ - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb11": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_13) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb12": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_3) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb13": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_1) -> [return: bb14, unwind terminate(cleanup)]", - { - "bb14": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb14": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.rs b/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.rs deleted file mode 100644 index 311e96a5..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct InfiniteList { - val: u32, - next: Box<InfiniteList>, -} - -#[analyzer::run] -fn test1(mut a: InfiniteList) { - let b = *a.next; -} - -#[analyzer::run] -fn test2(mut x: InfiniteList) { - x = *x.next.next; -} - -fn main() {} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.stdout b/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.stdout deleted file mode 100644 index fc383dce..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/infinite_list.stdout +++ /dev/null @@ -1,436 +0,0 @@ -Analyzing file $DIR/infinite_list.rs using DefinitelyAccessibleAnalysis... -Result for function test1(): -{ - "bb0": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _2 = move (*(_1.1: std::boxed::Box<InfiniteList>))" - ], - [ - "state:", - { - "accessible": [ - "(_1.0: u32)", - "_2" - ], - "owned": [ - "(_1.0: u32)", - "_2" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "accessible": [ - "(_1.0: u32)", - "_2" - ], - "owned": [ - "(_1.0: u32)", - "_2" - ] - }, - "statement: _0 = const ()" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0", - "(_1.0: u32)", - "_2" - ], - "owned": [ - "_0", - "(_1.0: u32)", - "_2" - ] - }, - "terminator: drop(_2) -> [return: bb1, unwind: bb3]", - { - "bb1": [ - "state:", - { - "accessible": [ - "_0", - "(_1.0: u32)" - ], - "owned": [ - "_0", - "(_1.0: u32)" - ] - } - ], - "bb3": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "accessible": [ - "_0", - "(_1.0: u32)" - ], - "owned": [ - "_0", - "(_1.0: u32)" - ] - }, - "statement: StorageDead(_2)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0", - "(_1.0: u32)" - ], - "owned": [ - "_0", - "(_1.0: u32)" - ] - }, - "terminator: drop(_1) -> [return: bb2, unwind: bb4]", - { - "bb2": [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - } - ], - "bb4": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb2": [ - [], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb3": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_1) -> [return: bb4, unwind terminate(cleanup)]", - { - "bb4": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb4": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: resume", - {} - ] -} -Result for function test2(): -{ - "bb0": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _2 = move (*((*(_1.1: std::boxed::Box<InfiniteList>)).1: std::boxed::Box<InfiniteList>))" - ] - ], - "state before terminator:", - { - "accessible": [ - "(_1.0: u32)", - "((*(_1.1: std::boxed::Box<InfiniteList>)).0: u32)", - "_2" - ], - "owned": [ - "(_1.0: u32)", - "((*(_1.1: std::boxed::Box<InfiniteList>)).0: u32)", - "_2" - ] - }, - "terminator: drop(_1) -> [return: bb1, unwind: bb2]", - { - "bb1": [ - "state:", - { - "accessible": [ - "_2" - ], - "owned": [ - "_2" - ] - } - ], - "bb2": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "accessible": [ - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: _1 = move _2" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "terminator: drop(_2) -> [return: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ], - "bb5": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: _1 = move _2" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "terminator: drop(_2) -> [return: bb5, unwind terminate(cleanup)]", - { - "bb5": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _0 = const ()" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0", - "_1" - ], - "owned": [ - "_0", - "_1" - ] - }, - "terminator: drop(_1) -> [return: bb4, unwind: bb6]", - { - "bb4": [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - } - ], - "bb6": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb4": [ - [], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_1) -> [return: bb6, unwind terminate(cleanup)]", - { - "bb6": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb6": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.rs b/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.rs deleted file mode 100644 index eefb3c4d..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn foo<T>(_x: T) {} - -#[analyzer::run] -fn main() { - let x = (Box::new(123), Box::new(123)); - let y = &x.0; - let mut z = (y, y, y); - z.2 = &x.1; - foo(&z); - foo(&z); - drop(x); -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.stdout b/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.stdout deleted file mode 100644 index cdbfd0ec..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_accessible/ref_field.stdout +++ /dev/null @@ -1,999 +0,0 @@ -Analyzing file $DIR/ref_field.rs using DefinitelyAccessibleAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: StorageLive(_1)" - ], - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: StorageLive(_2)" - ] - ], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: _2 = std::boxed::Box::<i32>::new(const 123_i32) -> [return: bb1, unwind: bb12]", - { - "bb1": [ - "state:", - { - "accessible": [ - "_2" - ], - "owned": [ - "_2" - ] - } - ], - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "accessible": [ - "_2" - ], - "owned": [ - "_2" - ] - }, - "statement: StorageLive(_3)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_2" - ], - "owned": [ - "_2" - ] - }, - "terminator: _3 = std::boxed::Box::<i32>::new(const 123_i32) -> [return: bb2, unwind: bb11]", - { - "bb11": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb2": [ - "state:", - { - "accessible": [ - "_2", - "_3" - ], - "owned": [ - "_2", - "_3" - ] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "accessible": [ - "_2", - "_3" - ], - "owned": [ - "_2", - "_3" - ] - }, - "statement: _1 = (move _2, move _3)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "terminator: drop(_3) -> [return: bb3, unwind: bb11]", - { - "bb11": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb3": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "terminator: drop(_2) -> [return: bb4, unwind: bb12]", - { - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb4": [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _4 = &(_1.0: std::boxed::Box<i32>)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4" - ] - }, - "statement: FakeRead(ForLet(None), _4)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4" - ] - }, - "statement: _6 = _4" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4", - "_6" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4", - "_6" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4", - "_6" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4", - "_6" - ] - }, - "statement: _7 = _4" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4", - "_6", - "_7" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4", - "_6", - "_7" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_4", - "_6", - "_7" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_4", - "_6", - "_7" - ] - }, - "statement: _8 = _4" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_6", - "_7", - "_8" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_6", - "_7", - "_8" - ] - }, - "statement: _5 = (move _6, move _7, move _8)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: FakeRead(ForLet(None), _5)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: StorageLive(_9)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: StorageLive(_10)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "(_1.1: std::boxed::Box<i32>)", - "_5" - ] - }, - "statement: _10 = &(_1.1: std::boxed::Box<i32>)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5", - "_10" - ], - "owned": [ - "_5", - "_10" - ] - }, - "statement: _9 = &(*_10)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5", - "_9" - ], - "owned": [ - "_5", - "_9" - ] - }, - "statement: (_5.2: &std::boxed::Box<i32>) = move _9" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageDead(_9)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageDead(_10)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_11)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_12)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: _12 = &_5" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1", - "_5", - "_12" - ], - "owned": [ - "_12" - ] - }, - "terminator: _11 = foo::<&(&std::boxed::Box<i32>, &std::boxed::Box<i32>, &std::boxed::Box<i32>)>(move _12) -> [return: bb5, unwind: bb10]", - { - "bb10": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb5": [ - "state:", - { - "accessible": [ - "_1", - "_5", - "_11" - ], - "owned": [ - "_5", - "_11" - ] - } - ] - } - ], - "bb5": [ - [ - [ - "state:", - { - "accessible": [ - "_1", - "_5", - "_11" - ], - "owned": [ - "_5", - "_11" - ] - }, - "statement: StorageDead(_12)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5", - "_11" - ], - "owned": [ - "_5", - "_11" - ] - }, - "statement: StorageDead(_11)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_13)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: StorageLive(_14)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_5" - ], - "owned": [ - "_5" - ] - }, - "statement: _14 = &_5" - ] - ], - "state before terminator:", - { - "accessible": [ - "_1", - "_14" - ], - "owned": [ - "_14" - ] - }, - "terminator: _13 = foo::<&(&std::boxed::Box<i32>, &std::boxed::Box<i32>, &std::boxed::Box<i32>)>(move _14) -> [return: bb6, unwind: bb10]", - { - "bb10": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb6": [ - "state:", - { - "accessible": [ - "_1", - "_13" - ], - "owned": [ - "_1", - "_13" - ] - } - ] - } - ], - "bb6": [ - [ - [ - "state:", - { - "accessible": [ - "_1", - "_13" - ], - "owned": [ - "_1", - "_13" - ] - }, - "statement: StorageDead(_14)" - ], - [ - "state:", - { - "accessible": [ - "_1", - "_13" - ], - "owned": [ - "_1", - "_13" - ] - }, - "statement: StorageDead(_13)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_15)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: StorageLive(_16)" - ], - [ - "state:", - { - "accessible": [ - "_1" - ], - "owned": [ - "_1" - ] - }, - "statement: _16 = move _1" - ] - ], - "state before terminator:", - { - "accessible": [ - "_16" - ], - "owned": [ - "_16" - ] - }, - "terminator: _15 = std::mem::drop::<(std::boxed::Box<i32>, std::boxed::Box<i32>)>(move _16) -> [return: bb7, unwind: bb9]", - { - "bb7": [ - "state:", - { - "accessible": [ - "_15" - ], - "owned": [ - "_15" - ] - } - ], - "bb9": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb7": [ - [ - [ - "state:", - { - "accessible": [ - "_15" - ], - "owned": [ - "_15" - ] - }, - "statement: StorageDead(_16)" - ], - [ - "state:", - { - "accessible": [ - "_15" - ], - "owned": [ - "_15" - ] - }, - "statement: StorageDead(_15)" - ], - [ - "state:", - { - "accessible": [], - "owned": [] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_4)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: drop(_1) -> [return: bb8, unwind: bb12]", - { - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ], - "bb8": [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - } - ] - } - ], - "bb8": [ - [ - [ - "state:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "accessible": [ - "_0" - ], - "owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb9": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_16) -> [return: bb10, unwind terminate(cleanup)]", - { - "bb10": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb10": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_1) -> [return: bb12, unwind terminate(cleanup)]", - { - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb11": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: drop(_2) -> [return: bb12, unwind terminate(cleanup)]", - { - "bb12": [ - "state:", - { - "accessible": [], - "owned": [] - } - ] - } - ], - "bb12": [ - [], - "state before terminator:", - { - "accessible": [], - "owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.rs deleted file mode 100644 index e70e687a..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn main() { - let a = abs(-1); - let b = abs(1); - println!("{}", a + b); -} - -#[analyzer::run] -fn abs(x: i32) -> i32 { - let res: i32; - if x >= 0 { - res = x; - } else { - res = -x; - } - return res; -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.stdout deleted file mode 100644 index 47c616c4..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/abs.stdout +++ /dev/null @@ -1,288 +0,0 @@ -Analyzing file $DIR/abs.rs using DefinitelyInitializedAnalysis... -Result for function abs(): -{ - "bb0": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_5)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_6)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _6 = _1" - ], - [ - "state:", - [ - "_1", - "_6" - ], - "statement: _5 = Ge(move _6, const 0_i32)" - ] - ], - "state before terminator:", - [ - "_1", - "_5" - ], - "terminator: switchInt(move _5) -> [0: bb2, otherwise: bb1]", - { - "bb1": [ - "state:", - [ - "_1" - ] - ], - "bb2": [ - "state:", - [ - "_1" - ] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_7)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _7 = _1" - ], - [ - "state:", - [ - "_1", - "_7" - ], - "statement: _3 = move _7" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: StorageDead(_7)" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_3", - "_4" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_3", - "_4" - ] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_8)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _8 = _1" - ], - [ - "state:", - [ - "_1", - "_8" - ], - "statement: _9 = Eq(_8, const i32::MIN)" - ] - ], - "state before terminator:", - [ - "_1", - "_8", - "_9" - ], - "terminator: assert(!move _9, /"attempt to negate `{}`, which would overflow/", _8) -> [success: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - [ - "_1", - "_8" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "_1", - "_8" - ], - "statement: _3 = Neg(move _8)" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: StorageDead(_8)" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_3", - "_4" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_3", - "_4" - ] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "_1", - "_3", - "_4" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_1", - "_3", - "_4" - ], - "statement: StorageDead(_4)" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: _0 = _3" - ], - [ - "state:", - [ - "_0", - "_1", - "_3" - ], - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - [ - "_0", - "_1" - ], - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.rs deleted file mode 100644 index ce548896..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![allow(dropping_copy_types)] - -#[analyzer::run] -fn main() { - let x = [1, 2, 3]; - drop(x); - let y = [Box::new(4)]; - drop(y); -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.stdout deleted file mode 100644 index 4aceb239..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/array.stdout +++ /dev/null @@ -1,314 +0,0 @@ -Analyzing file $DIR/array.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ], - [ - "state:", - [], - "statement: _1 = [const 1_i32, const 2_i32, const 3_i32]" - ], - [ - "state:", - [ - "_1" - ], - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _3 = _1" - ] - ], - "state before terminator:", - [ - "_1", - "_3" - ], - "terminator: _2 = std::mem::drop::<[i32; 3]>(move _3) -> [return: bb1, unwind: bb8]", - { - "bb1": [ - "state:", - [ - "_1", - "_2" - ] - ], - "bb8": [ - "state:", - [] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_3)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_5)" - ] - ], - "state before terminator:", - [ - "_1" - ], - "terminator: _5 = std::boxed::Box::<i32>::new(const 4_i32) -> [return: bb2, unwind: bb8]", - { - "bb2": [ - "state:", - [ - "_1", - "_5" - ] - ], - "bb8": [ - "state:", - [] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "_1", - "_5" - ], - "statement: _4 = [move _5]" - ] - ], - "state before terminator:", - [ - "_1", - "_4" - ], - "terminator: drop(_5) -> [return: bb3, unwind: bb8]", - { - "bb3": [ - "state:", - [ - "_1", - "_4" - ] - ], - "bb8": [ - "state:", - [] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "_1", - "_4" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_1", - "_4" - ], - "statement: FakeRead(ForLet(None), _4)" - ], - [ - "state:", - [ - "_1", - "_4" - ], - "statement: StorageLive(_6)" - ], - [ - "state:", - [ - "_1", - "_4" - ], - "statement: StorageLive(_7)" - ], - [ - "state:", - [ - "_1", - "_4" - ], - "statement: _7 = move _4" - ] - ], - "state before terminator:", - [ - "_1", - "_7" - ], - "terminator: _6 = std::mem::drop::<[std::boxed::Box<i32>; 1]>(move _7) -> [return: bb4, unwind: bb6]", - { - "bb4": [ - "state:", - [ - "_1", - "_6" - ] - ], - "bb6": [ - "state:", - [] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "_1", - "_6" - ], - "statement: StorageDead(_7)" - ], - [ - "state:", - [ - "_1", - "_6" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _0 = const ()" - ] - ], - "state before terminator:", - [ - "_0", - "_1" - ], - "terminator: drop(_4) -> [return: bb5, unwind: bb8]", - { - "bb5": [ - "state:", - [ - "_0", - "_1" - ] - ], - "bb8": [ - "state:", - [] - ] - } - ], - "bb5": [ - [ - [ - "state:", - [ - "_0", - "_1" - ], - "statement: StorageDead(_4)" - ], - [ - "state:", - [ - "_0", - "_1" - ], - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ], - "bb6": [ - [], - "state before terminator:", - [], - "terminator: drop(_7) -> [return: bb7, unwind terminate(cleanup)]", - { - "bb7": [ - "state:", - [] - ] - } - ], - "bb7": [ - [], - "state before terminator:", - [], - "terminator: drop(_4) -> [return: bb8, unwind terminate(cleanup)]", - { - "bb8": [ - "state:", - [] - ] - } - ], - "bb8": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.rs deleted file mode 100644 index a9dadb0c..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[analyzer::run] -fn main() { - let a = f(-1); - let b = f(1); - - let c = a + b; - let d = f(c); -} - -fn f(x: i32) -> i32 { - return x; -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.stdout deleted file mode 100644 index 44c84b2e..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/calls.stdout +++ /dev/null @@ -1,333 +0,0 @@ -Analyzing file $DIR/calls.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - [], - "terminator: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]", - { - "bb1": [ - "state:", - [ - "_1" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_2)" - ] - ], - "state before terminator:", - [ - "_1" - ], - "terminator: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]", - { - "bb2": [ - "state:", - [ - "_1", - "_2" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "_1", - "_2" - ], - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _4 = _1" - ], - [ - "state:", - [ - "_1", - "_2", - "_4" - ], - "statement: StorageLive(_5)" - ], - [ - "state:", - [ - "_1", - "_2", - "_4" - ], - "statement: _5 = _2" - ], - [ - "state:", - [ - "_1", - "_2", - "_4", - "_5" - ], - "statement: _6 = CheckedAdd(_4, _5)" - ] - ], - "state before terminator:", - [ - "_1", - "_2", - "_4", - "_5", - "_6" - ], - "terminator: assert(!move (_6.1: bool), /"attempt to compute `{} + {}`, which would overflow/", move _4, move _5) -> [success: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - [ - "_1", - "_2", - "_4", - "_5", - "(_6.0: i32)" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "_1", - "_2", - "_4", - "_5", - "(_6.0: i32)" - ], - "statement: _3 = move (_6.0: i32)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3", - "_4", - "_5" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3", - "_4" - ], - "statement: StorageDead(_4)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3" - ], - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3" - ], - "statement: StorageLive(_7)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3" - ], - "statement: StorageLive(_8)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3" - ], - "statement: _8 = _3" - ] - ], - "state before terminator:", - [ - "_1", - "_2", - "_3", - "_8" - ], - "terminator: _7 = f(move _8) -> [return: bb4, unwind: bb5]", - { - "bb4": [ - "state:", - [ - "_1", - "_2", - "_3", - "_7" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "_1", - "_2", - "_3", - "_7" - ], - "statement: StorageDead(_8)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3", - "_7" - ], - "statement: FakeRead(ForLet(None), _7)" - ], - [ - "state:", - [ - "_1", - "_2", - "_3", - "_7" - ], - "statement: _0 = const ()" - ], - [ - "state:", - [ - "_0", - "_1", - "_2", - "_3", - "_7" - ], - "statement: StorageDead(_7)" - ], - [ - "state:", - [ - "_0", - "_1", - "_2", - "_3" - ], - "statement: StorageDead(_3)" - ], - [ - "state:", - [ - "_0", - "_1", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "_0", - "_1" - ], - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.rs deleted file mode 100644 index dda348eb..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![allow(dropping_references)] - -#[derive(Clone, Default)] -struct T { - // Wrap in box to have non-Copy types - value1: Box<u32>, - value2: Box<u32>, - value3: Box<u32>, -} - -#[analyzer::run] -fn main() { - let mut x = T::default(); - // Move out value1 - drop(x.value1); - // Block value2 - let borrow_value2 = &mut x.value2; - let block_value2 = &borrow_value2; - // Freeze value3 - let shared_ref = &x.value3; - // Nothing should be owned here - drop(shared_ref); - // Now value3 should be owned - drop(block_value2); - // Now value2 should be accessible - x.value1 = Box::new(123); - // Now everything should be owned - drop(x); - // Now the state should be empty -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.stdout deleted file mode 100644 index 75b4c0bf..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/fields.stdout +++ /dev/null @@ -1,695 +0,0 @@ -Analyzing file $DIR/fields.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - [], - "terminator: _1 = <T as std::default::Default>::default() -> [return: bb1, unwind: bb14]", - { - "bb1": [ - "state:", - [ - "_1" - ] - ], - "bb14": [ - "state:", - [] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _3 = move (_1.0: std::boxed::Box<u32>)" - ] - ], - "state before terminator:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_3" - ], - "terminator: _2 = std::mem::drop::<std::boxed::Box<u32>>(move _3) -> [return: bb2, unwind: bb12]", - { - "bb12": [ - "state:", - [] - ], - "bb2": [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ], - "statement: StorageDead(_3)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)" - ], - "statement: _4 = &mut (_1.1: std::boxed::Box<u32>)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "statement: FakeRead(ForLet(None), _4)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "statement: StorageLive(_5)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4" - ], - "statement: _5 = &_4" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5" - ], - "statement: FakeRead(ForLet(None), _5)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5" - ], - "statement: StorageLive(_6)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5" - ], - "statement: _6 = &(_1.2: std::boxed::Box<u32>)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: FakeRead(ForLet(None), _6)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_7)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_8)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: _8 = _6" - ] - ], - "state before terminator:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_8" - ], - "terminator: _7 = std::mem::drop::<&std::boxed::Box<u32>>(move _8) -> [return: bb3, unwind: bb13]", - { - "bb13": [ - "state:", - [] - ], - "bb3": [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_7" - ] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_7" - ], - "statement: StorageDead(_8)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_7" - ], - "statement: StorageDead(_7)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_9)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_10)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: _10 = _5" - ] - ], - "state before terminator:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_10" - ], - "terminator: _9 = std::mem::drop::<&&mut std::boxed::Box<u32>>(move _10) -> [return: bb4, unwind: bb13]", - { - "bb13": [ - "state:", - [] - ], - "bb4": [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_9" - ] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_9" - ], - "statement: StorageDead(_10)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_9" - ], - "statement: StorageDead(_9)" - ], - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_11)" - ] - ], - "state before terminator:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6" - ], - "terminator: _11 = std::boxed::Box::<u32>::new(const 123_u32) -> [return: bb5, unwind: bb13]", - { - "bb13": [ - "state:", - [] - ], - "bb5": [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_11" - ] - ] - } - ], - "bb5": [ - [], - "state before terminator:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_11" - ], - "terminator: drop((_1.0: std::boxed::Box<u32>)) -> [return: bb6, unwind: bb7]", - { - "bb6": [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_11" - ] - ], - "bb7": [ - "state:", - [] - ] - } - ], - "bb6": [ - [ - [ - "state:", - [ - "(_1.1: std::boxed::Box<u32>)", - "(_1.2: std::boxed::Box<u32>)", - "_4", - "_5", - "_6", - "_11" - ], - "statement: (_1.0: std::boxed::Box<u32>) = move _11" - ] - ], - "state before terminator:", - [ - "_1", - "_4", - "_5", - "_6" - ], - "terminator: drop(_11) -> [return: bb8, unwind: bb13]", - { - "bb13": [ - "state:", - [] - ], - "bb8": [ - "state:", - [ - "_1", - "_4", - "_5", - "_6" - ] - ] - } - ], - "bb7": [ - [ - [ - "state:", - [], - "statement: (_1.0: std::boxed::Box<u32>) = move _11" - ] - ], - "state before terminator:", - [ - "(_1.0: std::boxed::Box<u32>)" - ], - "terminator: drop(_11) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - [ - "(_1.0: std::boxed::Box<u32>)" - ] - ] - } - ], - "bb8": [ - [ - [ - "state:", - [ - "_1", - "_4", - "_5", - "_6" - ], - "statement: StorageDead(_11)" - ], - [ - "state:", - [ - "_1", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_12)" - ], - [ - "state:", - [ - "_1", - "_4", - "_5", - "_6" - ], - "statement: StorageLive(_13)" - ], - [ - "state:", - [ - "_1", - "_4", - "_5", - "_6" - ], - "statement: _13 = move _1" - ] - ], - "state before terminator:", - [ - "_4", - "_5", - "_6", - "_13" - ], - "terminator: _12 = std::mem::drop::<T>(move _13) -> [return: bb9, unwind: bb11]", - { - "bb11": [ - "state:", - [] - ], - "bb9": [ - "state:", - [ - "_4", - "_5", - "_6", - "_12" - ] - ] - } - ], - "bb9": [ - [ - [ - "state:", - [ - "_4", - "_5", - "_6", - "_12" - ], - "statement: StorageDead(_13)" - ], - [ - "state:", - [ - "_4", - "_5", - "_6", - "_12" - ], - "statement: StorageDead(_12)" - ], - [ - "state:", - [ - "_4", - "_5", - "_6" - ], - "statement: _0 = const ()" - ], - [ - "state:", - [ - "_0", - "_4", - "_5", - "_6" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_0", - "_4", - "_5" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_0", - "_4" - ], - "statement: StorageDead(_4)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: drop(_1) -> [return: bb10, unwind: bb14]", - { - "bb10": [ - "state:", - [ - "_0" - ] - ], - "bb14": [ - "state:", - [] - ] - } - ], - "bb10": [ - [ - [ - "state:", - [ - "_0" - ], - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ], - "bb11": [ - [], - "state before terminator:", - [], - "terminator: drop(_13) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - [] - ] - } - ], - "bb12": [ - [], - "state before terminator:", - [], - "terminator: drop(_3) -> [return: bb13, unwind terminate(cleanup)]", - { - "bb13": [ - "state:", - [] - ] - } - ], - "bb13": [ - [], - "state before terminator:", - [], - "terminator: drop(_1) -> [return: bb14, unwind terminate(cleanup)]", - { - "bb14": [ - "state:", - [] - ] - } - ], - "bb14": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.rs deleted file mode 100644 index 007a91d8..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[analyzer::run] -fn main() { - let mut x = 1; - let mut y = 3; - x = input(); - if x > 2 { - y = 5; - } else { - y = 7; - } - y = 25; -} - -fn input() -> i32 { - return 42; -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.stdout deleted file mode 100644 index 87be870a..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/repeated_assignment.stdout +++ /dev/null @@ -1,318 +0,0 @@ -Analyzing file $DIR/repeated_assignment.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ], - [ - "state:", - [], - "statement: _1 = const 1_i32" - ], - [ - "state:", - [ - "_1" - ], - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _2 = const 3_i32" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_3)" - ] - ], - "state before terminator:", - [ - "_1", - "_2" - ], - "terminator: _3 = input() -> [return: bb1, unwind: bb5]", - { - "bb1": [ - "state:", - [ - "_1", - "_2", - "_3" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1", - "_2", - "_3" - ], - "statement: _1 = move _3" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_3)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_5)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageLive(_6)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _6 = _1" - ], - [ - "state:", - [ - "_1", - "_2", - "_6" - ], - "statement: _5 = Gt(move _6, const 2_i32)" - ] - ], - "state before terminator:", - [ - "_1", - "_2", - "_5" - ], - "terminator: switchInt(move _5) -> [0: bb3, otherwise: bb2]", - { - "bb2": [ - "state:", - [ - "_1", - "_2" - ] - ], - "bb3": [ - "state:", - [ - "_1", - "_2" - ] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _2 = const 5_i32" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_2", - "_4" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_2", - "_4" - ] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _2 = const 7_i32" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_2", - "_4" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_2", - "_4" - ] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "_1", - "_2", - "_4" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_1", - "_2", - "_4" - ], - "statement: StorageDead(_4)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _2 = const 25_i32" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _0 = const ()" - ], - [ - "state:", - [ - "_0", - "_1", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "_0", - "_1" - ], - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.rs deleted file mode 100644 index 4926701b..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[analyzer::run] -fn main() { - { - let x = 123; - } - { - let y = 456; - } -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.stdout deleted file mode 100644 index 3167aebf..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/scopes.stdout +++ /dev/null @@ -1,90 +0,0 @@ -Analyzing file $DIR/scopes.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ], - [ - "state:", - [], - "statement: StorageLive(_2)" - ], - [ - "state:", - [], - "statement: _2 = const 123_i32" - ], - [ - "state:", - [ - "_2" - ], - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - [ - "_2" - ], - "statement: _1 = const ()" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageDead(_1)" - ], - [ - "state:", - [], - "statement: StorageLive(_3)" - ], - [ - "state:", - [], - "statement: _3 = const 456_i32" - ], - [ - "state:", - [ - "_3" - ], - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - [ - "_3" - ], - "statement: _0 = const ()" - ], - [ - "state:", - [ - "_0", - "_3" - ], - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.rs b/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.rs deleted file mode 100644 index a3771f91..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[analyzer::run] -fn main() { - let x = 123; - let y: u32; - y = x; -} diff --git a/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.stdout b/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.stdout deleted file mode 100644 index 69cbf318..00000000 --- a/rr_frontend/analysis/tests/test_cases/definitely_initialized/very_simple_assignment.stdout +++ /dev/null @@ -1,93 +0,0 @@ -Analyzing file $DIR/very_simple_assignment.rs using DefinitelyInitializedAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - [], - "statement: StorageLive(_1)" - ], - [ - "state:", - [], - "statement: _1 = const 123_u32" - ], - [ - "state:", - [ - "_1" - ], - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_2)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _3 = _1" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: _2 = move _3" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: StorageDead(_3)" - ], - [ - "state:", - [ - "_1", - "_2" - ], - "statement: _0 = const ()" - ], - [ - "state:", - [ - "_0", - "_1", - "_2" - ], - "statement: StorageDead(_2)" - ], - [ - "state:", - [ - "_0", - "_1" - ], - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - [ - "_0" - ], - "terminator: return", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/framing/ref_field.rs b/rr_frontend/analysis/tests/test_cases/framing/ref_field.rs deleted file mode 100644 index 744d57c4..00000000 --- a/rr_frontend/analysis/tests/test_cases/framing/ref_field.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn foo<T>(_x: T) {} - -#[analyzer::run] -fn main() { - let mut x = (Box::new(123), Box::new(123)); - foo(&x.0); - foo(&mut x.1); - drop(x); -} diff --git a/rr_frontend/analysis/tests/test_cases/framing/ref_field.stdout b/rr_frontend/analysis/tests/test_cases/framing/ref_field.stdout deleted file mode 100644 index 47c265d6..00000000 --- a/rr_frontend/analysis/tests/test_cases/framing/ref_field.stdout +++ /dev/null @@ -1,589 +0,0 @@ -Analyzing file $DIR/ref_field.rs using FramingAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: StorageLive(_1)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: StorageLive(_2)" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: _2 = std::boxed::Box::<i32>::new(const 123_i32) -> [return: bb1, unwind: bb12]", - { - "bb1": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb12": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "statement: StorageLive(_3)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "terminator: _3 = std::boxed::Box::<i32>::new(const 123_i32) -> [return: bb2, unwind: bb11]", - { - "bb11": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb2": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: _1 = (move _2, move _3)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "terminator: drop(_3) -> [return: bb3, unwind: bb11]", - { - "bb11": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb3": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "terminator: drop(_2) -> [return: bb4, unwind: bb12]", - { - "bb12": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb4": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "(_1.1: std::boxed::Box<i32>)" - ] - }, - "statement: _5 = &(_1.0: std::boxed::Box<i32>)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "(_1.1: std::boxed::Box<i32>)" - ] - }, - "terminator: _4 = foo::<&std::boxed::Box<i32>>(move _5) -> [return: bb5, unwind: bb10]", - { - "bb10": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb5": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb5": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1", - "_4" - ], - "frame_owned": [ - "_1", - "_4" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_4" - ], - "frame_owned": [ - "_1", - "_4" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "frame_accessible": [ - "(_1.0: std::boxed::Box<i32>)" - ], - "frame_owned": [ - "(_1.0: std::boxed::Box<i32>)" - ] - }, - "statement: _7 = &mut (_1.1: std::boxed::Box<i32>)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "(_1.0: std::boxed::Box<i32>)" - ], - "frame_owned": [ - "(_1.0: std::boxed::Box<i32>)" - ] - }, - "terminator: _6 = foo::<&mut std::boxed::Box<i32>>(move _7) -> [return: bb6, unwind: bb10]", - { - "bb10": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb6": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb6": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1", - "_6" - ], - "frame_owned": [ - "_1", - "_6" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_6" - ], - "frame_owned": [ - "_1", - "_6" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_9)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: _9 = move _1" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: _8 = std::mem::drop::<(std::boxed::Box<i32>, std::boxed::Box<i32>)>(move _9) -> [return: bb7, unwind: bb9]", - { - "bb7": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb9": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb7": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_8" - ], - "frame_owned": [ - "_8" - ] - }, - "statement: StorageDead(_9)" - ], - [ - "state:", - { - "frame_accessible": [ - "_8" - ], - "frame_owned": [ - "_8" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: _0 = const ()" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "terminator: drop(_1) -> [return: bb8, unwind: bb12]", - { - "bb12": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb8": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb8": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb9": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_9) -> [return: bb10, unwind terminate(cleanup)]", - { - "bb10": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb10": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_1) -> [return: bb12, unwind terminate(cleanup)]", - { - "bb12": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb11": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_2) -> [return: bb12, unwind terminate(cleanup)]", - { - "bb12": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb12": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.rs b/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.rs deleted file mode 100644 index e2eb375b..00000000 --- a/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::cell::*; - -#[analyzer::run] -pub fn break_it(rc: &RefCell<i32>, r: Ref<'_, i32>) { - // `r` has a shared reference, it is passed in as argument and hence - // a barrier is added that marks this memory as read-only for the entire - // duration of this function. - drop(r); - // *oops* here we can mutate that memory. - *rc.borrow_mut() = 2; -} - -#[analyzer::run] -pub fn main() { - let rc = RefCell::new(0); - break_it(&rc, rc.borrow()) -} diff --git a/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.stdout b/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.stdout deleted file mode 100644 index 74fb6889..00000000 --- a/rr_frontend/analysis/tests/test_cases/framing/rust_issue_63787.stdout +++ /dev/null @@ -1,712 +0,0 @@ -Analyzing file $DIR/rust_issue_63787.rs using FramingAnalysis... -Result for function break_it(): -{ - "bb0": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_1", - "_2" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_1", - "_2" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: _4 = move _2" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "terminator: _3 = std::mem::drop::<std::cell::Ref<'_, i32>>(move _4) -> [return: bb1, unwind: bb7]", - { - "bb1": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb7": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1", - "_3" - ], - "frame_owned": [ - "_1", - "_3" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_3" - ], - "frame_owned": [ - "_1", - "_3" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [] - }, - "statement: _8 = &(*_1)" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: _7 = std::cell::RefCell::<i32>::borrow_mut(move _8) -> [return: bb2, unwind: bb8]", - { - "bb2": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb8": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: _6 = &mut _7" - ], - [ - "state:", - { - "frame_accessible": [ - "_6" - ], - "frame_owned": [ - "_6" - ] - }, - "statement: StorageDead(_8)" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: _5 = <std::cell::RefMut<'_, i32> as std::ops::DerefMut>::deref_mut(move _6) -> [return: bb3, unwind: bb6]", - { - "bb3": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb6": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_5" - ], - "frame_owned": [ - "_5" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: (*_5) = const 2_i32" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_7) -> [return: bb4, unwind: bb8]", - { - "bb4": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb8": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: _0 = const ()" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "terminator: drop(_2) -> [return: bb5, unwind: bb9]", - { - "bb5": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb9": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb5": [ - [], - "state before terminator:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb6": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_7) -> [return: bb8, unwind terminate(cleanup)]", - { - "bb8": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb7": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_4) -> [return: bb8, unwind terminate(cleanup)]", - { - "bb8": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb8": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_2) -> [return: bb9, unwind terminate(cleanup)]", - { - "bb9": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb9": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: resume", - {} - ] -} -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: _1 = std::cell::RefCell::<i32>::new(const 0_i32) -> [return: bb1, unwind: bb5]", - { - "bb1": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb5": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [ - "_1" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [] - }, - "statement: _3 = &_1" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_3" - ], - "frame_owned": [] - }, - "statement: _2 = &(*_3)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "statement: _5 = &_1" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1", - "_2" - ], - "frame_owned": [ - "_2" - ] - }, - "terminator: _4 = std::cell::RefCell::<i32>::borrow(move _5) -> [return: bb2, unwind: bb5]", - { - "bb2": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb5": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_1", - "_2", - "_4" - ], - "frame_owned": [ - "_2", - "_4" - ] - }, - "statement: StorageDead(_5)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_1" - ], - "frame_owned": [] - }, - "terminator: _0 = break_it(move _2, move _4) -> [return: bb3, unwind: bb4]", - { - "bb3": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ], - "bb4": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "frame_accessible": [ - "_0", - "_1" - ], - "frame_owned": [ - "_0", - "_1" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frame_accessible": [ - "_0", - "_1" - ], - "frame_owned": [ - "_0", - "_1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "frame_accessible": [ - "_0", - "_1" - ], - "frame_owned": [ - "_0", - "_1" - ] - }, - "statement: StorageDead(_1)" - ], - [ - "state:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - { - "frame_accessible": [ - "_0" - ], - "frame_owned": [ - "_0" - ] - }, - "terminator: return", - {} - ], - "bb4": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: drop(_4) -> [return: bb5, unwind terminate(cleanup)]", - { - "bb5": [ - "state:", - { - "frame_accessible": [], - "frame_owned": [] - } - ] - } - ], - "bb5": [ - [], - "state before terminator:", - { - "frame_accessible": [], - "frame_owned": [] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/basic-move.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/basic-move.rs deleted file mode 100644 index abc3e4af..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/basic-move.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub struct S2 { - f: u32, -} - -pub fn test4() -> S2 { - let x = S2 { f: 8 }; - let y = x; - assert!(y.f == 9); - y -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/check-move.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/check-move.rs deleted file mode 100644 index c0f6a11f..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/check-move.rs +++ /dev/null @@ -1,8 +0,0 @@ -struct T(i32); - -fn main() { - let mut x = T(5); - let y = x; - x = T(6); - assert!(y.0 == 5); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/consume-call.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/consume-call.rs deleted file mode 100644 index e8455a07..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/consume-call.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct A; -struct B { - a1: A, - a2: A, -} -struct C { - b: B, -} -struct D { - c: C, -} - -fn consume(a: A) {} - -fn main() { - let a1 = A; - let a2 = A; - let b = B { a1, a2 }; - let c = C { b }; - let d = D { c }; - - consume(d.c.b.a1); // drop sub-field - - let x = d.c.b.a2; // still accessible -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/create-box.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/create-box.rs deleted file mode 100644 index 3e7e389e..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/create-box.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(box_patterns)] - -fn use_box(v: i32) -> Box<i32> { - let x = Box::new(v); - let y = *x; - assert!(v == y); - let z = Box::new(y); - assert!(v == *z); - let result = Box::new(*z); - result -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/deref.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/deref.rs deleted file mode 100644 index 030be55c..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/deref.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![feature(box_patterns)] - -struct InfiniteList1 { - next: Box<InfiniteList1>, -} - -fn consume1(x: InfiniteList1) {} - -fn reassignment1(mut x: InfiniteList1) { - // Consume the only path. - x = *(*(*(*(*x.next).next).next).next).next; - consume1(x); -} - -struct InfiniteList2 { - val: u32, - next: Box<InfiniteList2>, -} - -fn consume2(x: InfiniteList2) {} - -fn reassignment2a(a: InfiniteList2) { - let mut x = a; - // Consume one of the paths. - x = *x.next; - consume2(x); -} - -fn reassignment2b(a: InfiniteList2) { - let mut x = a; - // Consume one of the paths. - x = *(*(*(*(*x.next).next).next).next).next; - consume2(x); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expired.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expired.rs deleted file mode 100644 index 75ad5e73..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expired.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(box_patterns)] - -fn foo<T>(x: T) {} - -fn main() { - let mut x = Box::new(123); - let y = &x; - foo(y); - // `y` should expire here - let z = &mut x; - foo(z); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-if.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-if.rs deleted file mode 100644 index 0318deaf..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-if.rs +++ /dev/null @@ -1,26 +0,0 @@ -struct G { - value: u32, -} - -struct F { - f: G, - g: G, -} - -fn consume_F(_f: F) {} - -fn test7(y: F, z: F, b: bool) { - let mut y = y; - let mut z = z; - let mut x; - if b { - x = &mut y; - } else { - x = &mut z; - } - let f = &mut x.f; - consume_F(y); - consume_F(z); -} - -fn use_both(_f: &mut G, _g: &mut G) {} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-magic.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-magic.rs deleted file mode 100644 index f9239188..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-magic.rs +++ /dev/null @@ -1,31 +0,0 @@ -struct G { - value: u32, -} - -struct F { - f: G, - g: G, -} - -fn consume_F(_f: F) {} - -fn use_both(_f: &mut G, _g: &mut G) {} - -fn either<'a>(f: &'a mut G, _g: &'a mut G) -> &'a mut G { - f -} - -fn test3(y: &mut F) { - let x = &mut *y; - let f = &mut x.f; - let g = &mut x.g; - use_both(f, g); -} - -fn test3b(y: &mut F) { - let x = &mut *y; - let f = &mut x.f; - let g = &mut x.g; - - let m = either(f, g); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-moves.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-moves.rs deleted file mode 100644 index 56005a46..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die-with-moves.rs +++ /dev/null @@ -1,24 +0,0 @@ -struct G { - value: u32, -} - -struct F { - f: G, - g: G, -} - -fn consume_F(_f: F) {} - -fn use_both(_f: &mut G, _g: &mut G) {} - -fn test1(x: &mut F) { - let y = x; - let z = y; - let _z = &mut *z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die.rs deleted file mode 100644 index 98583cab..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/borrow-die.rs +++ /dev/null @@ -1,76 +0,0 @@ -struct G { - value: u32, -} - -struct F { - f: G, - g: G, -} - -fn consume_F(_f: F) {} - -fn test7(y: F, z: F, b: bool) { - let mut y = y; - let mut z = z; - let mut x; - if b { - x = &mut y; - } else { - x = &mut z; - } - let f = &mut x.f; - consume_F(y); - consume_F(z); -} - -fn test6(y: F, z: F, b: bool) { - let mut y = y; - let mut z = z; - let mut x; - if b { - x = &mut y; - consume_F(z); - } else { - x = &mut z; - consume_F(y); - } - let f = &mut x.f; -} - -fn test1(x: &mut F) { - let y = x; - let z = y; - let _z = &mut *z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; -} - -fn test2(x: &mut F, b: bool) { - let y = &mut *x; - let z = y; - let z2; - if b { - z2 = z; - } else { - z2 = x; - } - let _z = z2; - let _z = _z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; - let _z = &mut *_z; -} - -fn test3(y: &mut F) { - let x = &mut *y; - let f = &mut x.f; - let g = &mut x.g; - use_both(f, g); -} - -fn use_both(_f: &mut G, _g: &mut G) {} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/issue-25-simpl.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/issue-25-simpl.rs deleted file mode 100644 index aa60e7a3..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/issue-25-simpl.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct T { - f: i32, -} - -fn extract(x: &mut T) -> i32 { - x.f -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/simple-expire-borrows.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/simple-expire-borrows.rs deleted file mode 100644 index eab3460f..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/expiring-loans/simple-expire-borrows.rs +++ /dev/null @@ -1,18 +0,0 @@ -struct G { - value: u32, -} - -struct F { - f: G, - g: G, -} - -fn use_mut_ref(x: &mut G) {} - -fn test1(x: F) { - let mut y = x; - let z = &mut y.f; - use_mut_ref(z); - let k = &mut y.f; - //use_mut_ref(k); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/external-call-fail.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/external-call-fail.rs deleted file mode 100644 index 259d675b..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/external-call-fail.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn test(x: i32) { - let is_pos = x.is_positive(); - assert!(is_pos); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/field-types.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/field-types.rs deleted file mode 100644 index 7bbc6ce0..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/field-types.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct A { - val: i32, -} - -struct B { - val: bool, -} - -struct C { - val: A, -} - -fn main() { - let mut a = A { val: 111 }; - let mut b = B { val: true }; - let mut c = C { - val: A { val: 222 }, - }; - a.val = 333; - b.val = false; - c.val.val = 444; - assert!(a.val == 333); - assert!(b.val == false); - assert!(c.val.val == 444); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/fields.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/fields.rs deleted file mode 100644 index 3525ed2e..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/fields.rs +++ /dev/null @@ -1,27 +0,0 @@ -#[derive(Clone, Default)] -struct T { - // Wrap in Box to have non-Copy types - value1: Box<u32>, - value2: Box<u32>, - value3: Box<u32>, -} - -fn main() { - let mut x = T::default(); - // Move out value1 - drop(x.value1); - // Block value2 - let borrow_value2 = &mut x.value2; - let block_value2 = &borrow_value2; - // Freeze value3 - let shared_ref = &x.value3; - // Nothing should be owned here - drop(shared_ref); - // Now value3 should be owned - drop(block_value2); - // Now value2 should be owned - x.value1 = Box::new(123); - // Now everything should be owned - drop(x); - // Now the state should be empty -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/join.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/join.rs deleted file mode 100644 index 61ff2836..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/join.rs +++ /dev/null @@ -1,15 +0,0 @@ -struct MyStruct { - a: i32, - b: (i32, i32), -} - -fn foo(mut x: MyStruct, switch: bool) -> MyStruct { - if switch { - // Unfold MyStruct - x.b = (444, 555); - } else { - // Nothing - } - // Join branches - x -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/array-mut-loop.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/array-mut-loop.rs deleted file mode 100644 index 2613f699..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/array-mut-loop.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn looping() { - let mut a = [0; 3]; - let mut i = 0; - - while i < 3 { - a[i] = a[i]; - i += 1; - } - - assert!(a[0] == 0); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/break-continue.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/break-continue.rs deleted file mode 100644 index 708cec24..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/break-continue.rs +++ /dev/null @@ -1,48 +0,0 @@ -fn random(i: u32) -> bool { - unimplemented!() -} - -fn continue_before_invariant() { - let mut i = 0; - 'myloop: while { - if random(i + 2) { - continue 'myloop; - } - random(i + 3) - } { - i += 1; - } -} - -fn break_before_invariant() { - let mut i = 0; - 'outer: while random(i + 0) { - 'inner: while { - if random(i + 2) { - break 'inner; // Ok - } - if random(i + 2) { - break 'outer; // Ok - } - random(i + 3) - } { - i += 1; - } - } -} - -fn continue_outer_loop_before_invariant() { - let mut i = 0; - 'outer: while random(i + 0) { - 'inner: while { - if random(i + 2) { - continue 'outer; // Ok - } - random(i + 3) - } { - i += 1; - } - } -} - -fn main() {} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/loops.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/loops.rs deleted file mode 100644 index 7f24124a..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/loops.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn borrow(_x: &i32) {} - -pub fn test(n: &i32) { - let mut i = 0; - while i < *n { - i += 1; - borrow(n); - } -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/tmp-in-guard.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/tmp-in-guard.rs deleted file mode 100644 index f46d252a..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/loops/tmp-in-guard.rs +++ /dev/null @@ -1,51 +0,0 @@ -fn random() -> u32 { - unimplemented!() -} - -fn test1() { - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - - while { - let guard = random() < 55; - - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - - guard - } { - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - } - - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; -} - -fn test2() { - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - - while { - let guard = random() < 55; - - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - - guard - } { - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; - } - - let mut tmp = Box::new(Box::new(random())); - let tmp_ref = &tmp; - let tmp_ref_mut = &mut tmp; -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/multiple-branches.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/multiple-branches.rs deleted file mode 100644 index f5d43fdc..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/multiple-branches.rs +++ /dev/null @@ -1,47 +0,0 @@ -struct MyStruct { - a: i32, - b: (i32, i32), -} - -fn foo(switch: bool) -> MyStruct { - let mut x = MyStruct { - a: 000, - b: (000, 000), - }; - let y = MyStruct { - a: 111, - b: (222, 333), - }; - if switch { - return x; - } - if switch { - x.b.0 = 444; - } - if switch { - x.b.1 = 555; - } - if switch { - return x; - } - if switch { - x.a = 666; - } - if switch { - x.b = (777, 888); - } - if switch { - return x; - } - if switch { - x.a = y.a; - } - if switch { - x.b = y.b; - } - if switch { - x.b.0 = 999; - } - let z = x; - z -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/borrow-first.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/borrow-first.rs deleted file mode 100644 index 2c0eb5c0..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/borrow-first.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Source: http://smallcultfollowing.com/babysteps/blog/2018/06/15/mir-based-borrow-check-nll-status-update/ - -fn some_condition<T>(r: &T) -> bool { - true -} - -fn foo<T>(vec: &mut Vec<T>, x: T) -> &T { - let r = &vec[0]; - if some_condition(r) { - return r; - } - - // Question: can we mutate `vec` here? On Nightly, - // you get an error, because a reference that is returned (like `r`) - // is considered to be in scope until the end of the function, - // even if that return only happens conditionally. Polonius can - // accept this code. - vec.push(x); - let last = vec.len() - 1; - &vec[last] -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/message.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/message.rs deleted file mode 100644 index a52e7276..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/message.rs +++ /dev/null @@ -1,26 +0,0 @@ -/// An adaptation of this example: -/// https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=b8dfafd14113f2933c1b5127c861df44 -/// -/// which was created by Matsakis to show-case NLL in his blog: -/// http://smallcultfollowing.com/babysteps/blog/2018/10/31/mir-based-borrowck-is-almost-here/ -use std::sync::mpsc::{Receiver, Sender}; - -enum Message { - Letter { recipient: String, data: String }, -} - -fn router(me: &str, rx: Receiver<Message>, tx: Sender<Message>) { - for message in rx { - match &message { - Message::Letter { recipient, data } => { - if recipient != me { - tx.send(message).unwrap(); - } else { - process(data); - } - }, - } - } -} - -fn process(_data: &str) {} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/wrong-case1.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/wrong-case1.rs deleted file mode 100644 index dd29db26..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/nll-rfc/wrong-case1.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Adapted from https://github.com/nikomatsakis/nll-rfc/blob/master/0000-nonlexical-lifetimes.md - -fn capitalize(vec: &mut [char]) {} - -fn bar() { - let mut data = vec!['a', 'b', 'c']; - let slice = &mut data[..]; - capitalize(slice); - data.push('d'); - data.push('e'); - data.push('f'); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/paths.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/paths.rs deleted file mode 100644 index 5e5d4511..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/paths.rs +++ /dev/null @@ -1,50 +0,0 @@ -struct T1 { - f: u32, - g: u32, - h: u32, -} - -struct T2 { - f: T1, - g: T1, - h: T1, -} - -struct T3 { - f: T1, - g: T2, - h: T2, -} - -fn use_t3(_x: T3) {} - -fn test1(x: T3) { - let z = x.f; -} - -fn test2(b: bool, mut x: T3, y: T1) { - if b { - let z = x.f; - } - x.f = y; - use_t3(x); -} - -fn test3(mut x: T3, y: T1) { - x.f = y; -} - -struct S1 { - f: T1, -} - -struct S2 { - f: S1, -} - -fn test4(b: bool, mut x: S2, y: T1) { - if b { - let z = x.f.f; - } - x.f.f = y; -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/predicate-old-expr.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/predicate-old-expr.rs deleted file mode 100644 index c8a22d66..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/predicate-old-expr.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![feature(box_patterns)] - -use std::borrow::BorrowMut; - -struct List { - value: u32, - next: Option<Box<List>>, -} - -fn lookup(head: &List, index: usize) -> u32 { - let result; - if index == 0 { - result = head.value - } else { - match head.next { - Some(box ref tail) => { - result = lookup(tail, index - 1); - }, - None => { - unreachable!(); - }, - } - } - result -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/reassignment.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/reassignment.rs deleted file mode 100644 index 5e6917df..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/reassignment.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Example of reassignment - -#![feature(box_patterns)] - -struct InfiniteList { - val: i32, - next: Box<InfiniteList>, -} - -fn consume(x: InfiniteList) {} - -fn reassignment(a: InfiniteList) { - let mut x = a; - - // Reassignment - x = *(*(*(*(*x.next).next).next).next).next; - - consume(x); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/ref_field.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/ref_field.rs deleted file mode 100644 index fd06b5b0..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/ref_field.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn foo<T>(_x: T) {} - -fn main() { - let x = (Box::new(123), Box::new(123)); - let y = &x.0; - let mut z = (y, y, y); - z.2 = &x.1; - foo(&z); - foo(&z); - drop(x); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/simple-assert.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/simple-assert.rs deleted file mode 100644 index 176e1abb..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/simple-assert.rs +++ /dev/null @@ -1,21 +0,0 @@ -fn foo(x: i32, y: i32, guard: bool) { - let mut z = x + y; - - if guard { - z = 100; - } - - // later... - - if guard { - assert!(z == 100); - } else { - assert!(z - x == y); - } -} - -fn main() { - let x = 10; - let y = 10; - debug_assert!(x + y == 20); -} diff --git a/rr_frontend/analysis/tests/test_cases/gen_accessibility/structs.rs b/rr_frontend/analysis/tests/test_cases/gen_accessibility/structs.rs deleted file mode 100644 index 43963bf1..00000000 --- a/rr_frontend/analysis/tests/test_cases/gen_accessibility/structs.rs +++ /dev/null @@ -1,18 +0,0 @@ -struct MyStruct { - a: i32, - b: (i32, i32), -} - -fn foo<'a>(arg: MyStruct) -> (i32, i32) { - let mut x = MyStruct { - a: 111, - b: (222, 333), - }; - x.b.0 = 444; - let y = x; - let z = MyStruct { - a: 555, - b: (666, 777), - }; - y.b -} diff --git a/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.rs b/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.rs deleted file mode 100644 index dea001fa..00000000 --- a/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![feature(box_patterns)] - -struct Node { - value: u32, - next: Option<Box<Node>>, -} - -#[analyzer::run] -fn borrow_fields(mut head: Node) { - let _val = &mut head.value; - let _next = &head.next; - noop(); -} - -#[analyzer::run] -fn last_val_mut(node: &mut Node) -> &mut u32 { - let mut curr = node; - while let Some(box next) = &mut curr.next { - curr = next; - } - &mut curr.value -} - -#[analyzer::run] -fn modify_last_val(head: &mut Node) { - let first = &mut *head; - let val = last_val_mut(first); - *val = 123; - noop(); -} - -#[analyzer::run] -fn noop() {} - -fn main() {} diff --git a/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.stdout b/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.stdout deleted file mode 100644 index c70dc6f1..00000000 --- a/rr_frontend/analysis/tests/test_cases/maybe_borrowed/linked_list.stdout +++ /dev/null @@ -1,846 +0,0 @@ -Analyzing file $DIR/linked_list.rs using MaybeBorrowedAnalysis... -Result for function borrow_fields(): -{ - "bb0": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _2 = &mut (_1.0: u32)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "(_1.0: u32)" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _3 = &(_1.1: std::option::Option<std::boxed::Box<Node>>)" - ], - [ - "state:", - { - "frozen": [ - "(_1.1: std::option::Option<std::boxed::Box<Node>>)" - ], - "blocked": [] - }, - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_4)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: _4 = noop() -> [return: bb1, unwind: bb3]", - { - "bb1": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ], - "bb3": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_2)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: drop(_1) -> [return: bb2, unwind: bb4]", - { - "bb2": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ], - "bb4": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb2": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: return", - {} - ], - "bb3": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: drop(_1) -> [return: bb4, unwind terminate(cleanup)]", - { - "bb4": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb4": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: resume", - {} - ] -} -Result for function last_val_mut(): -{ - "bb0": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _3 = move _1" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_4)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: goto -> bb1", - { - "bb1": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb1": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: falseUnwind -> [real: bb2, unwind: bb6]", - { - "bb2": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ], - "bb6": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _6 = &mut ((*_3).1: std::option::Option<std::boxed::Box<Node>>)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "statement: FakeRead(ForMatchedPlace(None), _6)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "statement: _7 = discriminant((*_6))" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "terminator: switchInt(move _7) -> [1: bb3, otherwise: bb5]", - { - "bb3": [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - } - ], - "bb5": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb3": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "terminator: falseEdge -> [real: bb4, imaginary: bb5]", - { - "bb4": [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - } - ], - "bb5": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "statement: _8 = &mut (*(((*_6) as Some).0: std::boxed::Box<Node>))" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3", - "_6" - ] - }, - "statement: StorageLive(_9)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3", - "_6" - ] - }, - "statement: _9 = &mut (*_8)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3", - "_6", - "_8" - ] - }, - "statement: _3 = move _9" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_6", - "_8" - ] - }, - "statement: StorageDead(_9)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_6", - "_8" - ] - }, - "statement: _5 = const ()" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_6", - "_8" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_6" - ] - }, - "statement: StorageDead(_6)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: goto -> bb1", - { - "bb1": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb5": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_11)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _4 = const ()" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_11)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_13)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _13 = &mut ((*_3).0: u32)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3" - ] - }, - "statement: _2 = &mut (*_13)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_3", - "_13" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_13" - ] - }, - "statement: _0 = &mut (*_2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_2", - "_13" - ] - }, - "statement: StorageDead(_13)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_2" - ] - }, - "statement: StorageDead(_2)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: return", - {} - ], - "bb6": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: resume", - {} - ] -} -Result for function modify_last_val(): -{ - "bb0": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _2 = &mut (*_1)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1" - ] - }, - "statement: _4 = &mut (*_2)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [ - "_1", - "_2" - ] - }, - "terminator: _3 = last_val_mut(move _4) -> [return: bb1, unwind: bb3]", - { - "bb1": [ - "state:", - { - "frozen": [], - "blocked": [ - "_1", - "_2" - ] - } - ], - "bb3": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1", - "_2" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1", - "_2" - ] - }, - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [ - "_1", - "_2" - ] - }, - "statement: (*_3) = const 123_u32" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageLive(_5)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: _5 = noop() -> [return: bb2, unwind: bb3]", - { - "bb2": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ], - "bb3": [ - "state:", - { - "frozen": [], - "blocked": [] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: StorageDead(_2)" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: return", - {} - ], - "bb3": [ - [], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: resume", - {} - ] -} -Result for function noop(): -{ - "bb0": [ - [ - [ - "state:", - { - "frozen": [], - "blocked": [] - }, - "statement: _0 = const ()" - ] - ], - "state before terminator:", - { - "frozen": [], - "blocked": [] - }, - "terminator: return", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.rs b/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.rs deleted file mode 100644 index e70e687a..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn main() { - let a = abs(-1); - let b = abs(1); - println!("{}", a + b); -} - -#[analyzer::run] -fn abs(x: i32) -> i32 { - let res: i32; - if x >= 0 { - res = x; - } else { - res = -x; - } - return res; -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.stdout b/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.stdout deleted file mode 100644 index 2aab0969..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/abs.stdout +++ /dev/null @@ -1,710 +0,0 @@ -Analyzing file $DIR/abs.rs using ReachingDefsAnalysis... -Result for function abs(): -{ - "bb0": [ - [ - [ - "state:", - { - "_1": [ - "arg0" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ] - }, - "statement: _6 = _1" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: _5 = Ge(move _6, const 0_i32)" - ] - ], - "state before terminator:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "terminator: switchInt(move _5) -> [0: bb2, otherwise: bb1]", - { - "bb1": [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - } - ], - "bb2": [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: _7 = _1" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ] - }, - "statement: _3 = move _7" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ] - }, - "statement: _4 = const ()" - ] - ], - "state before terminator:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7" - ], - "_4": [ - "bb1[5]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ] - }, - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7" - ], - "_4": [ - "bb1[5]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ] - }, - "statement: _8 = _1" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ] - }, - "statement: _9 = Eq(_8, const i32::MIN)" - ] - ], - "state before terminator:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "terminator: assert(!move _9, /"attempt to negate `{}`, which would overflow/", _8) -> [success: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: _3 = Neg(move _8)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb3[0]: _3 = Neg(move _8)" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb3[0]: _3 = Neg(move _8)" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: _4 = const ()" - ] - ], - "state before terminator:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7", - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb1[5]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7", - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb1[5]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7", - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb1[5]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: _0 = _3" - ], - [ - "state:", - { - "_0": [ - "bb4[2]: _0 = _3" - ], - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7", - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb1[5]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - { - "_0": [ - "bb4[2]: _0 = _3" - ], - "_1": [ - "arg0" - ], - "_3": [ - "bb1[3]: _3 = move _7", - "bb3[0]: _3 = Neg(move _8)" - ], - "_4": [ - "bb1[5]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_7": [ - "bb1[2]: _7 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - { - "_1": [ - "arg0" - ], - "_5": [ - "bb0[5]: _5 = Ge(move _6, const 0_i32)" - ], - "_6": [ - "bb0[4]: _6 = _1" - ], - "_8": [ - "bb2[2]: _8 = _1" - ], - "_9": [ - "bb2[3]: _9 = Eq(_8, const i32::MIN)" - ] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.rs b/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.rs deleted file mode 100644 index a9dadb0c..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[analyzer::run] -fn main() { - let a = f(-1); - let b = f(1); - - let c = a + b; - let d = f(c); -} - -fn f(x: i32) -> i32 { - return x; -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.stdout b/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.stdout deleted file mode 100644 index b03df648..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/calls.stdout +++ /dev/null @@ -1,792 +0,0 @@ -Analyzing file $DIR/calls.rs using ReachingDefsAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - {}, - "statement: StorageLive(_1)" - ] - ], - "state before terminator:", - {}, - "terminator: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]", - { - "bb1": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ] - }, - "statement: StorageLive(_2)" - ] - ], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ] - }, - "terminator: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]", - { - "bb2": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ] - }, - "statement: _4 = _1" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ] - }, - "statement: _5 = _2" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ] - }, - "statement: _6 = CheckedAdd(_4, _5)" - ] - ], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "terminator: assert(!move (_6.1: bool), /"attempt to compute `{} + {}`, which would overflow/", move _4, move _5) -> [success: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: _3 = move (_6.0: i32)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: FakeRead(ForLet(None), _3)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: StorageLive(_7)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: StorageLive(_8)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ] - }, - "statement: _8 = _3" - ] - ], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "terminator: _7 = f(move _8) -> [return: bb4, unwind: bb5]", - { - "bb4": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: StorageDead(_8)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: FakeRead(ForLet(None), _7)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "_0": [ - "bb4[2]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: StorageDead(_7)" - ], - [ - "state:", - { - "_0": [ - "bb4[2]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "_0": [ - "bb4[2]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "_0": [ - "bb4[2]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "_0": [ - "bb4[2]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = f(const -1_i32) -> [return: bb1, unwind: bb5]" - ], - "_2": [ - "bb1[2]: _2 = f(const 1_i32) -> [return: bb2, unwind: bb5]" - ], - "_3": [ - "bb3[0]: _3 = move (_6.0: i32)" - ], - "_4": [ - "bb2[3]: _4 = _1" - ], - "_5": [ - "bb2[5]: _5 = _2" - ], - "_6": [ - "bb2[6]: _6 = CheckedAdd(_4, _5)" - ], - "_7": [ - "bb3[7]: _7 = f(move _8) -> [return: bb4, unwind: bb5]" - ], - "_8": [ - "bb3[6]: _8 = _3" - ] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.rs b/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.rs deleted file mode 100644 index 007a91d8..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[analyzer::run] -fn main() { - let mut x = 1; - let mut y = 3; - x = input(); - if x > 2 { - y = 5; - } else { - y = 7; - } - y = 25; -} - -fn input() -> i32 { - return 42; -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.stdout b/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.stdout deleted file mode 100644 index 83583644..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/repeated_assignment.stdout +++ /dev/null @@ -1,717 +0,0 @@ -Analyzing file $DIR/repeated_assignment.rs using ReachingDefsAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - {}, - "statement: StorageLive(_1)" - ], - [ - "state:", - {}, - "statement: _1 = const 1_i32" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ] - }, - "statement: _2 = const 3_i32" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ] - }, - "statement: FakeRead(ForLet(None), _2)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ] - }, - "statement: StorageLive(_3)" - ] - ], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ] - }, - "terminator: _3 = input() -> [return: bb1, unwind: bb5]", - { - "bb1": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - } - ], - "bb5": [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - } - ] - } - ], - "bb1": [ - [ - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: _1 = move _3" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: StorageLive(_4)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: StorageLive(_5)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: StorageLive(_6)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "statement: _6 = _1" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _5 = Gt(move _6, const 2_i32)" - ] - ], - "state before terminator:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "terminator: switchInt(move _5) -> [0: bb3, otherwise: bb2]", - { - "bb2": [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - } - ], - "bb3": [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - } - ] - } - ], - "bb2": [ - [ - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _2 = const 5_i32" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _4 = const ()" - ] - ], - "state before terminator:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - } - ] - } - ], - "bb3": [ - [ - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_6)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _2 = const 7_i32" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _4 = const ()" - ] - ], - "state before terminator:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - } - ] - } - ], - "bb4": [ - [ - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32", - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_5)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32", - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_4)" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb2[1]: _2 = const 5_i32", - "bb3[1]: _2 = const 7_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _2 = const 25_i32" - ], - [ - "state:", - { - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb4[2]: _2 = const 25_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "_0": [ - "bb4[3]: _0 = const ()" - ], - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb4[2]: _2 = const 25_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "_0": [ - "bb4[3]: _0 = const ()" - ], - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb4[2]: _2 = const 25_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "_0": [ - "bb4[3]: _0 = const ()" - ], - "_1": [ - "bb1[0]: _1 = move _3" - ], - "_2": [ - "bb4[2]: _2 = const 25_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ], - "_4": [ - "bb2[2]: _4 = const ()", - "bb3[2]: _4 = const ()" - ], - "_5": [ - "bb1[6]: _5 = Gt(move _6, const 2_i32)" - ], - "_6": [ - "bb1[5]: _6 = _1" - ] - }, - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - { - "_1": [ - "bb0[1]: _1 = const 1_i32" - ], - "_2": [ - "bb0[4]: _2 = const 3_i32" - ], - "_3": [ - "bb0[7]: _3 = input() -> [return: bb1, unwind: bb5]" - ] - }, - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.rs b/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.rs deleted file mode 100644 index a3771f91..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[analyzer::run] -fn main() { - let x = 123; - let y: u32; - y = x; -} diff --git a/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.stdout b/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.stdout deleted file mode 100644 index 7640ff9b..00000000 --- a/rr_frontend/analysis/tests/test_cases/reaching_definitions/very_simple_assignment.stdout +++ /dev/null @@ -1,149 +0,0 @@ -Analyzing file $DIR/very_simple_assignment.rs using ReachingDefsAnalysis... -Result for function main(): -{ - "bb0": [ - [ - [ - "state:", - {}, - "statement: StorageLive(_1)" - ], - [ - "state:", - {}, - "statement: _1 = const 123_u32" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ] - }, - "statement: FakeRead(ForLet(None), _1)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ] - }, - "statement: StorageLive(_2)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ] - }, - "statement: StorageLive(_3)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ] - }, - "statement: _3 = _1" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "statement: _2 = move _3" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_2": [ - "bb0[6]: _2 = move _3" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "statement: StorageDead(_3)" - ], - [ - "state:", - { - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_2": [ - "bb0[6]: _2 = move _3" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "statement: _0 = const ()" - ], - [ - "state:", - { - "_0": [ - "bb0[8]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_2": [ - "bb0[6]: _2 = move _3" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "statement: StorageDead(_2)" - ], - [ - "state:", - { - "_0": [ - "bb0[8]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_2": [ - "bb0[6]: _2 = move _3" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "statement: StorageDead(_1)" - ] - ], - "state before terminator:", - { - "_0": [ - "bb0[8]: _0 = const ()" - ], - "_1": [ - "bb0[1]: _1 = const 123_u32" - ], - "_2": [ - "bb0[6]: _2 = move _3" - ], - "_3": [ - "bb0[5]: _3 = _1" - ] - }, - "terminator: return", - {} - ] -} diff --git a/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.rs b/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.rs deleted file mode 100644 index e70e687a..00000000 --- a/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn main() { - let a = abs(-1); - let b = abs(1); - println!("{}", a + b); -} - -#[analyzer::run] -fn abs(x: i32) -> i32 { - let res: i32; - if x >= 0 { - res = x; - } else { - res = -x; - } - return res; -} diff --git a/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.stdout b/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.stdout deleted file mode 100644 index 3aee1e2d..00000000 --- a/rr_frontend/analysis/tests/test_cases/relaxed_definitely_initialized/abs.stdout +++ /dev/null @@ -1,323 +0,0 @@ -Analyzing file $DIR/abs.rs using RelaxedDefinitelyInitializedAnalysis... -Result for function abs(): -{ - "bb0": [ - [ - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_3)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_4)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_5)" - ], - [ - "state:", - [ - "_1" - ], - "statement: StorageLive(_6)" - ], - [ - "state:", - [ - "_1" - ], - "statement: _6 = _1" - ], - [ - "state:", - [ - "_1", - "_6" - ], - "statement: _5 = Ge(move _6, const 0_i32)" - ] - ], - "state before terminator:", - [ - "_1", - "_5", - "_6" - ], - "terminator: switchInt(move _5) -> [0: bb2, otherwise: bb1]", - { - "bb1": [ - "state:", - [ - "_1", - "_5", - "_6" - ] - ], - "bb2": [ - "state:", - [ - "_1", - "_5", - "_6" - ] - ] - } - ], - "bb1": [ - [ - [ - "state:", - [ - "_1", - "_5", - "_6" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1", - "_5" - ], - "statement: StorageLive(_7)" - ], - [ - "state:", - [ - "_1", - "_5" - ], - "statement: _7 = _1" - ], - [ - "state:", - [ - "_1", - "_5", - "_7" - ], - "statement: _3 = move _7" - ], - [ - "state:", - [ - "_1", - "_3", - "_5", - "_7" - ], - "statement: StorageDead(_7)" - ], - [ - "state:", - [ - "_1", - "_3", - "_5" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_3", - "_4", - "_5" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_3", - "_4", - "_5" - ] - ] - } - ], - "bb2": [ - [ - [ - "state:", - [ - "_1", - "_5", - "_6" - ], - "statement: StorageDead(_6)" - ], - [ - "state:", - [ - "_1", - "_5" - ], - "statement: StorageLive(_8)" - ], - [ - "state:", - [ - "_1", - "_5" - ], - "statement: _8 = _1" - ], - [ - "state:", - [ - "_1", - "_5", - "_8" - ], - "statement: _9 = Eq(_8, const i32::MIN)" - ] - ], - "state before terminator:", - [ - "_1", - "_5", - "_8", - "_9" - ], - "terminator: assert(!move _9, /"attempt to negate `{}`, which would overflow/", _8) -> [success: bb3, unwind: bb5]", - { - "bb3": [ - "state:", - [ - "_1", - "_5", - "_8", - "_9" - ] - ], - "bb5": [ - "state:", - [] - ] - } - ], - "bb3": [ - [ - [ - "state:", - [ - "_1", - "_5", - "_8", - "_9" - ], - "statement: _3 = Neg(move _8)" - ], - [ - "state:", - [ - "_1", - "_3", - "_5", - "_8", - "_9" - ], - "statement: StorageDead(_8)" - ], - [ - "state:", - [ - "_1", - "_3", - "_5", - "_9" - ], - "statement: _4 = const ()" - ] - ], - "state before terminator:", - [ - "_1", - "_3", - "_4", - "_5", - "_9" - ], - "terminator: goto -> bb4", - { - "bb4": [ - "state:", - [ - "_1", - "_3", - "_4", - "_5", - "_9" - ] - ] - } - ], - "bb4": [ - [ - [ - "state:", - [ - "_1", - "_3", - "_4", - "_5" - ], - "statement: StorageDead(_5)" - ], - [ - "state:", - [ - "_1", - "_3", - "_4" - ], - "statement: StorageDead(_4)" - ], - [ - "state:", - [ - "_1", - "_3" - ], - "statement: _0 = _3" - ], - [ - "state:", - [ - "_0", - "_1", - "_3" - ], - "statement: StorageDead(_3)" - ] - ], - "state before terminator:", - [ - "_0", - "_1" - ], - "terminator: return", - {} - ], - "bb5": [ - [], - "state before terminator:", - [], - "terminator: resume", - {} - ] -} diff --git a/rr_frontend/analysis/tests/utils.rs b/rr_frontend/analysis/tests/utils.rs deleted file mode 100644 index bf664be9..00000000 --- a/rr_frontend/analysis/tests/utils.rs +++ /dev/null @@ -1,20 +0,0 @@ -#[allow(clippy::option_env_unwrap)] -pub fn find_sysroot() -> String { - // Taken from https://github.com/Manishearth/rust-clippy/pull/911. - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - - match (home, toolchain) { - (Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain), - _ => option_env!("RUST_SYSROOT") - .or_else(|| { - option_env!("RUST_SRC_PATH") - .map(|s| s.strip_suffix("lib/rustlib/rustc-src/rust/compiler/rustc_driver/Cargo.toml")) - .flatten() - }) - .expect( - "Need to specify RUST_SYSROOT or RUST_SRC_PATH environment variables, or use rustup or multirust", - ) - .to_owned(), - } -} diff --git a/rr_frontend/translation/Cargo.toml b/rr_frontend/translation/Cargo.toml index a63cd4c6..eb3347a9 100644 --- a/rr_frontend/translation/Cargo.toml +++ b/rr_frontend/translation/Cargo.toml @@ -8,12 +8,12 @@ repository.workspace = true version.workspace = true [dependencies] -analysis.workspace = true attribute_parse.workspace = true radium.workspace = true rr_rustc_interface.workspace = true rrconfig.workspace = true +analysis.workspace = true csv.workspace = true datafrog.workspace = true lazy_static.workspace = true -- GitLab