-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SymbolGraphGen] synthesize child symbols for type aliases of private decls #78959
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
@swift-ci Please smoke test |
@@ -232,6 +232,18 @@ void SymbolGraph::recordEdge(Symbol Source, | |||
|
|||
void SymbolGraph::recordMemberRelationship(Symbol S) { | |||
const auto *DC = S.getLocalSymbolDecl()->getDeclContext(); | |||
const ValueDecl *ParentDecl = DC->getSelfNominalTypeDecl(); |
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.
Do we also need to support the other kinds of relationships like inheritsFrom
, requirementOf
, etc.?
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 handled the other kinds of relationship that are necessary for type declarations in b7079f4 - this includes inheritsFrom
and conformsTo
, since requirementOf
only applies to method declarations on protocols. Any other relationship kind that applies to the synthesized children will happen as these symbols are processed.
@swift-ci Please smoke test |
Resolves rdar://141460819
Consider the following C code:
When this C code is processed in ClangImporter, it initially sees four top-level Clang decls: two typedefs and their respective underlying struct decls, one anonymous and one named. In
canSkipOverTypedef
, it then folds the underlying type into the typedef decl, creating two final Swift top-level decls.However, when processing this code:
...this folding process fails, instead creating Swift decls for both the typedef and its underlying type.
When these decls are then rendered in SymbolGraphGen, the underlying struct decl is then hidden, due to its underscored name, leaving the converted type alias pointing to nowhere.
This PR adds behavior in SymbolGraphGen to effectively fold these decls together: When a type alias (including a converted Clang typedef) is encountered whose underlying type is (1) from the same module and (2) hidden by the current settings, it will crawl the underlying type and create synthesized symbols to clone its children as children of the type alias.