-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang-doc] Serialize private members in JSON #171700
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
Merged
Merged
+143
−5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Dec 10, 2025
40a7689 to
a0298a6
Compare
6195426 to
5a303b8
Compare
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
Member
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesFull diff: https://github.com/llvm/llvm-project/pull/171700.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index c65c3dc759c3e..c47c65ddc2d73 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -545,6 +545,8 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
json::Array &PubMembersArrayRef = *PublicMembersArray.getAsArray();
json::Value ProtectedMembersArray = Array();
json::Array &ProtMembersArrayRef = *ProtectedMembersArray.getAsArray();
+ json::Value PrivateMembersArray = Array();
+ json::Array &PrivateMembersArrayRef = *PrivateMembersArray.getAsArray();
for (const MemberTypeInfo &Member : I.Members) {
json::Value MemberVal = Object();
@@ -557,12 +559,16 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
PubMembersArrayRef.push_back(MemberVal);
else if (Member.Access == AccessSpecifier::AS_protected)
ProtMembersArrayRef.push_back(MemberVal);
+ else if (Member.Access == AccessSpecifier::AS_private)
+ PrivateMembersArrayRef.push_back(MemberVal);
}
if (!PubMembersArrayRef.empty())
insertArray(Obj, PublicMembersArray, "PublicMembers");
if (!ProtMembersArrayRef.empty())
Obj["ProtectedMembers"] = ProtectedMembersArray;
+ if (!PrivateMembersArrayRef.empty())
+ insertArray(Obj, PrivateMembersArray, "PrivateMembers");
}
if (!I.Bases.empty())
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp
index 9d3102a11db9d..d57e8a990c3fe 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -30,6 +30,8 @@ struct MyClass {
int protectedMethod();
int ProtectedField;
+private:
+ int PrivateField;
};
// CHECK: {
@@ -122,6 +124,7 @@ struct MyClass {
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "HasEnums": true,
+// CHECK-NEXT: "HasPrivateMembers": true,
// CHECK-NEXT: "HasPublicFunctions": true,
// CHECK-NEXT: "HasPublicMembers": true,
// CHECK-NEXT: "HasRecords": true,
@@ -137,6 +140,13 @@ struct MyClass {
// CHECK-NEXT: "GlobalNamespace"
// CHECK-NEXT: ],
// CHECK-NEXT: "Path": "GlobalNamespace",
+// CHECK-NEXT: "PrivateMembers": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "IsStatic": false,
+// CHECK-NEXT: "Name": "PrivateField",
+// CHECK-NEXT: "Type": "int"
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
// CHECK-NEXT: "ProtectedFunctions": [
// CHECK-NEXT: {
// CHECK-NEXT: "InfoType": "function",
|
petrhosek
approved these changes
Dec 11, 2025
a0298a6 to
45d8e8a
Compare
5a303b8 to
0be4b36
Compare
Base automatically changed from
users/evelez7/clang-doc-has-parents-vparents
to
main
December 11, 2025 18:42
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

No description provided.