Skip to content

[lldb] Add unittests for SwiftLanguageRuntime demangling functions #9422

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

Conversation

felipepiovezan
Copy link

This should make it easier to make changes and ensure they are correct. For example, as commented in the tests, there are known issues with the async function detection.

switch (node->getFirstChild()->getKind()) {
case Node::Kind::Static:
case Node::Kind::ExplicitClosure:
while (llvm::is_contained({Node::Kind::Static, Node::Kind::ExplicitClosure},

Choose a reason for hiding this comment

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

Is this a quadratic algorithm?

Choose a reason for hiding this comment

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

suggestion: only support nested ExplicitClosure.

as far as I know, there's no case where Static nodes are nested. While there's no harm in supporting nested Static nodes, I'd prefer to see the code match the reality. Purely for expressiveness. I'd rather not have a reader wonder "why does this need to handle nested Static nodes"?

Copy link
Author

@felipepiovezan felipepiovezan Oct 16, 2024

Choose a reason for hiding this comment

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

Is this a quadratic algorithm?

It's linear in the depth of the tree: one node in each level of the tree is compared against two possibilities, i.e. it performs a constant number of operations on each level of the tree.

as far as I know, there's no case where Static nodes are nested.

So is it safe to say that if there is a Static node, it must be at the root of the tree?

Copy link
Author

Choose a reason for hiding this comment

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

Updated the PR with suggestions

@felipepiovezan felipepiovezan force-pushed the felipe/add_unittests_demangler branch 5 times, most recently from e16f58a to dca54e1 Compare October 16, 2024 15:12
This should make it easier to make changes and ensure they are correct.
For example, as commented in the tests, there are known issues with the async
function detection.
@felipepiovezan felipepiovezan force-pushed the felipe/add_unittests_demangler branch from dca54e1 to 3e6402b Compare October 16, 2024 18:04
These produce nested Node objects with the Kind::ExplicitClosure annotation, all
of which must be peeled in order to find the Function node.
@felipepiovezan felipepiovezan force-pushed the felipe/add_unittests_demangler branch from 3e6402b to 4dac4d3 Compare October 16, 2024 22:08
@felipepiovezan
Copy link
Author

Updated wording of a comment

@felipepiovezan felipepiovezan merged commit 44566d7 into swiftlang:stable/20240723 Oct 17, 2024
@felipepiovezan felipepiovezan deleted the felipe/add_unittests_demangler branch October 17, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants