[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
This commit is contained in:
parent
46c948935d
commit
d18b796429
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -124,8 +124,6 @@ protected:
|
||||
// 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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user