Index: clang-tools-extra/clang-doc/BitcodeReader.cpp =================================================================== --- clang-tools-extra/clang-doc/BitcodeReader.cpp +++ clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -342,8 +342,6 @@ return decodeRecord(R, I->RefType, Blob); case REFERENCE_PATH: return decodeRecord(R, I->Path, Blob); - case REFERENCE_IS_IN_GLOBAL_NAMESPACE: - return decodeRecord(R, I->IsInGlobalNamespace, Blob); case REFERENCE_FIELD: return decodeRecord(R, F, Blob); default: Index: clang-tools-extra/clang-doc/BitcodeWriter.h =================================================================== --- clang-tools-extra/clang-doc/BitcodeWriter.h +++ clang-tools-extra/clang-doc/BitcodeWriter.h @@ -122,7 +122,6 @@ REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH, - REFERENCE_IS_IN_GLOBAL_NAMESPACE, REFERENCE_FIELD, RI_LAST, RI_FIRST = VERSION Index: clang-tools-extra/clang-doc/BitcodeWriter.cpp =================================================================== --- clang-tools-extra/clang-doc/BitcodeWriter.cpp +++ clang-tools-extra/clang-doc/BitcodeWriter.cpp @@ -187,8 +187,6 @@ {REFERENCE_NAME, {"Name", &StringAbbrev}}, {REFERENCE_TYPE, {"RefType", &IntAbbrev}}, {REFERENCE_PATH, {"Path", &StringAbbrev}}, - {REFERENCE_IS_IN_GLOBAL_NAMESPACE, - {"IsInGlobalNamespace", &BoolAbbrev}}, {REFERENCE_FIELD, {"Field", &IntAbbrev}}}; assert(Inits.size() == RecordIdCount); for (const auto &Init : Inits) { @@ -239,7 +237,7 @@ // Reference Block {BI_REFERENCE_BLOCK_ID, {REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH, - REFERENCE_IS_IN_GLOBAL_NAMESPACE, REFERENCE_FIELD}}}; + REFERENCE_FIELD}}}; // AbbreviationMap @@ -412,7 +410,6 @@ emitRecord(R.Name, REFERENCE_NAME); emitRecord((unsigned)R.RefType, REFERENCE_TYPE); emitRecord(R.Path, REFERENCE_PATH); - emitRecord(R.IsInGlobalNamespace, REFERENCE_IS_IN_GLOBAL_NAMESPACE); emitRecord((unsigned)Field, REFERENCE_FIELD); } Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp =================================================================== --- clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -308,7 +308,7 @@ static std::unique_ptr genReference(const Reference &Type, StringRef CurrentDirectory, llvm::Optional JumpToSection = None) { - if (Type.Path.empty() && !Type.IsInGlobalNamespace) { + if (Type.Path.empty()) { if (!JumpToSection) return std::make_unique(Type.Name); else Index: clang-tools-extra/clang-doc/Representation.h =================================================================== --- clang-tools-extra/clang-doc/Representation.h +++ clang-tools-extra/clang-doc/Representation.h @@ -114,19 +114,9 @@ }; struct Reference { - Reference() = default; - Reference(llvm::StringRef Name) : Name(Name) {} - // An empty path means the info is in the global namespace because the path is - // a composite of the parent namespaces. - Reference(llvm::StringRef Name, StringRef Path) - : Name(Name), Path(Path), IsInGlobalNamespace(Path.empty()) {} - Reference(SymbolID USR, StringRef Name, InfoType IT) - : USR(USR), Name(Name), RefType(IT) {} - // An empty path means the info is in the global namespace because the path is - // a composite of the parent namespaces. - Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef Path) - : USR(USR), Name(Name), RefType(IT), Path(Path), - IsInGlobalNamespace(Path.empty()) {} + Reference(SymbolID USR = SymbolID(), StringRef Name = StringRef(), + InfoType IT = InfoType::IT_default, StringRef Path = StringRef()) + : USR(USR), Name(Name), RefType(IT), Path(Path) {} bool operator==(const Reference &Other) const { return std::tie(USR, Name, RefType) == @@ -150,9 +140,6 @@ // Path of directory where the clang-doc generated file will be saved // (possibly unresolved) llvm::SmallString<128> Path; - // Indicates if the info's parent is the global namespace, or if the info is - // the global namespace - bool IsInGlobalNamespace = false; }; // A base struct for TypeInfos @@ -160,12 +147,10 @@ TypeInfo() = default; TypeInfo(const Reference &R) : Type(R) {} - TypeInfo(SymbolID Type, StringRef Field, InfoType IT) - : Type(Type, Field, IT) {} - TypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path) - : Type(Type, Field, IT, Path) {} - TypeInfo(llvm::StringRef RefName) : Type(RefName) {} - TypeInfo(llvm::StringRef RefName, StringRef Path) : Type(RefName, Path) {} + // Convenience constructor for when there is no symbol ID or info type + // (normally used for built-in types in tests). + TypeInfo(StringRef Name, StringRef Path = StringRef()) + : Type(SymbolID(), Name, InfoType::IT_default, Path) {} bool operator==(const TypeInfo &Other) const { return Type == Other.Type; } @@ -178,13 +163,6 @@ FieldTypeInfo(const TypeInfo &TI, StringRef Name = StringRef(), StringRef DefaultValue = StringRef()) : TypeInfo(TI), Name(Name), DefaultValue(DefaultValue) {} - FieldTypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path, - llvm::StringRef Name) - : TypeInfo(Type, Field, IT, Path), Name(Name) {} - FieldTypeInfo(llvm::StringRef RefName, llvm::StringRef Name) - : TypeInfo(RefName), Name(Name) {} - FieldTypeInfo(llvm::StringRef RefName, StringRef Path, llvm::StringRef Name) - : TypeInfo(RefName, Path), Name(Name) {} bool operator==(const FieldTypeInfo &Other) const { return std::tie(Type, Name, DefaultValue) == @@ -203,15 +181,6 @@ MemberTypeInfo() = default; MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access) : FieldTypeInfo(TI, Name), Access(Access) {} - MemberTypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path, - llvm::StringRef Name, AccessSpecifier Access) - : FieldTypeInfo(Type, Field, IT, Path, Name), Access(Access) {} - MemberTypeInfo(llvm::StringRef RefName, llvm::StringRef Name, - AccessSpecifier Access) - : FieldTypeInfo(RefName, Name), Access(Access) {} - MemberTypeInfo(llvm::StringRef RefName, StringRef Path, llvm::StringRef Name, - AccessSpecifier Access) - : FieldTypeInfo(RefName, Path, Name), Access(Access) {} bool operator==(const MemberTypeInfo &Other) const { return std::tie(Type, Name, Access, Description) == @@ -228,10 +197,8 @@ }; struct Location { - Location() = default; - Location(int LineNumber, SmallString<16> Filename) - : LineNumber(LineNumber), Filename(std::move(Filename)) {} - Location(int LineNumber, SmallString<16> Filename, bool IsFileInRootDir) + Location(int LineNumber = 0, StringRef Filename = StringRef(), + bool IsFileInRootDir = false) : LineNumber(LineNumber), Filename(std::move(Filename)), IsFileInRootDir(IsFileInRootDir) {} @@ -249,20 +216,17 @@ std::tie(Other.LineNumber, Other.Filename); } - int LineNumber; // Line number of this Location. + int LineNumber = 0; // Line number of this Location. SmallString<32> Filename; // File for this Location. bool IsFileInRootDir = false; // Indicates if file is inside root directory }; /// A base struct for Infos. struct Info { - Info() = default; - Info(InfoType IT) : IT(IT) {} - Info(InfoType IT, SymbolID USR) : USR(USR), IT(IT) {} - Info(InfoType IT, SymbolID USR, StringRef Name) - : USR(USR), IT(IT), Name(Name) {} - Info(InfoType IT, SymbolID USR, StringRef Name, StringRef Path) + Info(InfoType IT = InfoType::IT_default, SymbolID USR = SymbolID(), + StringRef Name = StringRef(), StringRef Path = StringRef()) : USR(USR), IT(IT), Name(Name), Path(Path) {} + Info(const Info &Other) = delete; Info(Info &&Other) = default; @@ -296,11 +260,8 @@ // Info for namespaces. struct NamespaceInfo : public Info { - NamespaceInfo() : Info(InfoType::IT_namespace) {} - NamespaceInfo(SymbolID USR) : Info(InfoType::IT_namespace, USR) {} - NamespaceInfo(SymbolID USR, StringRef Name) - : Info(InfoType::IT_namespace, USR, Name) {} - NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path) + NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(), + StringRef Path = StringRef()) : Info(InfoType::IT_namespace, USR, Name, Path) {} void merge(NamespaceInfo &&I); @@ -317,10 +278,8 @@ // Info for symbols. struct SymbolInfo : public Info { - SymbolInfo(InfoType IT) : Info(IT) {} - SymbolInfo(InfoType IT, SymbolID USR) : Info(IT, USR) {} - SymbolInfo(InfoType IT, SymbolID USR, StringRef Name) : Info(IT, USR, Name) {} - SymbolInfo(InfoType IT, SymbolID USR, StringRef Name, StringRef Path) + SymbolInfo(InfoType IT, SymbolID USR = SymbolID(), + StringRef Name = StringRef(), StringRef Path = StringRef()) : Info(IT, USR, Name, Path) {} void merge(SymbolInfo &&I); @@ -332,8 +291,8 @@ // TODO: Expand to allow for documenting templating and default args. // Info for functions. struct FunctionInfo : public SymbolInfo { - FunctionInfo() : SymbolInfo(InfoType::IT_function) {} - FunctionInfo(SymbolID USR) : SymbolInfo(InfoType::IT_function, USR) {} + FunctionInfo(SymbolID USR = SymbolID()) + : SymbolInfo(InfoType::IT_function, USR) {} void merge(FunctionInfo &&I); @@ -352,11 +311,8 @@ // friend classes // Info for types. struct RecordInfo : public SymbolInfo { - RecordInfo() : SymbolInfo(InfoType::IT_record) {} - RecordInfo(SymbolID USR) : SymbolInfo(InfoType::IT_record, USR) {} - RecordInfo(SymbolID USR, StringRef Name) - : SymbolInfo(InfoType::IT_record, USR, Name) {} - RecordInfo(SymbolID USR, StringRef Name, StringRef Path) + RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(), + StringRef Path = StringRef()) : SymbolInfo(InfoType::IT_record, USR, Name, Path) {} void merge(RecordInfo &&I); @@ -450,9 +406,9 @@ struct Index : public Reference { Index() = default; - Index(StringRef Name) : Reference(Name) {} + Index(StringRef Name) : Reference(SymbolID(), Name) {} Index(StringRef Name, StringRef JumpToSection) - : Reference(Name), JumpToSection(JumpToSection) {} + : Reference(SymbolID(), Name), JumpToSection(JumpToSection) {} Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path) : Reference(USR, Name, IT, Path) {} // This is used to look for a USR in a vector of Indexes using std::find Index: clang-tools-extra/clang-doc/Representation.cpp =================================================================== --- clang-tools-extra/clang-doc/Representation.cpp +++ clang-tools-extra/clang-doc/Representation.cpp @@ -170,8 +170,6 @@ Name = Other.Name; if (Path.empty()) Path = Other.Path; - if (!IsInGlobalNamespace) - IsInGlobalNamespace = Other.IsInGlobalNamespace; } void Info::mergeBase(Info &&Other) { Index: clang-tools-extra/clang-doc/Serialize.cpp =================================================================== --- clang-tools-extra/clang-doc/Serialize.cpp +++ clang-tools-extra/clang-doc/Serialize.cpp @@ -239,7 +239,7 @@ TypeInfo getTypeInfoForType(const QualType &T) { const TagDecl *TD = getTagDeclForType(T); if (!TD) - return TypeInfo(Reference(T.getAsString())); + return TypeInfo(Reference(SymbolID(), T.getAsString())); InfoType IT; if (dyn_cast(TD)) { @@ -360,7 +360,7 @@ I.Parents.emplace_back(getUSRForDecl(P), P->getNameAsString(), InfoType::IT_record, getInfoRelativePath(P)); else - I.Parents.emplace_back(B.getType().getAsString()); + I.Parents.emplace_back(SymbolID(), B.getType().getAsString()); } for (const CXXBaseSpecifier &B : D->vbases()) { if (const RecordDecl *P = getRecordDeclForType(B.getType())) @@ -368,7 +368,7 @@ InfoType::IT_record, getInfoRelativePath(P)); else - I.VirtualParents.emplace_back(B.getType().getAsString()); + I.VirtualParents.emplace_back(SymbolID(), B.getType().getAsString()); } } Index: clang-tools-extra/clang-doc/YAMLGenerator.cpp =================================================================== --- clang-tools-extra/clang-doc/YAMLGenerator.cpp +++ clang-tools-extra/clang-doc/YAMLGenerator.cpp @@ -174,7 +174,6 @@ IO.mapOptional("Name", Ref.Name, SmallString<16>()); IO.mapOptional("USR", Ref.USR, SymbolID()); IO.mapOptional("Path", Ref.Path, SmallString<128>()); - IO.mapOptional("IsInGlobalNamespace", Ref.IsInGlobalNamespace, false); } }; Index: clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp +++ clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp @@ -78,13 +78,14 @@ I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private); I.TagType = TagTypeKind::TTK_Class; I.IsTypeDef = true; I.Bases.emplace_back(EmptySID, "F", "path/to/F", true, AccessSpecifier::AS_public, true); I.Bases.back().ChildFunctions.emplace_back(); - I.Bases.back().Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.Bases.back().Members.emplace_back(TypeInfo("int"), "X", + AccessSpecifier::AS_private); I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); @@ -119,8 +120,8 @@ I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "P"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "P"); I.Access = AccessSpecifier::AS_none; @@ -139,8 +140,8 @@ I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "P"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "P"); I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); @@ -174,9 +175,9 @@ TEST(SerializeTest, emitInfoWithCommentBitcode) { FunctionInfo F; F.Name = "F"; - F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + F.ReturnType = TypeInfo("void"); F.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); - F.Params.emplace_back("int", "I"); + F.Params.emplace_back(TypeInfo("int"), "I"); CommentInfo Top; Top.Kind = "FullComment"; Index: clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp @@ -24,7 +24,7 @@ auto InfoC = std::make_unique(); InfoC->Name = "C"; InfoC->USR = serialize::hashUSR("3"); - Reference RefB = Reference("B"); + Reference RefB = Reference(SymbolID(), "B"); RefB.USR = serialize::hashUSR("2"); InfoC->Namespace = {std::move(RefB)}; Generator::addInfoToIndex(Idx, InfoC.get()); @@ -34,9 +34,9 @@ auto InfoF = std::make_unique(); InfoF->Name = "F"; InfoF->USR = serialize::hashUSR("6"); - Reference RefD = Reference("D"); + Reference RefD = Reference(SymbolID(), "D"); RefD.USR = serialize::hashUSR("4"); - Reference RefE = Reference("E"); + Reference RefE = Reference(SymbolID(), "E"); RefE.USR = serialize::hashUSR("5"); InfoF->Namespace = {std::move(RefE), std::move(RefD)}; Generator::addInfoToIndex(Idx, InfoF.get()); Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -152,7 +152,8 @@ SmallString<16> PathTo; llvm::sys::path::native("path/to", PathTo); - I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private); + I.Members.emplace_back(TypeInfo("int", "X/Y"), "X", + AccessSpecifier::AS_private); I.TagType = TagTypeKind::TTK_Class; I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); @@ -276,8 +277,9 @@ SmallString<16> PathTo; llvm::sys::path::native("path/to", PathTo); - I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo); - I.Params.emplace_back("int", PathTo, "P"); + I.ReturnType = + TypeInfo(Reference(EmptySID, "float", InfoType::IT_default, PathTo)); + I.Params.emplace_back(TypeInfo("int", PathTo), "P"); I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); @@ -370,9 +372,9 @@ FunctionInfo I; I.Name = "f"; I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "I"); - I.Params.emplace_back("int", "J"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "I"); + I.Params.emplace_back(TypeInfo("int"), "J"); I.Access = AccessSpecifier::AS_none; CommentInfo Top; Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp @@ -85,7 +85,7 @@ I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private); I.TagType = TagTypeKind::TTK_Class; I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); @@ -154,8 +154,8 @@ I.Access = AccessSpecifier::AS_none; - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "P"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "P"); I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); @@ -211,9 +211,9 @@ FunctionInfo I; I.Name = "f"; I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "I"); - I.Params.emplace_back("int", "J"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "I"); + I.Params.emplace_back(TypeInfo("int"), "J"); I.Access = AccessSpecifier::AS_none; CommentInfo Top; Index: clang-tools-extra/unittests/clang-doc/MergeTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/MergeTest.cpp +++ clang-tools-extra/unittests/clang-doc/MergeTest.cpp @@ -83,7 +83,7 @@ One.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); - One.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + One.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private); One.TagType = TagTypeKind::TTK_Class; One.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); One.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); @@ -126,7 +126,8 @@ Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); Expected->Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - Expected->Members.emplace_back("int", "X", AccessSpecifier::AS_private); + Expected->Members.emplace_back(TypeInfo("int"), "X", + AccessSpecifier::AS_private); Expected->TagType = TagTypeKind::TTK_Class; Expected->Parents.emplace_back(EmptySID, "F", InfoType::IT_record); Expected->VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); @@ -180,8 +181,8 @@ Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - Two.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - Two.Params.emplace_back("int", "P"); + Two.ReturnType = TypeInfo("void"); + Two.Params.emplace_back(TypeInfo("int"), "P"); Two.Description.emplace_back(); auto TwoFullComment = &Two.Description.back(); @@ -205,8 +206,8 @@ Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); Expected->Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - Expected->ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - Expected->Params.emplace_back("int", "P"); + Expected->ReturnType = TypeInfo("void"); + Expected->Params.emplace_back(TypeInfo("int"), "P"); Expected->IsMethod = true; Expected->Parent = Reference(EmptySID, "Parent", InfoType::IT_namespace); Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/SerializeTest.cpp +++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp @@ -119,7 +119,7 @@ NamespaceInfo ExpectedBWithFunction(EmptySID); FunctionInfo F; F.Name = "f"; - F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + F.ReturnType = TypeInfo("void"); F.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace); F.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); @@ -165,7 +165,8 @@ InfoType::IT_namespace); ExpectedE.TagType = TagTypeKind::TTK_Class; ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); - ExpectedE.Members.emplace_back("int", "value", AccessSpecifier::AS_public); + ExpectedE.Members.emplace_back(TypeInfo("int"), "value", + AccessSpecifier::AS_public); // TODO the data member should have the docstring on it: //ExpectedE.Members.back().Description.push_back(MakeOneLineCommentInfo(" Some docs")); CheckRecordInfo(&ExpectedE, E); @@ -175,7 +176,7 @@ FunctionInfo EConstructor; EConstructor.Name = "E"; EConstructor.Parent = Reference(EmptySID, "E", InfoType::IT_record); - EConstructor.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + EConstructor.ReturnType = TypeInfo("void"); EConstructor.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); EConstructor.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record); EConstructor.Namespace.emplace_back(EmptySID, "GlobalNamespace", @@ -191,7 +192,7 @@ FunctionInfo Method; Method.Name = "ProtectedMethod"; Method.Parent = Reference(EmptySID, "E", InfoType::IT_record); - Method.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + Method.ReturnType = TypeInfo("void"); Method.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"}); Method.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record); Method.Namespace.emplace_back(EmptySID, "GlobalNamespace", @@ -214,7 +215,7 @@ FunctionInfo TemplateMethod; TemplateMethod.Name = "TemplateMethod"; TemplateMethod.Parent = Reference(EmptySID, "F", InfoType::IT_record); - TemplateMethod.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + TemplateMethod.ReturnType = TypeInfo("void"); TemplateMethod.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"}); TemplateMethod.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record); TemplateMethod.Namespace.emplace_back(EmptySID, "GlobalNamespace", @@ -231,8 +232,7 @@ SpecializedTemplateMethod.Name = "TemplateMethod"; SpecializedTemplateMethod.Parent = Reference(EmptySID, "F", InfoType::IT_record); - SpecializedTemplateMethod.ReturnType = - TypeInfo(EmptySID, "void", InfoType::IT_default); + SpecializedTemplateMethod.ReturnType = TypeInfo("void"); SpecializedTemplateMethod.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"}); SpecializedTemplateMethod.Namespace.emplace_back(EmptySID, "F", @@ -306,7 +306,8 @@ InfoType::IT_namespace); ExpectedE.TagType = TagTypeKind::TTK_Struct; ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); - ExpectedE.Members.emplace_back("int", "I", AccessSpecifier::AS_public); + ExpectedE.Members.emplace_back(TypeInfo("int"), "I", + AccessSpecifier::AS_public); CheckRecordInfo(&ExpectedE, E); } @@ -348,7 +349,7 @@ NamespaceInfo ExpectedBWithFunction(EmptySID); FunctionInfo F; F.Name = "F"; - F.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); + F.ReturnType = TypeInfo("int"); F.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); F.Access = AccessSpecifier::AS_none; ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); @@ -363,9 +364,9 @@ NamespaceInfo ExpectedBWithFunction(EmptySID); FunctionInfo F; F.Name = "F"; - F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + F.ReturnType = TypeInfo("void"); F.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); - F.Params.emplace_back("int", "I"); + F.Params.emplace_back(TypeInfo("int"), "I"); F.Access = AccessSpecifier::AS_none; ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); CheckNamespaceInfo(&ExpectedBWithFunction, BWithFunction); @@ -396,7 +397,8 @@ InfoType::IT_namespace); ExpectedG.TagType = TagTypeKind::TTK_Class; ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); - ExpectedG.Members.emplace_back("int", "I", AccessSpecifier::AS_protected); + ExpectedG.Members.emplace_back(TypeInfo("int"), "I", + AccessSpecifier::AS_protected); CheckRecordInfo(&ExpectedG, G); RecordInfo *E = InfoAsRecord(Infos[6].get()); @@ -412,9 +414,9 @@ AccessSpecifier::AS_public, true); FunctionInfo FunctionSet; FunctionSet.Name = "set"; - FunctionSet.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + FunctionSet.ReturnType = TypeInfo("void"); FunctionSet.Loc.emplace_back(); - FunctionSet.Params.emplace_back("int", "N"); + FunctionSet.Params.emplace_back(TypeInfo("int"), "N"); FunctionSet.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record); FunctionSet.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace); @@ -426,7 +428,7 @@ AccessSpecifier::AS_private, true); FunctionInfo FunctionGet; FunctionGet.Name = "get"; - FunctionGet.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); + FunctionGet.ReturnType = TypeInfo("int"); FunctionGet.DefLoc = Location(); FunctionGet.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record); FunctionGet.Namespace.emplace_back(EmptySID, "GlobalNamespace", @@ -434,7 +436,7 @@ FunctionGet.Access = AccessSpecifier::AS_private; FunctionGet.IsMethod = true; ExpectedE.Bases.back().ChildFunctions.emplace_back(std::move(FunctionGet)); - ExpectedE.Bases.back().Members.emplace_back("int", "I", + ExpectedE.Bases.back().Members.emplace_back(TypeInfo("int"), "I", AccessSpecifier::AS_private); ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); ExpectedE.TagType = TagTypeKind::TTK_Class; @@ -458,9 +460,9 @@ AccessSpecifier::AS_private, false); FunctionInfo FunctionSetNew; FunctionSetNew.Name = "set"; - FunctionSetNew.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + FunctionSetNew.ReturnType = TypeInfo("void"); FunctionSetNew.Loc.emplace_back(); - FunctionSetNew.Params.emplace_back("int", "N"); + FunctionSetNew.Params.emplace_back(TypeInfo("int"), "N"); FunctionSetNew.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record); FunctionSetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace); @@ -472,7 +474,7 @@ AccessSpecifier::AS_private, false); FunctionInfo FunctionGetNew; FunctionGetNew.Name = "get"; - FunctionGetNew.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); + FunctionGetNew.ReturnType = TypeInfo("int"); FunctionGetNew.DefLoc = Location(); FunctionGetNew.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record); FunctionGetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace", @@ -480,7 +482,7 @@ FunctionGetNew.Access = AccessSpecifier::AS_private; FunctionGetNew.IsMethod = true; ExpectedH.Bases.back().ChildFunctions.emplace_back(std::move(FunctionGetNew)); - ExpectedH.Bases.back().Members.emplace_back("int", "I", + ExpectedH.Bases.back().Members.emplace_back(TypeInfo("int"), "I", AccessSpecifier::AS_private); CheckRecordInfo(&ExpectedH, H); @@ -520,10 +522,10 @@ NamespaceInfo ExpectedBWithFunction(EmptySID); FunctionInfo F; F.Name = "moduleFunction"; - F.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); + F.ReturnType = TypeInfo("int"); F.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"}); - F.Params.emplace_back("int", "x"); - F.Params.emplace_back("double", "d"); + F.Params.emplace_back(TypeInfo("int"), "x"); + F.Params.emplace_back(TypeInfo("double"), "d"); F.Params.back().DefaultValue = "3.2 - 1.0"; F.Access = AccessSpecifier::AS_none; ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); @@ -533,9 +535,10 @@ NamespaceInfo ExpectedBWithExportedFunction(EmptySID); FunctionInfo ExportedF; ExportedF.Name = "exportedModuleFunction"; - ExportedF.ReturnType = TypeInfo(EmptySID, "double", InfoType::IT_default); + ExportedF.ReturnType = + TypeInfo(Reference(EmptySID, "double", InfoType::IT_default)); ExportedF.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"}); - ExportedF.Params.emplace_back("double", "y"); + ExportedF.Params.emplace_back(TypeInfo("double"), "y"); ExportedF.Access = AccessSpecifier::AS_none; ExpectedBWithExportedFunction.ChildFunctions.emplace_back( std::move(ExportedF)); Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp @@ -82,7 +82,7 @@ I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.Members.emplace_back("int", "path/to/int", "X", + I.Members.emplace_back(TypeInfo("int", "path/to/int"), "X", AccessSpecifier::AS_private); // Member documentation. @@ -102,7 +102,7 @@ AccessSpecifier::AS_public, true); I.Bases.back().ChildFunctions.emplace_back(); I.Bases.back().ChildFunctions.back().Name = "InheritedFunctionOne"; - I.Bases.back().Members.emplace_back("int", "path/to/int", "N", + I.Bases.back().Members.emplace_back(TypeInfo("int", "path/to/int"), "N", AccessSpecifier::AS_private); // F is in the global namespace I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, ""); @@ -174,7 +174,6 @@ Parents: - Type: Record Name: 'F' - IsInGlobalNamespace: true VirtualParents: - Type: Record Name: 'G' @@ -206,10 +205,10 @@ I.Access = AccessSpecifier::AS_none; - I.ReturnType = - TypeInfo(EmptySID, "void", InfoType::IT_default, "path/to/void"); - I.Params.emplace_back("int", "path/to/int", "P"); - I.Params.emplace_back("double", "path/to/double", "D"); + I.ReturnType = TypeInfo( + Reference(EmptySID, "void", InfoType::IT_default, "path/to/void")); + I.Params.emplace_back(TypeInfo("int", "path/to/int"), "P"); + I.Params.emplace_back(TypeInfo("double", "path/to/double"), "D"); I.Params.back().DefaultValue = "2.0 * M_PI"; I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); @@ -335,9 +334,9 @@ FunctionInfo I; I.Name = "f"; I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); - I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); - I.Params.emplace_back("int", "I"); - I.Params.emplace_back("int", "J"); + I.ReturnType = TypeInfo("void"); + I.Params.emplace_back(TypeInfo("int"), "I"); + I.Params.emplace_back(TypeInfo("int"), "J"); I.Access = AccessSpecifier::AS_none; CommentInfo Top;