Skip to content

Commit d18b796

Browse files
authored
[clang-doc] remove FullName from serialization (#166595)
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
1 parent 46c9489 commit d18b796

File tree

5 files changed

+0
-65
lines changed

5 files changed

+0
-65
lines changed

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ static void insertArray(Object &Obj, json::Value &Array, StringRef Key) {
468468
static void serializeInfo(const RecordInfo &I, json::Object &Obj,
469469
const std::optional<StringRef> &RepositoryUrl) {
470470
serializeCommonAttributes(I, Obj, RepositoryUrl);
471-
Obj["FullName"] = I.FullName;
472471
Obj["TagType"] = getTagType(I.TagType);
473472
Obj["IsTypedef"] = I.IsTypeDef;
474473
Obj["MangledName"] = I.MangledName;

clang-tools-extra/clang-doc/Representation.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,6 @@ struct FunctionInfo : public SymbolInfo {
437437
// (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
438438
AccessSpecifier Access = AccessSpecifier::AS_public;
439439

440-
// Full qualified name of this function, including namespaces and template
441-
// specializations.
442-
SmallString<16> FullName;
443-
444440
// Function Prototype
445441
SmallString<256> Prototype;
446442

@@ -460,10 +456,6 @@ struct RecordInfo : public SymbolInfo {
460456
// Type of this record (struct, class, union, interface).
461457
TagTypeKind TagType = TagTypeKind::Struct;
462458

463-
// Full qualified name of this record, including namespaces and template
464-
// specializations.
465-
SmallString<16> FullName;
466-
467459
// When present, this record is a template or specialization.
468460
std::optional<TemplateInfo> Template;
469461

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -178,55 +178,6 @@ static llvm::SmallString<16> getTypeAlias(const TypeAliasDecl *Alias) {
178178
return Result;
179179
}
180180

181-
// extract full syntax for record declaration
182-
static llvm::SmallString<16> getRecordPrototype(const CXXRecordDecl *CXXRD) {
183-
llvm::SmallString<16> Result;
184-
LangOptions LangOpts;
185-
PrintingPolicy Policy(LangOpts);
186-
Policy.SuppressTagKeyword = false;
187-
Policy.FullyQualifiedName = true;
188-
Policy.IncludeNewlines = false;
189-
llvm::raw_svector_ostream OS(Result);
190-
if (const auto *TD = CXXRD->getDescribedClassTemplate()) {
191-
OS << "template <";
192-
bool FirstParam = true;
193-
for (const auto *Param : *TD->getTemplateParameters()) {
194-
if (!FirstParam)
195-
OS << ", ";
196-
Param->print(OS, Policy);
197-
FirstParam = false;
198-
}
199-
OS << ">\n";
200-
}
201-
202-
if (CXXRD->isStruct())
203-
OS << "struct ";
204-
else if (CXXRD->isClass())
205-
OS << "class ";
206-
else if (CXXRD->isUnion())
207-
OS << "union ";
208-
209-
OS << CXXRD->getNameAsString();
210-
211-
// We need to make sure we have a good enough declaration to check. In the
212-
// case where the class is a forward declaration, we'll fail assertions in
213-
// DeclCXX.
214-
if (CXXRD->isCompleteDefinition() && CXXRD->getNumBases() > 0) {
215-
OS << " : ";
216-
bool FirstBase = true;
217-
for (const auto &Base : CXXRD->bases()) {
218-
if (!FirstBase)
219-
OS << ", ";
220-
if (Base.isVirtual())
221-
OS << "virtual ";
222-
OS << getAccessSpelling(Base.getAccessSpecifier()) << " ";
223-
OS << Base.getType().getAsString(Policy);
224-
FirstBase = false;
225-
}
226-
}
227-
return Result;
228-
}
229-
230181
// A function to extract the appropriate relative path for a given info's
231182
// documentation. The path returned is a composite of the parent namespaces.
232183
//
@@ -1033,7 +984,6 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc,
1033984
parseFields(*RI, D, PublicOnly);
1034985

1035986
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
1036-
RI->FullName = getRecordPrototype(C);
1037987
if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
1038988
RI->Name = TD->getNameAsString();
1039989
RI->IsTypeDef = true;

clang-tools-extra/test/clang-doc/json/class.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ struct MyClass {
124124
// CHECK-NEXT: }
125125
// CHECK-NEXT: }
126126
// CHECK-NEXT: ],
127-
// COM: FIXME: FullName is not emitted correctly.
128-
// CHECK-NEXT: "FullName": "",
129127
// CHECK-NEXT: "HasEnums": true,
130128
// CHECK-NEXT: "HasPublicFunctions": true,
131129
// CHECK-NEXT: "HasPublicMembers": true,

clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ static std::unique_ptr<Generator> getJSONGenerator() {
1616
TEST(JSONGeneratorTest, emitRecordJSON) {
1717
RecordInfo I;
1818
I.Name = "Foo";
19-
// FIXME: FullName is not emitted correctly.
20-
I.FullName = "";
2119
I.IsTypeDef = false;
2220
I.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace);
2321
I.Path = "GlobalNamespace";
@@ -64,7 +62,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
6462
{
6563
"Access": "public",
6664
"End": true,
67-
"FullName": "",
6865
"HasPublicFunctions": true,
6966
"HasPublicMembers": true,
7067
"InfoType": "record",
@@ -115,7 +112,6 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
115112
"USR": "0000000000000000000000000000000000000000"
116113
}
117114
],
118-
"FullName": "",
119115
"HasEnums": true,
120116
"HasPublicFunctions": true,
121117
"HasRecords": true,

0 commit comments

Comments
 (0)