Skip to content

[clang-doc] serialize friends #146165

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

Draft
wants to merge 1 commit into
base: users/evelez7/clang-doc-precommit-friends
Choose a base branch
from

Conversation

evelez7
Copy link
Member

@evelez7 evelez7 commented Jun 27, 2025

No description provided.

Copy link
Member Author

evelez7 commented Jun 27, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- clang-tools-extra/clang-doc/BitcodeReader.cpp clang-tools-extra/clang-doc/BitcodeWriter.cpp clang-tools-extra/clang-doc/BitcodeWriter.h clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp clang-tools-extra/clang-doc/JSONGenerator.cpp clang-tools-extra/clang-doc/MDGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/clang-doc/YAMLGenerator.cpp clang-tools-extra/test/clang-doc/json/class.cpp clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
View the diff from clang-format here.
diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index ba53329a4..422a76d99 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -435,7 +435,7 @@ llvm::SmallString<16> Info::extractName() const {
   case InfoType::IT_variable:
     return llvm::SmallString<16>("@nonymous_variable_" +
                                  toHex(llvm::toStringRef(USR)));
-                                 case InfoType::IT_friend:
+  case InfoType::IT_friend:
     return llvm::SmallString<16>("@nonymous_friend_" +
                                  toHex(llvm::toStringRef(USR)));
   case InfoType::IT_default:

@@ -947,6 +952,53 @@ emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc,
return {std::move(NSI), makeAndInsertIntoParent<const NamespaceInfo &>(*NSI)};
}

static void parseFriends(RecordInfo &RI, const CXXRecordDecl *D) {
if (D->hasDefinition() && D->hasFriends())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you invert the condition you can use early return to avoid a level of nesting.

Copy link
Contributor

@ilovepi ilovepi left a comment

Choose a reason for hiding this comment

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

LGTM, modulo formatting and 1 small suggestion.

@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-precommit-friends branch from bf66a99 to 111fe87 Compare June 27, 2025 23:19
@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-friends branch from a373ecb to 8dd16ca Compare June 27, 2025 23:19
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.

2 participants