From dff5ed7d295e260d8bc30b5bfac8e9ec6eee58a7 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 3 Sep 2025 09:31:58 +0200 Subject: [PATCH] Rust: Assign locations to all `DataFlowCallable`s --- rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll | 4 +++- .../library-tests/dataflow/global/viableCallable.expected | 4 ++-- .../test/library-tests/dataflow/global/viableCallable.qlref | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 rust/ql/test/library-tests/dataflow/global/viableCallable.qlref diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll index 81dce66ce48..c63d2330ca2 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll @@ -53,7 +53,9 @@ final class DataFlowCallable extends TDataFlowCallable { } /** Gets the location of this callable. */ - Location getLocation() { result = this.asCfgScope().getLocation() } + Location getLocation() { + result = [this.asCfgScope().getLocation(), this.asSummarizedCallable().getLocation()] + } } final class DataFlowCall extends TDataFlowCall { diff --git a/rust/ql/test/library-tests/dataflow/global/viableCallable.expected b/rust/ql/test/library-tests/dataflow/global/viableCallable.expected index aab630af29f..11f670aabff 100644 --- a/rust/ql/test/library-tests/dataflow/global/viableCallable.expected +++ b/rust/ql/test/library-tests/dataflow/global/viableCallable.expected @@ -98,10 +98,10 @@ | main.rs:326:17:326:25 | source(...) | main.rs:1:1:3:1 | fn source | | main.rs:327:9:327:15 | sink(...) | main.rs:5:1:7:1 | fn sink | | main.rs:330:5:330:17 | sink(...) | main.rs:5:1:7:1 | fn sink | -| main.rs:334:13:334:55 | ...::block_on(...) | file://:0:0:0:0 | fn block_on | +| main.rs:334:13:334:55 | ...::block_on(...) | {EXTERNAL LOCATION} | fn block_on | | main.rs:334:41:334:54 | async_source(...) | main.rs:315:1:319:1 | fn async_source | | main.rs:335:5:335:11 | sink(...) | main.rs:5:1:7:1 | fn sink | -| main.rs:337:5:337:62 | ...::block_on(...) | file://:0:0:0:0 | fn block_on | +| main.rs:337:5:337:62 | ...::block_on(...) | {EXTERNAL LOCATION} | fn block_on | | main.rs:337:33:337:61 | test_async_await_async_part(...) | main.rs:321:1:331:1 | fn test_async_await_async_part | | main.rs:341:5:341:22 | data_out_of_call(...) | main.rs:16:1:19:1 | fn data_out_of_call | | main.rs:342:5:342:35 | data_out_of_call_side_effect1(...) | main.rs:35:1:40:1 | fn data_out_of_call_side_effect1 | diff --git a/rust/ql/test/library-tests/dataflow/global/viableCallable.qlref b/rust/ql/test/library-tests/dataflow/global/viableCallable.qlref new file mode 100644 index 00000000000..29d8fc7b11a --- /dev/null +++ b/rust/ql/test/library-tests/dataflow/global/viableCallable.qlref @@ -0,0 +1,2 @@ +query: viableCallable.ql +postprocess: utils/test/ExternalLocationPostProcessing.ql \ No newline at end of file