-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-doc] remove FullName from serialization #166595
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
An Info's FullName was not being used anywhere in clang-doc. It seems to have been superseded by other types like QualName. Removing QualName also orphans getRecordPrototype, which constructs a record's full declaration (template<...> class ...). There are better ways to construct this documentation in templates.
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesAn Info's FullName was not being used anywhere in clang-doc. It seems to Fixes #143086 Full diff: https://github.com/llvm/llvm-project/pull/166595.diff 5 Files Affected:
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index b17cc80bdba34..93ec90e9048ea 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -468,7 +468,6 @@ static void insertArray(Object &Obj, json::Value &Array, StringRef Key) {
static void serializeInfo(const RecordInfo &I, json::Object &Obj,
const std::optional<StringRef> &RepositoryUrl) {
serializeCommonAttributes(I, Obj, RepositoryUrl);
- Obj["FullName"] = I.FullName;
Obj["TagType"] = getTagType(I.TagType);
Obj["IsTypedef"] = I.IsTypeDef;
Obj["MangledName"] = I.MangledName;
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index d8c2b9c0a5842..79e9bfc291c3a 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -437,10 +437,6 @@ struct FunctionInfo : public SymbolInfo {
// (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
AccessSpecifier Access = AccessSpecifier::AS_public;
- // Full qualified name of this function, including namespaces and template
- // specializations.
- SmallString<16> FullName;
-
// Function Prototype
SmallString<256> Prototype;
@@ -460,10 +456,6 @@ struct RecordInfo : public SymbolInfo {
// Type of this record (struct, class, union, interface).
TagTypeKind TagType = TagTypeKind::Struct;
- // Full qualified name of this record, including namespaces and template
- // specializations.
- SmallString<16> FullName;
-
// When present, this record is a template or specialization.
std::optional<TemplateInfo> Template;
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 186f634dd892a..7f8691d63622f 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -178,55 +178,6 @@ static llvm::SmallString<16> getTypeAlias(const TypeAliasDecl *Alias) {
return Result;
}
-// extract full syntax for record declaration
-static llvm::SmallString<16> getRecordPrototype(const CXXRecordDecl *CXXRD) {
- llvm::SmallString<16> Result;
- LangOptions LangOpts;
- PrintingPolicy Policy(LangOpts);
- Policy.SuppressTagKeyword = false;
- Policy.FullyQualifiedName = true;
- Policy.IncludeNewlines = false;
- llvm::raw_svector_ostream OS(Result);
- if (const auto *TD = CXXRD->getDescribedClassTemplate()) {
- OS << "template <";
- bool FirstParam = true;
- for (const auto *Param : *TD->getTemplateParameters()) {
- if (!FirstParam)
- OS << ", ";
- Param->print(OS, Policy);
- FirstParam = false;
- }
- OS << ">\n";
- }
-
- if (CXXRD->isStruct())
- OS << "struct ";
- else if (CXXRD->isClass())
- OS << "class ";
- else if (CXXRD->isUnion())
- OS << "union ";
-
- OS << CXXRD->getNameAsString();
-
- // We need to make sure we have a good enough declaration to check. In the
- // case where the class is a forward declaration, we'll fail assertions in
- // DeclCXX.
- if (CXXRD->isCompleteDefinition() && CXXRD->getNumBases() > 0) {
- OS << " : ";
- bool FirstBase = true;
- for (const auto &Base : CXXRD->bases()) {
- if (!FirstBase)
- OS << ", ";
- if (Base.isVirtual())
- OS << "virtual ";
- OS << getAccessSpelling(Base.getAccessSpecifier()) << " ";
- OS << Base.getType().getAsString(Policy);
- FirstBase = false;
- }
- }
- return Result;
-}
-
// A function to extract the appropriate relative path for a given info's
// documentation. The path returned is a composite of the parent namespaces.
//
@@ -1033,7 +984,6 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc,
parseFields(*RI, D, PublicOnly);
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
- RI->FullName = getRecordPrototype(C);
if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
RI->Name = TD->getNameAsString();
RI->IsTypeDef = true;
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp
index 20a9f218b3d79..adb1ed7511c3b 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -124,8 +124,6 @@ struct MyClass {
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ],
-// COM: FIXME: FullName is not emitted correctly.
-// CHECK-NEXT: "FullName": "",
// CHECK-NEXT: "HasEnums": true,
// CHECK-NEXT: "HasPublicFunctions": true,
// CHECK-NEXT: "HasPublicMembers": true,
diff --git a/clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp
index 07c761fcd0685..2706a5145ebfd 100644
--- a/clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp
@@ -16,8 +16,6 @@ static std::unique_ptr<Generator> getJSONGenerator() {
TEST(JSONGeneratorTest, emitRecordJSON) {
RecordInfo I;
I.Name = "Foo";
- // FIXME: FullName is not emitted correctly.
- I.FullName = "";
I.IsTypeDef = false;
I.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace);
I.Path = "GlobalNamespace";
@@ -64,7 +62,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
{
"Access": "public",
"End": true,
- "FullName": "",
"HasPublicFunctions": true,
"HasPublicMembers": true,
"InfoType": "record",
@@ -115,7 +112,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
"USR": "0000000000000000000000000000000000000000"
}
],
- "FullName": "",
"HasEnums": true,
"HasPublicFunctions": true,
"HasRecords": true,
|
ilovepi
left a comment
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.
Surprised this is dead. I thought the HTML still used it, but if tests are passing, then its probably OK.

An Info's FullName was not being used anywhere in clang-doc. It seems to
have been superseded by other types like QualName. Removing FullName
also orphans getRecordPrototype, which constructs a record's full
declaration (template<...> class ...). There are better ways to
construct this documentation in templates.
Fixes #143086