Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: Handle path attributes in path resolution #19216

Merged
merged 3 commits into from
Apr 9, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Apr 4, 2025

This PR adds basic support for taking path attributes into account in path resolution.

DCA shows that, while we maintain performance, we gain an additional 10% true positive call edges (up 522,938 from 475,383) and an additional 6% true positive resolved paths (up 388,991 from 368,369), all numbers computed across the entire DCA suite.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Apr 4, 2025
@hvitved hvitved force-pushed the rust/path-resolution-path-attr branch 3 times, most recently from 4dd7239 to cbf6f94 Compare April 4, 2025 12:46
@hvitved hvitved marked this pull request as ready for review April 6, 2025 11:07
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Apr 6, 2025
@hvitved hvitved force-pushed the rust/path-resolution-path-attr branch from cbf6f94 to 15ac9d3 Compare April 7, 2025 07:28
@hvitved hvitved requested a review from paldepind April 7, 2025 07:29
@hvitved hvitved force-pushed the rust/path-resolution-path-attr branch from 15ac9d3 to 13f4a6a Compare April 7, 2025 13:24
@paldepind paldepind self-assigned this Apr 9, 2025
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍. I've left a few minor comments.

Comment on lines 261 to 264
exists(int components |
components = (-1).maximum(max(int comp | exists(getComponent(relativePath, comp)) | comp)) and
result = appendStep(f, relativePath, components)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two thoughts:

  • Maybe factor out a getNrOfComponents predicate from this? Then this predicate would become just result = appendStep(f, relativePath, getNrOfComponents(relativePath)
  • The comp here is not a component but an index. Maybe rename it to just i?

)
}

private predicate append(Folder f, string relativePath) { pathAttrImport(f, _, relativePath) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had me a bit confused at first as the predicate is called append but doesn't seem to append :)

If I understand correctly this is about limiting the things that are appended by append inside Append in order for it not to append everything in the world?

What about calling it shouldAppend/limitAppend/appendOnly/shouldBeAppended (or something along those lines) and then using the same name for the parameter to the Append module (what is now called app)?

@@ -655,6 +655,11 @@ private predicate fileModule(SourceFile f, string name, Folder folder) {
)
}

private Meta getPathAttrMeta(Module m) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Meta getPathAttrMeta(Module m) {
/**
* Gets the `Meta` of the module `m`'s [path attribute][1].
*
* [1]: https://doc.rust-lang.org/reference/items/modules.html#r-items.mod.outlined.path
*/
private Meta getPathAttrMeta(Module m) {

@hvitved hvitved requested a review from paldepind April 9, 2025 15:19
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks 👍

@hvitved hvitved merged commit 1ba06ab into github:main Apr 9, 2025
39 checks passed
@hvitved hvitved deleted the rust/path-resolution-path-attr branch April 9, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants