Skip to content

Commit 550a350

Browse files
committed
flatten structure of functions in Scope
1 parent 91f5894 commit 550a350

File tree

11 files changed

+25
-210
lines changed

11 files changed

+25
-210
lines changed

source/lib/AsciidocGenerator.cpp

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void
366366
listFunctions(
367367
Config const& cfg,
368368
llvm::StringRef label,
369-
FunctionList const& v,
369+
std::vector<FunctionInfo> const& v,
370370
llvm::raw_ostream& os)
371371
{
372372
if(v.empty())
@@ -380,16 +380,16 @@ listFunctions(
380380
"|Description\n" <<
381381
"\n";
382382
os <<
383-
"|`" << v.front().name << "`\n" <<
384-
"|" << v.front().front().javadoc.brief <<
383+
"|`" << v.front().Name << "`\n" <<
384+
"|" << v.front().javadoc.brief <<
385385
"\n";
386386
for(std::size_t i = 1; i < v.size(); ++i)
387387
{
388388
auto const& f = v[i];
389389
os <<
390390
"\n" <<
391-
"|`" << f.name << "`\n" <<
392-
"|" << f.front().javadoc.brief <<
391+
"|`" << f.Name << "`\n" <<
392+
"|" << f.javadoc.brief <<
393393
"\n";
394394
}
395395
os <<
@@ -473,7 +473,7 @@ listScope(
473473
{
474474
listNamespaces(cfg, scope.Namespaces, os);
475475
listClasses(cfg, scope.Records, os);
476-
listFunctions(cfg, "Functions", scope.functions, os);
476+
listFunctions(cfg, "Functions", scope.Functions, os);
477477
listConstants(cfg, scope.Enums, os);
478478
listTypedefs(cfg, scope.Typedefs, os);
479479
}
@@ -490,37 +490,6 @@ listFunction(
490490
"|" << I.javadoc.brief << "\n";
491491
}
492492

493-
void
494-
listFunctions(
495-
Config const& cfg,
496-
llvm::StringRef label,
497-
std::vector<FunctionInfo> const& v,
498-
llvm::raw_ostream& os)
499-
{
500-
if(v.empty())
501-
return;
502-
503-
section(label, 2, os);
504-
os <<
505-
"[cols=2]\n" <<
506-
"|===\n" <<
507-
"|Name\n" <<
508-
"|Description\n" <<
509-
"\n";
510-
if(! v.empty())
511-
{
512-
listFunction(cfg, v.front(), os);
513-
for(std::size_t i = 1; i < v.size(); ++i)
514-
{
515-
os << "\n";
516-
listFunction(cfg, v[i], os);
517-
}
518-
}
519-
os <<
520-
"|===\n" <<
521-
"\n";
522-
}
523-
524493
// Write a complete FunctionInfo page
525494
void
526495
emitFunction(

source/lib/BitcodeReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ addChild(
651651
NamespaceInfo* I,
652652
FunctionInfo&& R)
653653
{
654-
I->Children.functions.insert(std::move(R));
654+
I->Children.Functions.emplace_back(std::move(R));
655655
}
656656

657657
template<>
@@ -679,7 +679,7 @@ addChild(
679679
RecordInfo* I,
680680
FunctionInfo&& R)
681681
{
682-
I->Children.functions.insert(std::move(R));
682+
I->Children.Functions.emplace_back(std::move(R));
683683
}
684684

685685
template<>
@@ -725,7 +725,7 @@ addChild(
725725
BaseRecordInfo* I,
726726
FunctionInfo&& R)
727727
{
728-
I->Children.functions.insert(std::move(R));
728+
I->Children.Functions.emplace_back(std::move(R));
729729
}
730730

731731
// TemplateParam children. These go into either a TemplateInfo (for template

source/lib/BitcodeWriter.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,8 @@ void ClangDocBitcodeWriter::emitBlock(const NamespaceInfo& I) {
527527
emitBlock(C, FieldId::F_child_namespace);
528528
for (const auto& C : I.Children.Records)
529529
emitBlock(C, FieldId::F_child_record);
530-
for (auto const& f : I.Children.functions)
531-
for (auto const& C : f)
532-
emitBlock(C);
530+
for (auto const& C : I.Children.Functions)
531+
emitBlock(C);
533532
for (const auto& C : I.Children.Enums)
534533
emitBlock(C);
535534
for (const auto& C : I.Children.Typedefs)
@@ -589,9 +588,8 @@ void ClangDocBitcodeWriter::emitBlock(const RecordInfo& I) {
589588
emitBlock(PB);
590589
for (const auto& C : I.Children.Records)
591590
emitBlock(C, FieldId::F_child_record);
592-
for (auto const& f : I.Children.functions)
593-
for (auto const& C : f)
594-
emitBlock(C);
591+
for (auto const& C : I.Children.Functions)
592+
emitBlock(C);
595593
for (const auto& C : I.Children.Enums)
596594
emitBlock(C);
597595
for (const auto& C : I.Children.Typedefs)
@@ -611,9 +609,8 @@ void ClangDocBitcodeWriter::emitBlock(const BaseRecordInfo& I) {
611609
emitRecord(I.IsParent, BASE_RECORD_IS_PARENT);
612610
for (const auto& M : I.Members)
613611
emitBlock(M);
614-
for (auto const& f : I.Children.functions)
615-
for (auto const& C : f)
616-
emitBlock(C);
612+
for (auto const& C : I.Children.Functions)
613+
emitBlock(C);
617614
}
618615

619616
void ClangDocBitcodeWriter::emitBlock(const FunctionInfo& I) {

source/lib/Corpus.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ build(
254254

255255
llvm::outs() <<
256256
"Collected " << corpus.USRToInfo.size() << " symbols.\n";
257-
for(auto const& it : corpus.USRToInfo)
258-
llvm::outs() << it.second.get()->Name << "\n";
259257

260258
if(GotFailure)
261259
{

source/lib/Function.cpp

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,96 +16,6 @@
1616
namespace clang {
1717
namespace mrdox {
1818

19-
// we assume that there are 4 access controls
20-
static_assert(
21-
AccessSpecifier::AS_none >
22-
AccessSpecifier::AS_private);
23-
static_assert(
24-
AccessSpecifier::AS_none >
25-
AccessSpecifier::AS_protected);
26-
static_assert(
27-
AccessSpecifier::AS_none >
28-
AccessSpecifier::AS_public);
29-
30-
//------------------------------------------------
31-
32-
void
33-
FunctionOverloads::
34-
insert(
35-
FunctionInfo I)
36-
{
37-
assert(I.Name == name);
38-
v_.emplace_back(std::move(I));
39-
}
40-
41-
void
42-
FunctionOverloads::
43-
merge(
44-
FunctionOverloads&& other)
45-
{
46-
reduceChildren(
47-
v_, std::move(other.v_));
48-
}
49-
50-
FunctionOverloads::
51-
FunctionOverloads(
52-
FunctionInfo I)
53-
: name(I.Name)
54-
{
55-
v_.emplace_back(std::move(I));
56-
}
57-
58-
//------------------------------------------------
59-
60-
void
61-
FunctionList::
62-
insert(
63-
FunctionInfo I)
64-
{
65-
//assert(I.Access == access);
66-
auto it = find(I.Name);
67-
if(it != end())
68-
{
69-
// new function
70-
it->insert(std::move(I));
71-
return;
72-
}
73-
74-
// overloaded function
75-
v_.emplace_back(std::move(I));
76-
}
77-
78-
void
79-
FunctionList::
80-
merge(
81-
FunctionList&& other)
82-
{
83-
for(auto& v : *this)
84-
{
85-
auto it = other.find(v.name);
86-
if(it == other.end())
87-
continue;
88-
v.merge(std::move(*it));
89-
other.v_.erase(it);
90-
}
91-
for(auto& v : other)
92-
v_.emplace_back(std::move(v));
93-
other.v_.clear();
94-
}
95-
96-
auto
97-
FunctionList::
98-
find(
99-
llvm::StringRef name) noexcept ->
100-
iterator
101-
{
102-
auto it = begin();
103-
for(;it != end(); ++it)
104-
if(it->name == name)
105-
return it;
106-
return it;
107-
}
108-
10919
} // mrdox
11020
} // clang
11121

source/lib/Function.hpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -63,54 +63,6 @@ struct FunctionInfo : SymbolInfo
6363
llvm::Optional<TemplateInfo> Template;
6464
};
6565

66-
/// A list of zero or more functions
67-
using FunctionInfos = std::vector<FunctionInfo>;
68-
69-
//------------------------------------------------
70-
71-
/** A list of overloads for a function.
72-
*/
73-
struct FunctionOverloads
74-
: List<FunctionInfo>
75-
{
76-
/// The name of the function.
77-
UnqualifiedName name;
78-
79-
void insert(FunctionInfo I);
80-
void merge(FunctionOverloads&& other);
81-
FunctionOverloads(FunctionInfo I);
82-
83-
FunctionOverloads(
84-
FunctionOverloads&&) = default;
85-
FunctionOverloads& operator=(
86-
FunctionOverloads&&) = default;
87-
};
88-
89-
//------------------------------------------------
90-
91-
/** A list of functions, each with possible overloads.
92-
*/
93-
struct FunctionList
94-
: List<FunctionOverloads>
95-
{
96-
clang::AccessSpecifier access;
97-
98-
void insert(FunctionInfo I);
99-
void merge(FunctionList&& other);
100-
101-
FunctionList(
102-
FunctionList&&) noexcept = default;
103-
FunctionList(
104-
clang::AccessSpecifier access_ =
105-
clang::AccessSpecifier::AS_public) noexcept
106-
: access(access_)
107-
{
108-
}
109-
110-
private:
111-
iterator find(llvm::StringRef name) noexcept;
112-
};
113-
11466
//------------------------------------------------
11567

11668
} // mrdox

source/lib/Namespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ merge(NamespaceInfo&& Other)
4040
// Reduce children if necessary.
4141
reduceChildren(Children.Namespaces, std::move(Other.Children.Namespaces));
4242
reduceChildren(Children.Records, std::move(Other.Children.Records));
43-
Children.functions.merge(std::move(Other.Children.functions));
43+
reduceChildren(Children.Functions, std::move(Other.Children.Functions));
4444
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
4545
reduceChildren(Children.Typedefs, std::move(Other.Children.Typedefs));
4646
mergeBase(std::move(Other));

source/lib/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ merge(RecordInfo&& Other)
4444
VirtualParents = std::move(Other.VirtualParents);
4545
// Reduce children if necessary.
4646
reduceChildren(Children.Records, std::move(Other.Children.Records));
47-
Children.functions.merge(std::move(Other.Children.functions));
47+
reduceChildren(Children.Functions, std::move(Other.Children.Functions));
4848
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
4949
reduceChildren(Children.Typedefs, std::move(Other.Children.Typedefs));
5050
SymbolInfo::merge(std::move(Other));

source/lib/Scope.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ struct Scope
4040
// this general for all possible container types reduces code complexity.
4141
std::vector<Reference> Namespaces;
4242
std::vector<Reference> Records;
43-
FunctionList functions;
43+
std::vector<FunctionInfo> Functions;
4444
std::vector<EnumInfo> Enums;
4545
std::vector<TypedefInfo> Typedefs;
4646

4747
Scope(
4848
clang::AccessSpecifier access_ =
4949
clang::AccessSpecifier::AS_public) noexcept
5050
: access(access_)
51-
, functions(access_)
5251
{
5352
}
5453
};

source/lib/Serialize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ InsertChild(
234234
Scope& scope,
235235
FunctionInfo Info)
236236
{
237-
scope.functions.insert(std::move(Info));
237+
scope.Functions.emplace_back(std::move(Info));
238238
}
239239

240240
static void InsertChild(Scope& scope, TypedefInfo Info) {
@@ -628,7 +628,7 @@ parseBases(RecordInfo& I, const CXXRecordDecl* D, bool IsFileInRootDir,
628628
IsInAnonymousNamespace);
629629
FI.Access =
630630
getFinalAccessSpecifier(BI.Access, MD->getAccessUnsafe());
631-
BI.Children.functions.insert(std::move(FI));
631+
BI.Children.Functions.emplace_back(std::move(FI));
632632
}
633633
I.Bases.emplace_back(std::move(BI));
634634
// Call this function recursively to get the inherited classes of

0 commit comments

Comments
 (0)