Skip to content

Commit 95add2f

Browse files
committed
Rust: Fix bad join in getAPrivateVisibleModule
Before ``` Pipeline standard for PathResolution::getAPrivateVisibleModule/1#3829a5ee@822d5hwq was evaluated in 24 iterations totaling 16ms (delta sizes total: 4843). 105047 ~63652% {2} r1 = SCAN `PathResolution::resolvePathPrivate/3#56db2cdf#reorder_1_2_0_3#prev_delta` OUTPUT In.0, In.0 69 ~0% {2} r2 = JOIN `#PathResolution::ItemNode.getImmediateParentModule/0#dispred#57c4c6d5Plus#bf#reorder_1_0#prev_delta` WITH `PathResolution::resolvePathPrivate/3#56db2cdf#reorder_1_2_0_3#prev` ON FIRST 1 OUTPUT Lhs.0, Lhs.1 5766690 ~148309% {2} r3 = JOIN `PathResolution::resolvePathPrivate/3#56db2cdf#reorder_1_2_0_3#prev_delta` WITH `#PathResolution::ItemNode.getImmediateParentModule/0#dispred#57c4c6d5Plus#bf#reorder_1_0#prev` ON FIRST 1 OUTPUT Lhs.0, Rhs.1 5871806 ~143984% {2} r4 = r1 UNION r2 UNION r3 6859 ~148% {2} | AND NOT `PathResolution::getAPrivateVisibleModule/1#3829a5ee#prev`(FIRST 2) return r4 ``` After ``` Pipeline standard for PathResolution::getAPrivateVisibleModule/1#3829a5ee@5edefhwp was evaluated in 12 iterations totaling 0ms (delta sizes total: 3515). 339 ~1% {2} r1 = SCAN `PathResolution::isItemParent/1#d5e587d6#prev_delta` OUTPUT In.0, In.0 3130 ~0% {2} r2 = JOIN `PathResolution::isItemParent/1#d5e587d6#prev_delta` WITH `#PathResolution::ItemNode.getImmediateParentModule/0#dispred#57c4c6d5Plus#bf#reorder_1_0#prev` ON FIRST 1 OUTPUT Lhs.0, Rhs.1 46 ~0% {2} r3 = JOIN `#PathResolution::ItemNode.getImmediateParentModule/0#dispred#57c4c6d5Plus#bf#reorder_1_0#prev_delta` WITH `PathResolution::isItemParent/1#d5e587d6#prev` ON FIRST 1 OUTPUT Lhs.0, Lhs.1 3515 ~2% {2} r4 = r1 UNION r2 UNION r3 3515 ~2% {2} | AND NOT `PathResolution::getAPrivateVisibleModule/1#3829a5ee#prev`(FIRST 2) return r4 ```
1 parent 2e1b8b8 commit 95add2f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/ql/lib/codeql/rust/internal/PathResolution.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ private ItemNode resolvePathPrivate(
981981
)
982982
}
983983

984+
pragma[nomagic]
985+
private predicate isItemParent(ModuleLikeNode itemParent) {
986+
exists(resolvePathPrivate(_, itemParent, _))
987+
}
988+
984989
/**
985990
* Gets a module that has access to private items defined inside `itemParent`.
986991
*
@@ -991,7 +996,7 @@ private ItemNode resolvePathPrivate(
991996
*/
992997
pragma[nomagic]
993998
private ModuleLikeNode getAPrivateVisibleModule(ModuleLikeNode itemParent) {
994-
exists(resolvePathPrivate(_, itemParent, _)) and
999+
isItemParent(itemParent) and
9951000
result.getImmediateParentModule*() = itemParent
9961001
}
9971002

0 commit comments

Comments
 (0)