-
Notifications
You must be signed in to change notification settings - Fork 344
[lldb] Implement TypeSystemSwiftTypeRef::GetNumTemplateArguments #2892
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
[lldb] Implement TypeSystemSwiftTypeRef::GetNumTemplateArguments #2892
Conversation
@swift-ci test |
da826cc
to
5ece8d6
Compare
@swift-ci test |
case Node::Kind::BoundGenericOtherNominalType: | ||
case Node::Kind::BoundGenericTypeAlias: | ||
case Node::Kind::BoundGenericFunction: { | ||
auto child = node->getChild(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure getChild
fails when accessing an index that doesn't exist, so generally we defensively check the number of children before accessing.
also llvm style is to indicate pointers even with auto
declarations, ex auto *child
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question I had about children: can I assume the indexes of the children won't change between different compiler releases? For example, right now TypeList
is always the child at index 1 of these BoundGenericX
nodes, can I assume this will always be true, or should I iterate over the children until I find the first one with kind TypeList
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is ABI and so shouldn't change. I think we assume indexes in some places, and in other places we iterate. I think assuming a known index is fine, but let's see what Adrian says.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (node->getNumChildren() > 1) {
NodePointer child = getChild(1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ordering is ABI, but there are some node types that by design some nodes can have an arbitrary number of children and future extensions might add additional children, I believe.
5ece8d6
to
f2e4194
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. If you can, please also add a unit test to https://github.com/apple/llvm-project/blob/swift/main/lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp.
f2e4194
to
9746edf
Compare
9746edf
to
9df8052
Compare
@swift-ci test |
This follows the same behavior as
SwiftASTContext::GetNumTemplateArguments
, which only returns the number of template arguments of generic types and not generic functions.rdar://68171376