diff --git a/Cargo.lock b/Cargo.lock index d2e0aa2d..3ae54795 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "camino" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" dependencies = [ "serde", ] @@ -561,7 +561,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mirai" -version = "1.1.3" +version = "1.1.4" dependencies = [ "bincode", "cargo_metadata", diff --git a/annotations/Cargo.toml b/annotations/Cargo.toml index 5e703873..76a6b644 100644 --- a/annotations/Cargo.toml +++ b/annotations/Cargo.toml @@ -2,7 +2,7 @@ name = "mirai-annotations" version = "1.12.0" -authors = ["Herman Venter "] +authors = ["Herman Venter "] description = "Macros that provide source code annotations for MIRAI" repository = "https://github.com/facebookexperimental/MIRAI" readme = "README.md" diff --git a/binaries/summary_store.tar b/binaries/summary_store.tar index 30078a95..b82eb482 100644 Binary files a/binaries/summary_store.tar and b/binaries/summary_store.tar differ diff --git a/checker/Cargo.toml b/checker/Cargo.toml index c2a17fda..da7fa43a 100644 --- a/checker/Cargo.toml +++ b/checker/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "mirai" -version = "1.1.3" -authors = ["Herman Venter "] +version = "1.1.4" +authors = ["Herman Venter "] description = "A static analysis tool for Rust, based on Abstract Interpretation of MIR" repository = "https://github.com/facebookexperimental/MIRAI" readme = "../README.md" diff --git a/checker/src/call_graph.rs b/checker/src/call_graph.rs index 3a75a6a8..1748e8c1 100644 --- a/checker/src/call_graph.rs +++ b/checker/src/call_graph.rs @@ -1440,7 +1440,7 @@ impl CallSiteOutput { Entry::Vacant(v) => { v.insert(index); let tcx = call_graph.tcx; - let name = crate::utils::summary_key_str(tcx, callable).to_string(); + let name = crate::utils::def_id_as_qualified_name_str(tcx, callable).to_string(); let local = !call_graph.non_local_defs.contains(&callable); let span = tcx.def_span(callable); let source_map = tcx.sess.source_map(); diff --git a/checker/tests/call_graph/fnptr.rs b/checker/tests/call_graph/fnptr.rs index 1b1e81c8..af908440 100644 --- a/checker/tests/call_graph/fnptr.rs +++ b/checker/tests/call_graph/fnptr.rs @@ -69,25 +69,25 @@ commit; ], "callables": [ { - "name": "fnptr.fn1", + "name": "/fnptr/fn1(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "fnptr.fn2", + "name": "/fnptr/fn2(u32)->u32", "file_index": 0, "first_line": 12, "local": true }, { - "name": "fnptr.fn3", + "name": "/fnptr/fn3(u32)->u32", "file_index": 0, "first_line": 15, "local": true }, { - "name": "fnptr.main", + "name": "/fnptr/main()->()", "file_index": 0, "first_line": 18, "local": true diff --git a/checker/tests/call_graph/fnptr_clean.rs b/checker/tests/call_graph/fnptr_clean.rs index e20ac45b..467c2738 100644 --- a/checker/tests/call_graph/fnptr_clean.rs +++ b/checker/tests/call_graph/fnptr_clean.rs @@ -74,25 +74,25 @@ commit; ], "callables": [ { - "name": "fnptr_clean.fn1", + "name": "/fnptr_clean/fn1(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 14, "local": true }, { - "name": "fnptr_clean.fn2", + "name": "/fnptr_clean/fn2(u32)->u32", "file_index": 0, "first_line": 17, "local": true }, { - "name": "fnptr_clean.fn3", + "name": "/fnptr_clean/fn3(u32)->u32", "file_index": 0, "first_line": 20, "local": true }, { - "name": "fnptr_clean.main", + "name": "/fnptr_clean/main()->()", "file_index": 0, "first_line": 23, "local": true diff --git a/checker/tests/call_graph/fnptr_deduplicate.rs b/checker/tests/call_graph/fnptr_deduplicate.rs index 9837b4ab..5188ca06 100644 --- a/checker/tests/call_graph/fnptr_deduplicate.rs +++ b/checker/tests/call_graph/fnptr_deduplicate.rs @@ -66,25 +66,25 @@ commit; ], "callables": [ { - "name": "fnptr_deduplicate.fn1", + "name": "/fnptr_deduplicate/fn1(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "fnptr_deduplicate.fn2", + "name": "/fnptr_deduplicate/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "fnptr_deduplicate.fn3", + "name": "/fnptr_deduplicate/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "fnptr_deduplicate.main", + "name": "/fnptr_deduplicate/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/fnptr_dom.rs b/checker/tests/call_graph/fnptr_dom.rs index 685c4384..1202cf4a 100644 --- a/checker/tests/call_graph/fnptr_dom.rs +++ b/checker/tests/call_graph/fnptr_dom.rs @@ -71,25 +71,25 @@ commit; ], "callables": [ { - "name": "fnptr_dom.fn1", + "name": "/fnptr_dom/fn1(u32,&fn(u32) -> u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "fnptr_dom.fn2", + "name": "/fnptr_dom/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "fnptr_dom.fn3", + "name": "/fnptr_dom/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "fnptr_dom.main", + "name": "/fnptr_dom/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/fnptr_dom_loop.rs b/checker/tests/call_graph/fnptr_dom_loop.rs index ba80387c..f89c5f56 100644 --- a/checker/tests/call_graph/fnptr_dom_loop.rs +++ b/checker/tests/call_graph/fnptr_dom_loop.rs @@ -85,31 +85,31 @@ commit; ], "callables": [ { - "name": "fnptr_dom_loop.fn1", + "name": "/fnptr_dom_loop/fn1(u32,&fn(u32) -> u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "fnptr_dom_loop.fn2", + "name": "/fnptr_dom_loop/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "fnptr_dom_loop.fn3", + "name": "/fnptr_dom_loop/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "fnptr_dom_loop.fn4", + "name": "/fnptr_dom_loop/fn4(u32)->u32", "file_index": 0, "first_line": 19, "local": true }, { - "name": "fnptr_dom_loop.main", + "name": "/fnptr_dom_loop/main()->()", "file_index": 0, "first_line": 26, "local": true diff --git a/checker/tests/call_graph/fnptr_dom_loop_souffle.rs b/checker/tests/call_graph/fnptr_dom_loop_souffle.rs index f6e02d14..5f772e45 100644 --- a/checker/tests/call_graph/fnptr_dom_loop_souffle.rs +++ b/checker/tests/call_graph/fnptr_dom_loop_souffle.rs @@ -82,31 +82,31 @@ digraph { ], "callables": [ { - "name": "fnptr_dom_loop_souffle.fn1", + "name": "/fnptr_dom_loop_souffle/fn1(u32,&fn(u32) -> u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "fnptr_dom_loop_souffle.fn2", + "name": "/fnptr_dom_loop_souffle/fn2(u32)->u32", "file_index": 0, "first_line": 14, "local": true }, { - "name": "fnptr_dom_loop_souffle.fn3", + "name": "/fnptr_dom_loop_souffle/fn3(u32)->u32", "file_index": 0, "first_line": 17, "local": true }, { - "name": "fnptr_dom_loop_souffle.fn4", + "name": "/fnptr_dom_loop_souffle/fn4(u32)->u32", "file_index": 0, "first_line": 20, "local": true }, { - "name": "fnptr_dom_loop_souffle.main", + "name": "/fnptr_dom_loop_souffle/main()->()", "file_index": 0, "first_line": 27, "local": true diff --git a/checker/tests/call_graph/fnptr_fold.rs b/checker/tests/call_graph/fnptr_fold.rs index 1be507a5..84d42dd7 100644 --- a/checker/tests/call_graph/fnptr_fold.rs +++ b/checker/tests/call_graph/fnptr_fold.rs @@ -73,37 +73,37 @@ commit; ], "callables": [ { - "name": "fnptr_fold.fn1", + "name": "/fnptr_fold/fn1(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "fnptr_fold.fn2", + "name": "/fnptr_fold/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "fnptr_fold.fn3", + "name": "/fnptr_fold/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "fnptr_fold.main", + "name": "/fnptr_fold/main()->()", "file_index": 0, "first_line": 20, "local": true }, { - "name": "std.io.stdio._print", + "name": "/std/std::io::_print(std::fmt::Arguments<'_>)->()", "file_index": 1, "first_line": 1073, "local": false }, { - "name": "core.fmt.implement_core_fmt_Arguments.new_v1", + "name": "/core/std::fmt::Arguments::<'a>::new_v1(&'a [&'static str],&'a [std::fmt::ArgumentV1<'a>])->std::fmt::Arguments<'a>", "file_index": 2, "first_line": 394, "local": true diff --git a/checker/tests/call_graph/fnptr_loop.rs b/checker/tests/call_graph/fnptr_loop.rs index 3bca2f25..17c02dec 100644 --- a/checker/tests/call_graph/fnptr_loop.rs +++ b/checker/tests/call_graph/fnptr_loop.rs @@ -76,25 +76,25 @@ commit; ], "callables": [ { - "name": "fnptr_loop.fn1", + "name": "/fnptr_loop/fn1(u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "fnptr_loop.fn2", + "name": "/fnptr_loop/fn2(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 12, "local": true }, { - "name": "fnptr_loop.fn3", + "name": "/fnptr_loop/fn3(u32)->u32", "file_index": 0, "first_line": 15, "local": true }, { - "name": "fnptr_loop.main", + "name": "/fnptr_loop/main()->()", "file_index": 0, "first_line": 22, "local": true diff --git a/checker/tests/call_graph/fnptr_slice.rs b/checker/tests/call_graph/fnptr_slice.rs index 306e2970..108595b6 100644 --- a/checker/tests/call_graph/fnptr_slice.rs +++ b/checker/tests/call_graph/fnptr_slice.rs @@ -62,25 +62,25 @@ commit; ], "callables": [ { - "name": "fnptr_slice.fn1", + "name": "/fnptr_slice/fn1(u32,&fn(u32) -> u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "fnptr_slice.fn2", + "name": "/fnptr_slice/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "fnptr_slice.fn3", + "name": "/fnptr_slice/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "fnptr_slice.main", + "name": "/fnptr_slice/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/generic.rs b/checker/tests/call_graph/generic.rs new file mode 100644 index 00000000..343dfecc --- /dev/null +++ b/checker/tests/call_graph/generic.rs @@ -0,0 +1,107 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// + +pub struct Gen { + pub t: T, +} + +impl Gen { + pub fn foo(_x: U) {} + + pub fn bar(&self, _x: T) {} +} + +pub fn main() { + let g = Gen:: { t: 1u8 }; + g.bar(2u8); + Gen::::foo::<&str>("bar"); +} + +/* CONFIG +{ + "reductions": [], + "included_crates": [], + "datalog_config": { + "datalog_backend": "DifferentialDatalog" + } +} +*/ + +/* EXPECTED:DOT +digraph { + 0 [ label = "\"generic::main\"" ] + 1 [ label = "\"generic::{impl#0}::bar\"" ] + 2 [ label = "\"generic::{impl#0}::foo\"" ] + 0 -> 1 [ ] + 0 -> 1 [ ] + 0 -> 2 [ ] +} +*/ + +/* EXPECTED:DDLOG +start; +insert Dom(1,2); +insert Edge(0,0,1); +insert Edge(1,0,1); +insert Edge(2,0,2); +insert EdgeType(0,0); +insert EdgeType(1,1); +insert EdgeType(2,2); +commit; +*/ + +/* EXPECTED:TYPEMAP +{ + "0": "&Gen", + "1": "u8", + "2": "&str" +} + +*/ + +/* EXPECTED:CALL_SITES +{ + "files": [ + "tests/call_graph/generic.rs" + ], + "callables": [ + { + "name": "/generic/main()->()", + "file_index": 0, + "first_line": 17, + "local": true + }, + { + "name": "/generic/Gen::::bar(&Gen,T)->()", + "file_index": 0, + "first_line": 14, + "local": true + }, + { + "name": "/generic/Gen::::foo(U)->()", + "file_index": 0, + "first_line": 12, + "local": true + } + ], + "calls": [ + [ + 0, + 19, + 5, + 0, + 1 + ], + [ + 0, + 20, + 5, + 0, + 2 + ] + ] +} +*/ diff --git a/checker/tests/call_graph/replace_croot.rs b/checker/tests/call_graph/replace_croot.rs index 4a7f8038..6cde6e55 100644 --- a/checker/tests/call_graph/replace_croot.rs +++ b/checker/tests/call_graph/replace_croot.rs @@ -52,13 +52,13 @@ commit; ], "callables": [ { - "name": "replace_croot.main", + "name": "/replace_croot/main()->()", "file_index": 0, "first_line": 10, "local": true }, { - "name": "replace_croot.fn1", + "name": "/replace_croot/fn1()->u32", "file_index": 0, "first_line": 14, "local": true diff --git a/checker/tests/call_graph/static.rs b/checker/tests/call_graph/static.rs index 018788c5..dc4c5f1b 100644 --- a/checker/tests/call_graph/static.rs +++ b/checker/tests/call_graph/static.rs @@ -65,25 +65,25 @@ commit; ], "callables": [ { - "name": "static.fn1", + "name": "/static/fn1(u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "static.fn2", + "name": "/static/fn2(u32)->u32", "file_index": 0, "first_line": 12, "local": true }, { - "name": "static.fn3", + "name": "/static/fn3(u32)->u32", "file_index": 0, "first_line": 15, "local": true }, { - "name": "static.main", + "name": "/static/main()->()", "file_index": 0, "first_line": 18, "local": true diff --git a/checker/tests/call_graph/static_clean.rs b/checker/tests/call_graph/static_clean.rs index d194f65a..5c45c0a0 100644 --- a/checker/tests/call_graph/static_clean.rs +++ b/checker/tests/call_graph/static_clean.rs @@ -70,25 +70,25 @@ commit; ], "callables": [ { - "name": "static_clean.fn1", + "name": "/static_clean/fn1(u32)->u32", "file_index": 0, "first_line": 14, "local": true }, { - "name": "static_clean.fn2", + "name": "/static_clean/fn2(u32)->u32", "file_index": 0, "first_line": 17, "local": true }, { - "name": "static_clean.fn3", + "name": "/static_clean/fn3(u32)->u32", "file_index": 0, "first_line": 20, "local": true }, { - "name": "static_clean.main", + "name": "/static_clean/main()->()", "file_index": 0, "first_line": 23, "local": true diff --git a/checker/tests/call_graph/static_deduplicate.rs b/checker/tests/call_graph/static_deduplicate.rs index c0896666..d323758e 100644 --- a/checker/tests/call_graph/static_deduplicate.rs +++ b/checker/tests/call_graph/static_deduplicate.rs @@ -66,25 +66,25 @@ commit; ], "callables": [ { - "name": "static_deduplicate.fn1", + "name": "/static_deduplicate/fn1(u32,&str)->(u32, &str)", "file_index": 0, "first_line": 10, "local": true }, { - "name": "static_deduplicate.fn2", + "name": "/static_deduplicate/fn2(u32,&str)->(u32, &str)", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_deduplicate.fn3", + "name": "/static_deduplicate/fn3(u32,&str)->(u32, &str)", "file_index": 0, "first_line": 16, "local": true }, { - "name": "static_deduplicate.main", + "name": "/static_deduplicate/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/static_dom.rs b/checker/tests/call_graph/static_dom.rs index d365cc20..927a166f 100644 --- a/checker/tests/call_graph/static_dom.rs +++ b/checker/tests/call_graph/static_dom.rs @@ -70,25 +70,25 @@ commit; ], "callables": [ { - "name": "static_dom.main", + "name": "/static_dom/main()->()", "file_index": 0, "first_line": 18, "local": true }, { - "name": "static_dom.fn1", + "name": "/static_dom/fn1(u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "static_dom.fn2", + "name": "/static_dom/fn2(u32)->u32", "file_index": 0, "first_line": 12, "local": true }, { - "name": "static_dom.fn3", + "name": "/static_dom/fn3(u32)->u32", "file_index": 0, "first_line": 15, "local": true diff --git a/checker/tests/call_graph/static_dom_loop.rs b/checker/tests/call_graph/static_dom_loop.rs index dd707aa2..cfefe41f 100644 --- a/checker/tests/call_graph/static_dom_loop.rs +++ b/checker/tests/call_graph/static_dom_loop.rs @@ -81,31 +81,31 @@ commit; ], "callables": [ { - "name": "static_dom_loop.fn1", + "name": "/static_dom_loop/fn1(u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "static_dom_loop.fn2", + "name": "/static_dom_loop/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_dom_loop.fn3", + "name": "/static_dom_loop/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "static_dom_loop.fn4", + "name": "/static_dom_loop/fn4(u32)->u32", "file_index": 0, "first_line": 19, "local": true }, { - "name": "static_dom_loop.main", + "name": "/static_dom_loop/main()->()", "file_index": 0, "first_line": 26, "local": true diff --git a/checker/tests/call_graph/static_fold.rs b/checker/tests/call_graph/static_fold.rs index efbffb2c..c4f70cb2 100644 --- a/checker/tests/call_graph/static_fold.rs +++ b/checker/tests/call_graph/static_fold.rs @@ -69,37 +69,37 @@ commit; ], "callables": [ { - "name": "static_fold.fn1", + "name": "/static_fold/fn1(u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "static_fold.fn2", + "name": "/static_fold/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_fold.fn3", + "name": "/static_fold/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "static_fold.main", + "name": "/static_fold/main()->()", "file_index": 0, "first_line": 20, "local": true }, { - "name": "std.io.stdio._print", + "name": "/std/std::io::_print(std::fmt::Arguments<'_>)->()", "file_index": 1, "first_line": 1073, "local": false }, { - "name": "core.fmt.implement_core_fmt_Arguments.new_v1", + "name": "/core/std::fmt::Arguments::<'a>::new_v1(&'a [&'static str],&'a [std::fmt::ArgumentV1<'a>])->std::fmt::Arguments<'a>", "file_index": 2, "first_line": 394, "local": false diff --git a/checker/tests/call_graph/static_loop.rs b/checker/tests/call_graph/static_loop.rs index 076927db..856e8aeb 100644 --- a/checker/tests/call_graph/static_loop.rs +++ b/checker/tests/call_graph/static_loop.rs @@ -72,25 +72,25 @@ commit; ], "callables": [ { - "name": "static_loop.fn1", + "name": "/static_loop/fn1(u32)->u32", "file_index": 0, "first_line": 9, "local": true }, { - "name": "static_loop.fn2", + "name": "/static_loop/fn2(u32)->u32", "file_index": 0, "first_line": 12, "local": true }, { - "name": "static_loop.fn3", + "name": "/static_loop/fn3(u32)->u32", "file_index": 0, "first_line": 15, "local": true }, { - "name": "static_loop.main", + "name": "/static_loop/main()->()", "file_index": 0, "first_line": 22, "local": true diff --git a/checker/tests/call_graph/static_no_args.rs b/checker/tests/call_graph/static_no_args.rs index 2ea5f3dc..b7dbf102 100644 --- a/checker/tests/call_graph/static_no_args.rs +++ b/checker/tests/call_graph/static_no_args.rs @@ -51,13 +51,13 @@ commit; ], "callables": [ { - "name": "static_no_args.main", + "name": "/static_no_args/main()->()", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_no_args.fn1", + "name": "/static_no_args/fn1()->u32", "file_index": 0, "first_line": 10, "local": true diff --git a/checker/tests/call_graph/static_slice.rs b/checker/tests/call_graph/static_slice.rs index f9cd6020..3c099310 100644 --- a/checker/tests/call_graph/static_slice.rs +++ b/checker/tests/call_graph/static_slice.rs @@ -62,25 +62,25 @@ commit; ], "callables": [ { - "name": "static_slice.fn1", + "name": "/static_slice/fn1(u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "static_slice.fn2", + "name": "/static_slice/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_slice.fn3", + "name": "/static_slice/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "static_slice.main", + "name": "/static_slice/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/static_souffle.rs b/checker/tests/call_graph/static_souffle.rs index 25f1d243..c7530bc4 100644 --- a/checker/tests/call_graph/static_souffle.rs +++ b/checker/tests/call_graph/static_souffle.rs @@ -63,25 +63,25 @@ digraph { ], "callables": [ { - "name": "static_souffle.fn1", + "name": "/static_souffle/fn1(u32)->u32", "file_index": 0, "first_line": 10, "local": true }, { - "name": "static_souffle.fn2", + "name": "/static_souffle/fn2(u32)->u32", "file_index": 0, "first_line": 13, "local": true }, { - "name": "static_souffle.fn3", + "name": "/static_souffle/fn3(u32)->u32", "file_index": 0, "first_line": 16, "local": true }, { - "name": "static_souffle.main", + "name": "/static_souffle/main()->()", "file_index": 0, "first_line": 19, "local": true diff --git a/checker/tests/call_graph/trait.rs b/checker/tests/call_graph/trait.rs new file mode 100644 index 00000000..d45b347d --- /dev/null +++ b/checker/tests/call_graph/trait.rs @@ -0,0 +1,94 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// + +pub trait Tr { + fn bar(&self) -> i32; +} + +struct Bar {} + +impl Tr for Bar { + fn bar(&self) -> i32 { + 1 + } +} + +struct BarTwo {} + +impl Tr for BarTwo { + fn bar(&self) -> i32 { + 2 + } +} + +pub fn main() { + let bar = Bar {}; + let _ = bar.bar(); +} + +/* CONFIG +{ + "reductions": [], + "included_crates": [], + "datalog_config": { + "datalog_backend": "DifferentialDatalog" + } +} +*/ + +/* EXPECTED:DOT +digraph { + 0 [ label = "\"trait::{impl#0}::bar\"" ] + 1 [ label = "\"trait::{impl#1}::bar\"" ] + 2 [ label = "\"trait::main\"" ] + 2 -> 0 [ ] +} +*/ + +/* EXPECTED:DDLOG +start; +insert Edge(0,2,0); +insert EdgeType(0,0); +commit; +*/ + +/* EXPECTED:TYPEMAP +{ + "0": "&Bar" +} +*/ + +/* EXPECTED:CALL_SITES +{ + "files": [ + "tests/call_graph/trait.rs" + ], + "callables": [ + { + "name": "/trait/main()->()", + "file_index": 0, + "first_line": 27, + "local": true + }, + { + "name": "/trait/::bar(&Bar)->i32", + "file_index": 0, + "first_line": 14, + "local": true + } + ], + "calls": [ + [ + 0, + 29, + 13, + 0, + 1 + ] + ] +} + +*/ diff --git a/checker/tests/call_graph/type_relations.rs_disabled b/checker/tests/call_graph/type_relations.rs_disabled index 8ff85649..1f0efbfb 100644 --- a/checker/tests/call_graph/type_relations.rs_disabled +++ b/checker/tests/call_graph/type_relations.rs_disabled @@ -138,187 +138,187 @@ commit;*/ ], "callables": [ { - "name": "type_relations.implement_type_relations_Foo.fmt", + "name": "/type_relations/::fmt(&Foo,&mut std::fmt::Formatter<'_>)->std::result::Result<(), std::fmt::Error>", "file_index": 0, "first_line": 8, "local": true }, { - "name": "core.fmt.implement_core_fmt_Formatter.debug_struct_field1_finish", + "name": "/core/std::fmt::Formatter::<'a>::debug_struct_field1_finish(&'b mut std::fmt::Formatter<'a>,&str,&str,&dyn std::fmt::Debug)->std::result::Result<(), std::fmt::Error>", "file_index": 1, "first_line": 1983, "local": false }, { - "name": "type_relations.foo_ref", + "name": "/type_relations/foo_ref(&Foo)->()", "file_index": 0, "first_line": 13, "local": true }, { - "name": "core.fmt.implement_core_fmt_ArgumentV1.new_display", + "name": "/core/std::fmt::ArgumentV1::<'a>::new_display(&'b T)->std::fmt::ArgumentV1<'b>", "file_index": 1, "first_line": 322, "local": true }, { - "name": "type_relations.foo_mut_ref", + "name": "/type_relations/foo_mut_ref(&mut Foo)->()", "file_index": 0, "first_line": 17, "local": true }, { - "name": "type_relations.foo_slice_iter", + "name": "/type_relations/foo_slice_iter(&[Foo])->()", "file_index": 0, "first_line": 22, "local": true }, { - "name": "core.slice.implement_slice_generic_par_T.iter", + "name": "/core/core::slice::::iter(&[T])->std::slice::Iter<'_, T>", "file_index": 2, "first_line": 735, "local": true }, { - "name": "core.slice.iter.implement_core_slice_iter_Iter_generic_par_T.next", + "name": "/core/ as std::iter::Iterator>::next(&mut std::slice::Iter<'a, T>)->std::option::Option<&'a T>", "file_index": 3, "first_line": 134, "local": true }, { - "name": "type_relations.foo_vec_iter", + "name": "/type_relations/foo_vec_iter(std::vec::Vec)->()", "file_index": 0, "first_line": 28, "local": true }, { - "name": "alloc.vec.implement_alloc_vec_Vec_generic_par_T_generic_par_A.drop", + "name": "/alloc/ as std::ops::Drop>::drop(&mut std::vec::Vec)->()", "file_index": 4, "first_line": 3048, "local": true }, { - "name": "type_relations.main", + "name": "/type_relations/main()->()", "file_index": 0, "first_line": 34, "local": true }, { - "name": "alloc.vec.implement_alloc_vec_Vec_generic_par_T_generic_par_A.deref", + "name": "/alloc/ as std::ops::Deref>::deref(&std::vec::Vec)->&[T]", "file_index": 4, "first_line": 2630, "local": true }, { - "name": "std.io.stdio._print", + "name": "/std/std::io::_print(std::fmt::Arguments<'_>)->()", "file_index": 5, "first_line": 1074, "local": false }, { - "name": "core.fmt.implement_core_fmt_Arguments.new_v1", + "name": "/core/std::fmt::Arguments::<'a>::new_v1(&'a [&'static str],&'a [std::fmt::ArgumentV1<'a>])->std::fmt::Arguments<'a>", "file_index": 1, "first_line": 394, "local": false }, { - "name": "alloc.boxed.implement_alloc_boxed_Box_generic_par_T_generic_par_A.into_raw_with_allocator", + "name": "/alloc/std::boxed::Box::::into_raw_with_allocator(std::boxed::Box)->(*mut T, A)", "file_index": 6, "first_line": 1112, "local": true }, { - "name": "alloc.boxed.implement_alloc_boxed_Box_generic_par_T_generic_par_A.into_unique", + "name": "/alloc/std::boxed::Box::::into_unique(std::boxed::Box)->(std::ptr::Unique, A)", "file_index": 6, "first_line": 1125, "local": true }, { - "name": "alloc.boxed.implement_alloc_boxed_Box_generic_par_T_generic_par_A.leak", + "name": "/alloc/std::boxed::Box::::leak(std::boxed::Box)->&'a mut T", "file_index": 6, "first_line": 1185, "local": true }, { - "name": "alloc.boxed.implement_alloc_boxed_Box_generic_par_T_generic_par_A.drop", + "name": "/alloc/ as std::ops::Drop>::drop(&mut std::boxed::Box)->()", "file_index": 6, "first_line": 1237, "local": true }, { - "name": "core.ptr.mut_ptr.implement_pointer_mut_generic_par_T.is_null", + "name": "/core/std::ptr::mut_ptr::::is_null(*mut T)->bool", "file_index": 7, "first_line": 35, "local": true }, { - "name": "core.ptr.drop_in_place", + "name": "/core/std::ptr::drop_in_place(*mut T)->()", "file_index": 8, "first_line": 490, "local": true }, { - "name": "alloc.slice.implement_slice_generic_par_T.into_vec", + "name": "/alloc/std::slice::::into_vec(std::boxed::Box<[T], A>)->std::vec::Vec", "file_index": 9, "first_line": 456, "local": true }, { - "name": "alloc.alloc.exchange_malloc", + "name": "/alloc/alloc::alloc::exchange_malloc(usize,usize)->*mut u8", "file_index": 10, "first_line": 324, "local": false }, { - "name": "alloc.alloc.implement_alloc_alloc_Global.alloc_impl", + "name": "/alloc/std::alloc::Global::alloc_impl(&std::alloc::Global,std::alloc::Layout,bool)->std::result::Result, std::alloc::AllocError>", "file_index": 10, "first_line": 172, "local": true }, { - "name": "core.ptr.non_null.implement_core_ptr_non_null_NonNull_generic_par_T.new", + "name": "/core/std::ptr::NonNull::::new(*mut T)->std::option::Option>", "file_index": 11, "first_line": 222, "local": true }, { - "name": "core.slice.iter.implement_core_slice_iter_Iter_generic_par_T.new", + "name": "/core/std::slice::Iter::<'a, T>::new(&'a [T])->std::slice::Iter<'a, T>", "file_index": 12, "first_line": 88, "local": true }, { - "name": "alloc.slice.hack.into_vec", + "name": "/alloc/std::slice::hack::into_vec(std::boxed::Box<[T], A>)->std::vec::Vec", "file_index": 9, "first_line": 95, "local": true }, { - "name": "alloc.vec.implement_alloc_vec_Vec_generic_par_T_generic_par_A.from_raw_parts_in", + "name": "/alloc/std::vec::Vec::::from_raw_parts_in(*mut T,usize,usize,A)->std::vec::Vec", "file_index": 4, "first_line": 781, "local": true }, { - "name": "core.ptr.const_ptr.implement_pointer_const_generic_par_T.is_null", + "name": "/core/std::ptr::const_ptr::::is_null(*const T)->bool", "file_index": 13, "first_line": 36, "local": true }, { - "name": "core.ptr.mut_ptr.implement_pointer_mut_generic_par_T.guaranteed_eq", + "name": "/core/std::ptr::mut_ptr::::guaranteed_eq(*mut T,*mut T)->std::option::Option", "file_index": 7, "first_line": 753, "local": true }, { - "name": "core.intrinsics.foreign.ptr_guaranteed_cmp", + "name": "/core/std::intrinsics::ptr_guaranteed_cmp(*const T,*const T)->u8", "file_index": 14, "first_line": 2065, "local": false }, { - "name": "core.intrinsics.foreign.assert_inhabited", + "name": "/core/std::intrinsics::assert_inhabited()->()", "file_index": 14, "first_line": 952, "local": false diff --git a/examples/taint/Cargo.toml b/examples/taint/Cargo.toml index fbbaa18a..be6f0deb 100644 --- a/examples/taint/Cargo.toml +++ b/examples/taint/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "taint" version = "0.1.0" -authors = ["Herman Venter "] +authors = ["Herman Venter "] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/examples/taint/taint_error/Cargo.toml b/examples/taint/taint_error/Cargo.toml index c47e1f7e..b233a51f 100644 --- a/examples/taint/taint_error/Cargo.toml +++ b/examples/taint/taint_error/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "taint-error" version = "0.1.0" -authors = ["Herman Venter "] +authors = ["Herman Venter "] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/standard_contracts/Cargo.toml b/standard_contracts/Cargo.toml index 9d4f362b..0335b130 100644 --- a/standard_contracts/Cargo.toml +++ b/standard_contracts/Cargo.toml @@ -2,7 +2,7 @@ name = "mirai-standard-contracts" version = "0.0.1" -authors = ["Herman Venter "] +authors = ["Herman Venter "] description = "Specifications of standard library functions for MIRAI" repository = "https://github.com/facebookexperimental/MIRAI" readme = "README.md"