-
Notifications
You must be signed in to change notification settings - Fork 226
Deal with friends from multiple classes #8037
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1318,6 +1318,45 @@ static std::string GetNavigationId(clang::FunctionDecl const* func) | |
| return navigationId; | ||
| } | ||
|
|
||
| static std::string GetNavigationId( | ||
| clang::FriendDecl const* friendDecl, | ||
| std::string const& parentNodeNavigationId) | ||
| { | ||
| std::string navigationId = parentNodeNavigationId + "_friend_"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the parentNodeNavigationId be ""? Can we assert these premises.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It cannot be empty, I'll add an error message if it is. |
||
| auto dc = friendDecl->getFriendDecl(); | ||
| if (dc) | ||
| { | ||
| if (isa<FunctionDecl>(dc)) | ||
| { | ||
| auto fd = cast<FunctionDecl>(dc); | ||
| navigationId += GetNavigationId(fd); | ||
| } | ||
| else if (isa<CXXRecordDecl>(dc)) | ||
| { | ||
| auto rd = cast<CXXRecordDecl>(dc); | ||
| navigationId += rd->getQualifiedNameAsString(); | ||
| } | ||
| else | ||
| { | ||
| dc->dump(llvm::outs()); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| auto friendType = friendDecl->getFriendType(); | ||
| if (friendType) | ||
| { | ||
| navigationId | ||
| += QualType::getAsString(friendDecl->getFriendType()->getType().split(), LangOptions{}); | ||
| } | ||
| else | ||
| { | ||
| friendDecl->dump(llvm::outs()); | ||
| } | ||
| } | ||
| return navigationId; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you end up in the final else of the initial if/else then you could end up with navigationId being
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All strings are valid, the only restriction is that the names must be unique. |
||
| } | ||
|
|
||
| static std::string GetNavigationId(clang::ParmVarDecl const* param) | ||
| { | ||
|
|
||
|
|
@@ -2690,6 +2729,7 @@ class AstField : public AstNamedNode { | |
|
|
||
| class AstFriend : public AstNode { | ||
| std::string m_friendType; | ||
| std::string m_navigationId; | ||
| std::unique_ptr<AstNode> m_friendFunction; | ||
|
|
||
| public: | ||
|
|
@@ -2727,6 +2767,7 @@ class AstFriend : public AstNode { | |
| { | ||
| if (ShouldIncludeFriendDeclaration(friendDecl)) | ||
| { | ||
| m_navigationId = GetNavigationId(friendDecl, parentNode->NavigationId); | ||
| if (friendDecl->getFriendType()) | ||
| { | ||
| m_friendType | ||
|
|
@@ -2763,7 +2804,7 @@ class AstFriend : public AstNode { | |
| } | ||
| else | ||
| { | ||
| dumper->InsertTypeName(m_friendType, "friend_" + m_friendType); | ||
| dumper->InsertTypeName(m_friendType, m_navigationId); | ||
| if (dumpOptions.NeedsTrailingSemi) | ||
| { | ||
| dumper->InsertPunctuation(';'); | ||
|
|
||
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.
Add function comment