[clang-doc] Clean up *Info constructors.

The *Info object (for the copy of the AST") constructors had many duplicated variants. Many of the variants seemed to be in an attempt to avoid default arguments. But default arguments are not prohibited and using them allows most of the variants to be removed which improves readability.

Remove the IsInGlobalNamespace flag on a Reference. This is set when the path is empty, and only read once in the HTML generator with the identical condition. The constructor cleanup exposed a problem where this was set to false when the constructor with no path was used, but true when the path was set to empty.

There should be no observable change with the exception that IsInGlobalNamespace is no longer emitted in YAML.

Reviewed By: paulkirth, haowei

Differential Revision: https://reviews.llvm.org/D134235
This commit is contained in:
Brett Wilson 2022-09-27 23:29:04 +00:00 committed by Paul Kirth
parent 1fee25629d
commit 0afc60858e
15 changed files with 99 additions and 146 deletions

View File

@ -342,8 +342,6 @@ llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
return decodeRecord(R, I->RefType, Blob); return decodeRecord(R, I->RefType, Blob);
case REFERENCE_PATH: case REFERENCE_PATH:
return decodeRecord(R, I->Path, Blob); return decodeRecord(R, I->Path, Blob);
case REFERENCE_IS_IN_GLOBAL_NAMESPACE:
return decodeRecord(R, I->IsInGlobalNamespace, Blob);
case REFERENCE_FIELD: case REFERENCE_FIELD:
return decodeRecord(R, F, Blob); return decodeRecord(R, F, Blob);
default: default:

View File

@ -187,8 +187,6 @@ static const llvm::IndexedMap<RecordIdDsc, RecordIdToIndexFunctor>
{REFERENCE_NAME, {"Name", &StringAbbrev}}, {REFERENCE_NAME, {"Name", &StringAbbrev}},
{REFERENCE_TYPE, {"RefType", &IntAbbrev}}, {REFERENCE_TYPE, {"RefType", &IntAbbrev}},
{REFERENCE_PATH, {"Path", &StringAbbrev}}, {REFERENCE_PATH, {"Path", &StringAbbrev}},
{REFERENCE_IS_IN_GLOBAL_NAMESPACE,
{"IsInGlobalNamespace", &BoolAbbrev}},
{REFERENCE_FIELD, {"Field", &IntAbbrev}}}; {REFERENCE_FIELD, {"Field", &IntAbbrev}}};
assert(Inits.size() == RecordIdCount); assert(Inits.size() == RecordIdCount);
for (const auto &Init : Inits) { for (const auto &Init : Inits) {
@ -239,7 +237,7 @@ static const std::vector<std::pair<BlockId, std::vector<RecordId>>>
// Reference Block // Reference Block
{BI_REFERENCE_BLOCK_ID, {BI_REFERENCE_BLOCK_ID,
{REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH, {REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH,
REFERENCE_IS_IN_GLOBAL_NAMESPACE, REFERENCE_FIELD}}}; REFERENCE_FIELD}}};
// AbbreviationMap // AbbreviationMap
@ -412,7 +410,6 @@ void ClangDocBitcodeWriter::emitBlock(const Reference &R, FieldId Field) {
emitRecord(R.Name, REFERENCE_NAME); emitRecord(R.Name, REFERENCE_NAME);
emitRecord((unsigned)R.RefType, REFERENCE_TYPE); emitRecord((unsigned)R.RefType, REFERENCE_TYPE);
emitRecord(R.Path, REFERENCE_PATH); emitRecord(R.Path, REFERENCE_PATH);
emitRecord(R.IsInGlobalNamespace, REFERENCE_IS_IN_GLOBAL_NAMESPACE);
emitRecord((unsigned)Field, REFERENCE_FIELD); emitRecord((unsigned)Field, REFERENCE_FIELD);
} }

View File

@ -122,7 +122,6 @@ enum RecordId {
REFERENCE_NAME, REFERENCE_NAME,
REFERENCE_TYPE, REFERENCE_TYPE,
REFERENCE_PATH, REFERENCE_PATH,
REFERENCE_IS_IN_GLOBAL_NAMESPACE,
REFERENCE_FIELD, REFERENCE_FIELD,
RI_LAST, RI_LAST,
RI_FIRST = VERSION RI_FIRST = VERSION

View File

@ -308,7 +308,7 @@ static std::unique_ptr<TagNode> genLink(const Twine &Text, const Twine &Link) {
static std::unique_ptr<HTMLNode> static std::unique_ptr<HTMLNode>
genReference(const Reference &Type, StringRef CurrentDirectory, genReference(const Reference &Type, StringRef CurrentDirectory,
llvm::Optional<StringRef> JumpToSection = None) { llvm::Optional<StringRef> JumpToSection = None) {
if (Type.Path.empty() && !Type.IsInGlobalNamespace) { if (Type.Path.empty()) {
if (!JumpToSection) if (!JumpToSection)
return std::make_unique<TextNode>(Type.Name); return std::make_unique<TextNode>(Type.Name);
else else

View File

@ -170,8 +170,6 @@ void Reference::merge(Reference &&Other) {
Name = Other.Name; Name = Other.Name;
if (Path.empty()) if (Path.empty())
Path = Other.Path; Path = Other.Path;
if (!IsInGlobalNamespace)
IsInGlobalNamespace = Other.IsInGlobalNamespace;
} }
void Info::mergeBase(Info &&Other) { void Info::mergeBase(Info &&Other) {

View File

@ -114,19 +114,9 @@ struct CommentInfo {
}; };
struct Reference { struct Reference {
Reference() = default; Reference(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
Reference(llvm::StringRef Name) : Name(Name) {} InfoType IT = InfoType::IT_default, StringRef Path = StringRef())
// An empty path means the info is in the global namespace because the path is : USR(USR), Name(Name), RefType(IT), Path(Path) {}
// 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()) {}
bool operator==(const Reference &Other) const { bool operator==(const Reference &Other) const {
return std::tie(USR, Name, RefType) == return std::tie(USR, Name, RefType) ==
@ -150,9 +140,6 @@ struct Reference {
// Path of directory where the clang-doc generated file will be saved // Path of directory where the clang-doc generated file will be saved
// (possibly unresolved) // (possibly unresolved)
llvm::SmallString<128> Path; 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 // A base struct for TypeInfos
@ -160,12 +147,10 @@ struct TypeInfo {
TypeInfo() = default; TypeInfo() = default;
TypeInfo(const Reference &R) : Type(R) {} TypeInfo(const Reference &R) : Type(R) {}
TypeInfo(SymbolID Type, StringRef Field, InfoType IT) // Convenience constructor for when there is no symbol ID or info type
: Type(Type, Field, IT) {} // (normally used for built-in types in tests).
TypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path) TypeInfo(StringRef Name, StringRef Path = StringRef())
: Type(Type, Field, IT, Path) {} : Type(SymbolID(), Name, InfoType::IT_default, Path) {}
TypeInfo(llvm::StringRef RefName) : Type(RefName) {}
TypeInfo(llvm::StringRef RefName, StringRef Path) : Type(RefName, Path) {}
bool operator==(const TypeInfo &Other) const { return Type == Other.Type; } bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }
@ -178,13 +163,6 @@ struct FieldTypeInfo : public TypeInfo {
FieldTypeInfo(const TypeInfo &TI, StringRef Name = StringRef(), FieldTypeInfo(const TypeInfo &TI, StringRef Name = StringRef(),
StringRef DefaultValue = StringRef()) StringRef DefaultValue = StringRef())
: TypeInfo(TI), Name(Name), DefaultValue(DefaultValue) {} : 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 { bool operator==(const FieldTypeInfo &Other) const {
return std::tie(Type, Name, DefaultValue) == return std::tie(Type, Name, DefaultValue) ==
@ -203,15 +181,6 @@ struct MemberTypeInfo : public FieldTypeInfo {
MemberTypeInfo() = default; MemberTypeInfo() = default;
MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access) MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access)
: FieldTypeInfo(TI, Name), Access(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 { bool operator==(const MemberTypeInfo &Other) const {
return std::tie(Type, Name, Access, Description) == return std::tie(Type, Name, Access, Description) ==
@ -228,11 +197,9 @@ struct MemberTypeInfo : public FieldTypeInfo {
}; };
struct Location { struct Location {
Location() = default; Location(int LineNumber = 0, StringRef Filename = StringRef(),
Location(int LineNumber, SmallString<16> Filename) bool IsFileInRootDir = false)
: LineNumber(LineNumber), Filename(std::move(Filename)) {} : LineNumber(LineNumber), Filename(Filename),
Location(int LineNumber, SmallString<16> Filename, bool IsFileInRootDir)
: LineNumber(LineNumber), Filename(std::move(Filename)),
IsFileInRootDir(IsFileInRootDir) {} IsFileInRootDir(IsFileInRootDir) {}
bool operator==(const Location &Other) const { bool operator==(const Location &Other) const {
@ -249,20 +216,17 @@ struct Location {
std::tie(Other.LineNumber, Other.Filename); 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. SmallString<32> Filename; // File for this Location.
bool IsFileInRootDir = false; // Indicates if file is inside root directory bool IsFileInRootDir = false; // Indicates if file is inside root directory
}; };
/// A base struct for Infos. /// A base struct for Infos.
struct Info { struct Info {
Info() = default; Info(InfoType IT = InfoType::IT_default, SymbolID USR = SymbolID(),
Info(InfoType IT) : IT(IT) {} StringRef Name = StringRef(), StringRef Path = StringRef())
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)
: USR(USR), IT(IT), Name(Name), Path(Path) {} : USR(USR), IT(IT), Name(Name), Path(Path) {}
Info(const Info &Other) = delete; Info(const Info &Other) = delete;
Info(Info &&Other) = default; Info(Info &&Other) = default;
@ -296,11 +260,8 @@ struct Info {
// Info for namespaces. // Info for namespaces.
struct NamespaceInfo : public Info { struct NamespaceInfo : public Info {
NamespaceInfo() : Info(InfoType::IT_namespace) {} NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
NamespaceInfo(SymbolID USR) : Info(InfoType::IT_namespace, USR) {} StringRef Path = StringRef())
NamespaceInfo(SymbolID USR, StringRef Name)
: Info(InfoType::IT_namespace, USR, Name) {}
NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path)
: Info(InfoType::IT_namespace, USR, Name, Path) {} : Info(InfoType::IT_namespace, USR, Name, Path) {}
void merge(NamespaceInfo &&I); void merge(NamespaceInfo &&I);
@ -317,10 +278,8 @@ struct NamespaceInfo : public Info {
// Info for symbols. // Info for symbols.
struct SymbolInfo : public Info { struct SymbolInfo : public Info {
SymbolInfo(InfoType IT) : Info(IT) {} SymbolInfo(InfoType IT, SymbolID USR = SymbolID(),
SymbolInfo(InfoType IT, SymbolID USR) : Info(IT, USR) {} StringRef Name = StringRef(), StringRef Path = StringRef())
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name) : Info(IT, USR, Name) {}
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name, StringRef Path)
: Info(IT, USR, Name, Path) {} : Info(IT, USR, Name, Path) {}
void merge(SymbolInfo &&I); void merge(SymbolInfo &&I);
@ -332,8 +291,8 @@ struct SymbolInfo : public Info {
// TODO: Expand to allow for documenting templating and default args. // TODO: Expand to allow for documenting templating and default args.
// Info for functions. // Info for functions.
struct FunctionInfo : public SymbolInfo { struct FunctionInfo : public SymbolInfo {
FunctionInfo() : SymbolInfo(InfoType::IT_function) {} FunctionInfo(SymbolID USR = SymbolID())
FunctionInfo(SymbolID USR) : SymbolInfo(InfoType::IT_function, USR) {} : SymbolInfo(InfoType::IT_function, USR) {}
void merge(FunctionInfo &&I); void merge(FunctionInfo &&I);
@ -352,11 +311,8 @@ struct FunctionInfo : public SymbolInfo {
// friend classes // friend classes
// Info for types. // Info for types.
struct RecordInfo : public SymbolInfo { struct RecordInfo : public SymbolInfo {
RecordInfo() : SymbolInfo(InfoType::IT_record) {} RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
RecordInfo(SymbolID USR) : SymbolInfo(InfoType::IT_record, USR) {} StringRef Path = StringRef())
RecordInfo(SymbolID USR, StringRef Name)
: SymbolInfo(InfoType::IT_record, USR, Name) {}
RecordInfo(SymbolID USR, StringRef Name, StringRef Path)
: SymbolInfo(InfoType::IT_record, USR, Name, Path) {} : SymbolInfo(InfoType::IT_record, USR, Name, Path) {}
void merge(RecordInfo &&I); void merge(RecordInfo &&I);
@ -450,9 +406,9 @@ struct EnumInfo : public SymbolInfo {
struct Index : public Reference { struct Index : public Reference {
Index() = default; Index() = default;
Index(StringRef Name) : Reference(Name) {} Index(StringRef Name) : Reference(SymbolID(), Name) {}
Index(StringRef Name, StringRef JumpToSection) Index(StringRef Name, StringRef JumpToSection)
: Reference(Name), JumpToSection(JumpToSection) {} : Reference(SymbolID(), Name), JumpToSection(JumpToSection) {}
Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path) Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
: Reference(USR, Name, IT, Path) {} : Reference(USR, Name, IT, Path) {}
// This is used to look for a USR in a vector of Indexes using std::find // This is used to look for a USR in a vector of Indexes using std::find

View File

@ -239,7 +239,7 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
TypeInfo getTypeInfoForType(const QualType &T) { TypeInfo getTypeInfoForType(const QualType &T) {
const TagDecl *TD = getTagDeclForType(T); const TagDecl *TD = getTagDeclForType(T);
if (!TD) if (!TD)
return TypeInfo(Reference(T.getAsString())); return TypeInfo(Reference(SymbolID(), T.getAsString()));
InfoType IT; InfoType IT;
if (dyn_cast<EnumDecl>(TD)) { if (dyn_cast<EnumDecl>(TD)) {
@ -360,7 +360,7 @@ static void parseBases(RecordInfo &I, const CXXRecordDecl *D) {
I.Parents.emplace_back(getUSRForDecl(P), P->getNameAsString(), I.Parents.emplace_back(getUSRForDecl(P), P->getNameAsString(),
InfoType::IT_record, getInfoRelativePath(P)); InfoType::IT_record, getInfoRelativePath(P));
else else
I.Parents.emplace_back(B.getType().getAsString()); I.Parents.emplace_back(SymbolID(), B.getType().getAsString());
} }
for (const CXXBaseSpecifier &B : D->vbases()) { for (const CXXBaseSpecifier &B : D->vbases()) {
if (const RecordDecl *P = getRecordDeclForType(B.getType())) if (const RecordDecl *P = getRecordDeclForType(B.getType()))
@ -368,7 +368,7 @@ static void parseBases(RecordInfo &I, const CXXRecordDecl *D) {
InfoType::IT_record, InfoType::IT_record,
getInfoRelativePath(P)); getInfoRelativePath(P));
else else
I.VirtualParents.emplace_back(B.getType().getAsString()); I.VirtualParents.emplace_back(SymbolID(), B.getType().getAsString());
} }
} }

View File

@ -174,7 +174,6 @@ template <> struct MappingTraits<Reference> {
IO.mapOptional("Name", Ref.Name, SmallString<16>()); IO.mapOptional("Name", Ref.Name, SmallString<16>());
IO.mapOptional("USR", Ref.USR, SymbolID()); IO.mapOptional("USR", Ref.USR, SymbolID());
IO.mapOptional("Path", Ref.Path, SmallString<128>()); IO.mapOptional("Path", Ref.Path, SmallString<128>());
IO.mapOptional("IsInGlobalNamespace", Ref.IsInGlobalNamespace, false);
} }
}; };

View File

@ -78,13 +78,14 @@ TEST(BitcodeTest, emitRecordInfoBitcode) {
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.Loc.emplace_back(12, 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.TagType = TagTypeKind::TTK_Class;
I.IsTypeDef = true; I.IsTypeDef = true;
I.Bases.emplace_back(EmptySID, "F", "path/to/F", true, I.Bases.emplace_back(EmptySID, "F", "path/to/F", true,
AccessSpecifier::AS_public, true); AccessSpecifier::AS_public, true);
I.Bases.back().ChildFunctions.emplace_back(); 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.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@ -119,8 +120,8 @@ TEST(BitcodeTest, emitFunctionInfoBitcode) {
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "P"); I.Params.emplace_back(TypeInfo("int"), "P");
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
@ -139,8 +140,8 @@ TEST(BitcodeTest, emitMethodInfoBitcode) {
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "P"); I.Params.emplace_back(TypeInfo("int"), "P");
I.IsMethod = true; I.IsMethod = true;
I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
@ -174,9 +175,9 @@ TEST(BitcodeTest, emitEnumInfoBitcode) {
TEST(SerializeTest, emitInfoWithCommentBitcode) { TEST(SerializeTest, emitInfoWithCommentBitcode) {
FunctionInfo F; FunctionInfo F;
F.Name = "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.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
F.Params.emplace_back("int", "I"); F.Params.emplace_back(TypeInfo("int"), "I");
CommentInfo Top; CommentInfo Top;
Top.Kind = "FullComment"; Top.Kind = "FullComment";

View File

@ -24,7 +24,7 @@ TEST(GeneratorTest, emitIndex) {
auto InfoC = std::make_unique<Info>(); auto InfoC = std::make_unique<Info>();
InfoC->Name = "C"; InfoC->Name = "C";
InfoC->USR = serialize::hashUSR("3"); InfoC->USR = serialize::hashUSR("3");
Reference RefB = Reference("B"); Reference RefB = Reference(SymbolID(), "B");
RefB.USR = serialize::hashUSR("2"); RefB.USR = serialize::hashUSR("2");
InfoC->Namespace = {std::move(RefB)}; InfoC->Namespace = {std::move(RefB)};
Generator::addInfoToIndex(Idx, InfoC.get()); Generator::addInfoToIndex(Idx, InfoC.get());
@ -34,9 +34,9 @@ TEST(GeneratorTest, emitIndex) {
auto InfoF = std::make_unique<Info>(); auto InfoF = std::make_unique<Info>();
InfoF->Name = "F"; InfoF->Name = "F";
InfoF->USR = serialize::hashUSR("6"); InfoF->USR = serialize::hashUSR("6");
Reference RefD = Reference("D"); Reference RefD = Reference(SymbolID(), "D");
RefD.USR = serialize::hashUSR("4"); RefD.USR = serialize::hashUSR("4");
Reference RefE = Reference("E"); Reference RefE = Reference(SymbolID(), "E");
RefE.USR = serialize::hashUSR("5"); RefE.USR = serialize::hashUSR("5");
InfoF->Namespace = {std::move(RefE), std::move(RefD)}; InfoF->Namespace = {std::move(RefE), std::move(RefD)};
Generator::addInfoToIndex(Idx, InfoF.get()); Generator::addInfoToIndex(Idx, InfoF.get());

View File

@ -152,7 +152,8 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
SmallString<16> PathTo; SmallString<16> PathTo;
llvm::sys::path::native("path/to", 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.TagType = TagTypeKind::TTK_Class;
I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo); I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@ -276,8 +277,9 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) {
SmallString<16> PathTo; SmallString<16> PathTo;
llvm::sys::path::native("path/to", PathTo); llvm::sys::path::native("path/to", PathTo);
I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo); I.ReturnType =
I.Params.emplace_back("int", PathTo, "P"); TypeInfo(Reference(EmptySID, "float", InfoType::IT_default, PathTo));
I.Params.emplace_back(TypeInfo("int", PathTo), "P");
I.IsMethod = true; I.IsMethod = true;
I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
@ -370,9 +372,9 @@ TEST(HTMLGeneratorTest, emitCommentHTML) {
FunctionInfo I; FunctionInfo I;
I.Name = "f"; I.Name = "f";
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "I"); I.Params.emplace_back(TypeInfo("int"), "I");
I.Params.emplace_back("int", "J"); I.Params.emplace_back(TypeInfo("int"), "J");
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
CommentInfo Top; CommentInfo Top;

View File

@ -85,7 +85,7 @@ TEST(MDGeneratorTest, emitRecordMD) {
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.Loc.emplace_back(12, 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.TagType = TagTypeKind::TTK_Class;
I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@ -154,8 +154,8 @@ TEST(MDGeneratorTest, emitFunctionMD) {
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "P"); I.Params.emplace_back(TypeInfo("int"), "P");
I.IsMethod = true; I.IsMethod = true;
I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
@ -211,9 +211,9 @@ TEST(MDGeneratorTest, emitCommentMD) {
FunctionInfo I; FunctionInfo I;
I.Name = "f"; I.Name = "f";
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "I"); I.Params.emplace_back(TypeInfo("int"), "I");
I.Params.emplace_back("int", "J"); I.Params.emplace_back(TypeInfo("int"), "J");
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
CommentInfo Top; CommentInfo Top;

View File

@ -83,7 +83,7 @@ TEST(MergeTest, mergeRecordInfos) {
One.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); 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.TagType = TagTypeKind::TTK_Class;
One.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); One.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
One.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); One.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@ -126,7 +126,8 @@ TEST(MergeTest, mergeRecordInfos) {
Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
Expected->Loc.emplace_back(12, 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->TagType = TagTypeKind::TTK_Class;
Expected->Parents.emplace_back(EmptySID, "F", InfoType::IT_record); Expected->Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
Expected->VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); Expected->VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@ -180,8 +181,8 @@ TEST(MergeTest, mergeFunctionInfos) {
Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
Two.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); Two.ReturnType = TypeInfo("void");
Two.Params.emplace_back("int", "P"); Two.Params.emplace_back(TypeInfo("int"), "P");
Two.Description.emplace_back(); Two.Description.emplace_back();
auto TwoFullComment = &Two.Description.back(); auto TwoFullComment = &Two.Description.back();
@ -205,8 +206,8 @@ TEST(MergeTest, mergeFunctionInfos) {
Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
Expected->Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); Expected->Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
Expected->ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); Expected->ReturnType = TypeInfo("void");
Expected->Params.emplace_back("int", "P"); Expected->Params.emplace_back(TypeInfo("int"), "P");
Expected->IsMethod = true; Expected->IsMethod = true;
Expected->Parent = Reference(EmptySID, "Parent", InfoType::IT_namespace); Expected->Parent = Reference(EmptySID, "Parent", InfoType::IT_namespace);

View File

@ -119,7 +119,7 @@ TEST(SerializeTest, emitNamespaceInfo) {
NamespaceInfo ExpectedBWithFunction(EmptySID); NamespaceInfo ExpectedBWithFunction(EmptySID);
FunctionInfo F; FunctionInfo F;
F.Name = "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.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace); F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace);
F.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); F.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
@ -165,7 +165,8 @@ typedef struct {} G;)raw",
InfoType::IT_namespace); InfoType::IT_namespace);
ExpectedE.TagType = TagTypeKind::TTK_Class; ExpectedE.TagType = TagTypeKind::TTK_Class;
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); 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: // TODO the data member should have the docstring on it:
//ExpectedE.Members.back().Description.push_back(MakeOneLineCommentInfo(" Some docs")); //ExpectedE.Members.back().Description.push_back(MakeOneLineCommentInfo(" Some docs"));
CheckRecordInfo(&ExpectedE, E); CheckRecordInfo(&ExpectedE, E);
@ -175,7 +176,7 @@ typedef struct {} G;)raw",
FunctionInfo EConstructor; FunctionInfo EConstructor;
EConstructor.Name = "E"; EConstructor.Name = "E";
EConstructor.Parent = Reference(EmptySID, "E", InfoType::IT_record); 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.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
EConstructor.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record); EConstructor.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
EConstructor.Namespace.emplace_back(EmptySID, "GlobalNamespace", EConstructor.Namespace.emplace_back(EmptySID, "GlobalNamespace",
@ -191,7 +192,7 @@ typedef struct {} G;)raw",
FunctionInfo Method; FunctionInfo Method;
Method.Name = "ProtectedMethod"; Method.Name = "ProtectedMethod";
Method.Parent = Reference(EmptySID, "E", InfoType::IT_record); 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.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
Method.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record); Method.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
Method.Namespace.emplace_back(EmptySID, "GlobalNamespace", Method.Namespace.emplace_back(EmptySID, "GlobalNamespace",
@ -214,7 +215,7 @@ typedef struct {} G;)raw",
FunctionInfo TemplateMethod; FunctionInfo TemplateMethod;
TemplateMethod.Name = "TemplateMethod"; TemplateMethod.Name = "TemplateMethod";
TemplateMethod.Parent = Reference(EmptySID, "F", InfoType::IT_record); 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.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
TemplateMethod.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record); TemplateMethod.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record);
TemplateMethod.Namespace.emplace_back(EmptySID, "GlobalNamespace", TemplateMethod.Namespace.emplace_back(EmptySID, "GlobalNamespace",
@ -231,8 +232,7 @@ typedef struct {} G;)raw",
SpecializedTemplateMethod.Name = "TemplateMethod"; SpecializedTemplateMethod.Name = "TemplateMethod";
SpecializedTemplateMethod.Parent = SpecializedTemplateMethod.Parent =
Reference(EmptySID, "F", InfoType::IT_record); Reference(EmptySID, "F", InfoType::IT_record);
SpecializedTemplateMethod.ReturnType = SpecializedTemplateMethod.ReturnType = TypeInfo("void");
TypeInfo(EmptySID, "void", InfoType::IT_default);
SpecializedTemplateMethod.Loc.emplace_back(0, SpecializedTemplateMethod.Loc.emplace_back(0,
llvm::SmallString<16>{"test.cpp"}); llvm::SmallString<16>{"test.cpp"});
SpecializedTemplateMethod.Namespace.emplace_back(EmptySID, "F", SpecializedTemplateMethod.Namespace.emplace_back(EmptySID, "F",
@ -306,7 +306,8 @@ TEST(SerializeTest, emitRecordMemberInfo) {
InfoType::IT_namespace); InfoType::IT_namespace);
ExpectedE.TagType = TagTypeKind::TTK_Struct; ExpectedE.TagType = TagTypeKind::TTK_Struct;
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); 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); CheckRecordInfo(&ExpectedE, E);
} }
@ -348,7 +349,7 @@ TEST(SerializeTest, emitPublicFunctionInternalInfo) {
NamespaceInfo ExpectedBWithFunction(EmptySID); NamespaceInfo ExpectedBWithFunction(EmptySID);
FunctionInfo F; FunctionInfo F;
F.Name = "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.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
F.Access = AccessSpecifier::AS_none; F.Access = AccessSpecifier::AS_none;
ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F));
@ -363,9 +364,9 @@ TEST(SerializeTest, emitInlinedFunctionInfo) {
NamespaceInfo ExpectedBWithFunction(EmptySID); NamespaceInfo ExpectedBWithFunction(EmptySID);
FunctionInfo F; FunctionInfo F;
F.Name = "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.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; F.Access = AccessSpecifier::AS_none;
ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F));
CheckNamespaceInfo(&ExpectedBWithFunction, BWithFunction); CheckNamespaceInfo(&ExpectedBWithFunction, BWithFunction);
@ -396,7 +397,8 @@ class J : public I<int> {} ;)raw",
InfoType::IT_namespace); InfoType::IT_namespace);
ExpectedG.TagType = TagTypeKind::TTK_Class; ExpectedG.TagType = TagTypeKind::TTK_Class;
ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); 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); CheckRecordInfo(&ExpectedG, G);
RecordInfo *E = InfoAsRecord(Infos[6].get()); RecordInfo *E = InfoAsRecord(Infos[6].get());
@ -412,9 +414,9 @@ class J : public I<int> {} ;)raw",
AccessSpecifier::AS_public, true); AccessSpecifier::AS_public, true);
FunctionInfo FunctionSet; FunctionInfo FunctionSet;
FunctionSet.Name = "set"; FunctionSet.Name = "set";
FunctionSet.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); FunctionSet.ReturnType = TypeInfo("void");
FunctionSet.Loc.emplace_back(); 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, "F", InfoType::IT_record);
FunctionSet.Namespace.emplace_back(EmptySID, "GlobalNamespace", FunctionSet.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace); InfoType::IT_namespace);
@ -426,7 +428,7 @@ class J : public I<int> {} ;)raw",
AccessSpecifier::AS_private, true); AccessSpecifier::AS_private, true);
FunctionInfo FunctionGet; FunctionInfo FunctionGet;
FunctionGet.Name = "get"; FunctionGet.Name = "get";
FunctionGet.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); FunctionGet.ReturnType = TypeInfo("int");
FunctionGet.DefLoc = Location(); FunctionGet.DefLoc = Location();
FunctionGet.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record); FunctionGet.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record);
FunctionGet.Namespace.emplace_back(EmptySID, "GlobalNamespace", FunctionGet.Namespace.emplace_back(EmptySID, "GlobalNamespace",
@ -434,7 +436,7 @@ class J : public I<int> {} ;)raw",
FunctionGet.Access = AccessSpecifier::AS_private; FunctionGet.Access = AccessSpecifier::AS_private;
FunctionGet.IsMethod = true; FunctionGet.IsMethod = true;
ExpectedE.Bases.back().ChildFunctions.emplace_back(std::move(FunctionGet)); 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); AccessSpecifier::AS_private);
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedE.TagType = TagTypeKind::TTK_Class; ExpectedE.TagType = TagTypeKind::TTK_Class;
@ -458,9 +460,9 @@ class J : public I<int> {} ;)raw",
AccessSpecifier::AS_private, false); AccessSpecifier::AS_private, false);
FunctionInfo FunctionSetNew; FunctionInfo FunctionSetNew;
FunctionSetNew.Name = "set"; FunctionSetNew.Name = "set";
FunctionSetNew.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); FunctionSetNew.ReturnType = TypeInfo("void");
FunctionSetNew.Loc.emplace_back(); 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, "F", InfoType::IT_record);
FunctionSetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace", FunctionSetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace); InfoType::IT_namespace);
@ -472,7 +474,7 @@ class J : public I<int> {} ;)raw",
AccessSpecifier::AS_private, false); AccessSpecifier::AS_private, false);
FunctionInfo FunctionGetNew; FunctionInfo FunctionGetNew;
FunctionGetNew.Name = "get"; FunctionGetNew.Name = "get";
FunctionGetNew.ReturnType = TypeInfo(EmptySID, "int", InfoType::IT_default); FunctionGetNew.ReturnType = TypeInfo("int");
FunctionGetNew.DefLoc = Location(); FunctionGetNew.DefLoc = Location();
FunctionGetNew.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record); FunctionGetNew.Namespace.emplace_back(EmptySID, "G", InfoType::IT_record);
FunctionGetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace", FunctionGetNew.Namespace.emplace_back(EmptySID, "GlobalNamespace",
@ -480,7 +482,7 @@ class J : public I<int> {} ;)raw",
FunctionGetNew.Access = AccessSpecifier::AS_private; FunctionGetNew.Access = AccessSpecifier::AS_private;
FunctionGetNew.IsMethod = true; FunctionGetNew.IsMethod = true;
ExpectedH.Bases.back().ChildFunctions.emplace_back(std::move(FunctionGetNew)); 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); AccessSpecifier::AS_private);
CheckRecordInfo(&ExpectedH, H); CheckRecordInfo(&ExpectedH, H);
@ -520,10 +522,10 @@ export double exportedModuleFunction(double y);)raw",
NamespaceInfo ExpectedBWithFunction(EmptySID); NamespaceInfo ExpectedBWithFunction(EmptySID);
FunctionInfo F; FunctionInfo F;
F.Name = "moduleFunction"; 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.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
F.Params.emplace_back("int", "x"); F.Params.emplace_back(TypeInfo("int"), "x");
F.Params.emplace_back("double", "d"); F.Params.emplace_back(TypeInfo("double"), "d");
F.Params.back().DefaultValue = "3.2 - 1.0"; F.Params.back().DefaultValue = "3.2 - 1.0";
F.Access = AccessSpecifier::AS_none; F.Access = AccessSpecifier::AS_none;
ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F)); ExpectedBWithFunction.ChildFunctions.emplace_back(std::move(F));
@ -533,9 +535,10 @@ export double exportedModuleFunction(double y);)raw",
NamespaceInfo ExpectedBWithExportedFunction(EmptySID); NamespaceInfo ExpectedBWithExportedFunction(EmptySID);
FunctionInfo ExportedF; FunctionInfo ExportedF;
ExportedF.Name = "exportedModuleFunction"; 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.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; ExportedF.Access = AccessSpecifier::AS_none;
ExpectedBWithExportedFunction.ChildFunctions.emplace_back( ExpectedBWithExportedFunction.ChildFunctions.emplace_back(
std::move(ExportedF)); std::move(ExportedF));

View File

@ -82,7 +82,7 @@ TEST(YAMLGeneratorTest, emitRecordYAML) {
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.Loc.emplace_back(12, 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); AccessSpecifier::AS_private);
// Member documentation. // Member documentation.
@ -102,7 +102,7 @@ TEST(YAMLGeneratorTest, emitRecordYAML) {
AccessSpecifier::AS_public, true); AccessSpecifier::AS_public, true);
I.Bases.back().ChildFunctions.emplace_back(); I.Bases.back().ChildFunctions.emplace_back();
I.Bases.back().ChildFunctions.back().Name = "InheritedFunctionOne"; 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); AccessSpecifier::AS_private);
// F is in the global namespace // F is in the global namespace
I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, ""); I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "");
@ -174,7 +174,6 @@ Bases:
Parents: Parents:
- Type: Record - Type: Record
Name: 'F' Name: 'F'
IsInGlobalNamespace: true
VirtualParents: VirtualParents:
- Type: Record - Type: Record
Name: 'G' Name: 'G'
@ -206,10 +205,10 @@ TEST(YAMLGeneratorTest, emitFunctionYAML) {
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
I.ReturnType = I.ReturnType = TypeInfo(
TypeInfo(EmptySID, "void", InfoType::IT_default, "path/to/void"); Reference(EmptySID, "void", InfoType::IT_default, "path/to/void"));
I.Params.emplace_back("int", "path/to/int", "P"); I.Params.emplace_back(TypeInfo("int", "path/to/int"), "P");
I.Params.emplace_back("double", "path/to/double", "D"); I.Params.emplace_back(TypeInfo("double", "path/to/double"), "D");
I.Params.back().DefaultValue = "2.0 * M_PI"; I.Params.back().DefaultValue = "2.0 * M_PI";
I.IsMethod = true; I.IsMethod = true;
I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
@ -335,9 +334,9 @@ TEST(YAMLGeneratorTest, emitCommentYAML) {
FunctionInfo I; FunctionInfo I;
I.Name = "f"; I.Name = "f";
I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); I.ReturnType = TypeInfo("void");
I.Params.emplace_back("int", "I"); I.Params.emplace_back(TypeInfo("int"), "I");
I.Params.emplace_back("int", "J"); I.Params.emplace_back(TypeInfo("int"), "J");
I.Access = AccessSpecifier::AS_none; I.Access = AccessSpecifier::AS_none;
CommentInfo Top; CommentInfo Top;