Skip to content

Commit 0ca3e22

Browse files
committed
adoc work
1 parent 9d35f70 commit 0ca3e22

13 files changed

+289
-89
lines changed

source/api/AST/ASTVisitor.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,6 @@ WalkUpFromCXXRecordDecl(
175175
return true;
176176
}
177177

178-
bool
179-
ASTVisitor::
180-
WalkUpFromCXXDestructorDecl(
181-
CXXDestructorDecl* D)
182-
{
183-
mapDecl(D);
184-
return true;
185-
}
186-
187-
bool
188-
ASTVisitor::
189-
WalkUpFromCXXConstructorDecl(
190-
CXXConstructorDecl* D)
191-
{
192-
mapDecl(D);
193-
return true;
194-
}
195-
196178
bool
197179
ASTVisitor::
198180
WalkUpFromCXXMethodDecl(

source/api/AST/ASTVisitor.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class ASTVisitor
6969

7070
bool WalkUpFromNamespaceDecl(NamespaceDecl* D);
7171
bool WalkUpFromCXXRecordDecl(CXXRecordDecl* D);
72-
bool WalkUpFromCXXDestructorDecl(CXXDestructorDecl* D);
73-
bool WalkUpFromCXXConstructorDecl(CXXConstructorDecl* D);
7472
bool WalkUpFromCXXMethodDecl(CXXMethodDecl* D);
7573
bool WalkUpFromFriendDecl(FriendDecl* D);
7674
//bool WalkUpFromUsingDecl(UsingDecl* D);

source/api/AST/Serializer.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ getInfo(
334334
sr.PublicOnly, IsInAnonymousNamespace, D))
335335
return false;
336336
I.id = getUSRForDecl(D);
337-
I.Name = D->getNameAsString();
337+
//I.Name = D->getName();
338+
//if(I.Name.empty())
339+
I.Name = D->getNameAsString();
340+
//if(D->getName() != I.Name)
341+
//debug_outs() << D->getName() << ", " << I.Name << "\n";
338342
parseJavadoc(I.javadoc, D);
339343
return true;
340344
}
@@ -964,7 +968,13 @@ build(
964968
// Functions, Member Functions
965969
//
966970
//------------------------------------------------
971+
/*
972+
Types of member functions:
967973
974+
destructor
975+
constructor
976+
conversion operator
977+
*/
968978
// VFALCO could this be done in getFunctionInfo?
969979
// but getFunctionInfo is called parseBases()
970980
static
@@ -1007,12 +1017,18 @@ getFunctionSpecs(
10071017
//MF->isOverloadedOperator();
10081018
//MF->isStaticOverloadedOperator();
10091019

1010-
if(auto const Ctor = dyn_cast<CXXConstructorDecl>(MF))
1020+
if(auto const Dtor = dyn_cast<CXXDestructorDecl>(MF))
1021+
{
1022+
//I.Name.append("-dtor");
1023+
}
1024+
else if(auto const Ctor = dyn_cast<CXXConstructorDecl>(MF))
10111025
{
1026+
//I.Name.append("-ctor");
10121027
I.specs1.set<FnFlags1::isExplicit>(Ctor->getExplicitSpecifier().isSpecified());
10131028
}
10141029
else if(auto const Conv = dyn_cast<CXXConversionDecl>(MF))
10151030
{
1031+
//I.Name.append("-conv");
10161032
I.specs1.set<FnFlags1::isExplicit>(Conv->getExplicitSpecifier().isSpecified());
10171033
}
10181034
}
@@ -1065,8 +1081,6 @@ build(
10651081
InfoType::IT_record);
10661082
I.Access = D->getAccess();
10671083

1068-
getFunctionSpecs(I, D);
1069-
10701084
return { writeBitcode(I), writeParent(std::move(I)) };
10711085
}
10721086

source/api/Support/SafeNames.cpp

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "Support/Operator.hpp"
1212
#include "Support/SafeNames.hpp"
13+
#include "Support/Validate.hpp"
1314
#include <mrdox/Corpus.hpp>
1415
#include <mrdox/Metadata.hpp>
1516
#include <llvm/ADT/STLExtras.h>
@@ -19,9 +20,18 @@
1920
namespace clang {
2021
namespace mrdox {
2122

23+
/*
24+
Unsafe names:
25+
26+
destructors
27+
overloaded operators
28+
function templates
29+
class templates
30+
*/
2231
class SafeNames::
2332
Builder : public Corpus::Visitor
2433
{
34+
llvm::raw_ostream* os_ = nullptr;
2535
std::string prefix_;
2636
std::string temp_;
2737

@@ -33,8 +43,27 @@ class SafeNames::
3343
prefix_.reserve(512);
3444
corpus_.visit(globalNamespaceID, *this);
3545
map.try_emplace(llvm::toStringRef(EmptySID), std::string());
46+
47+
#ifndef NDEBUG
48+
//for(auto const& N : map)
49+
//Assert(validAdocSectionID(N.second));
50+
#endif
3651
}
3752

53+
Builder(
54+
llvm::raw_ostream& os,
55+
Corpus const& corpus)
56+
:
57+
//os_(&os),
58+
corpus_(corpus)
59+
{
60+
prefix_.reserve(512);
61+
corpus_.visit(globalNamespaceID, *this);
62+
map.try_emplace(llvm::toStringRef(EmptySID), std::string());
63+
if(os_)
64+
*os_ << "\n\n";
65+
}
66+
3867
llvm::StringMap<std::string> map;
3968

4069
private:
@@ -51,7 +80,8 @@ class SafeNames::
5180
scope.Records.size() +
5281
scope.Functions.size() +
5382
scope.Typedefs.size() +
54-
scope.Enums.size());
83+
scope.Enums.size() +
84+
scope.Variables.size());
5585
for(auto const& ref : scope.Namespaces)
5686
infos.emplace_back(corpus_.find(ref.id));
5787
for(auto const& ref : scope.Records)
@@ -62,6 +92,8 @@ class SafeNames::
6292
infos.emplace_back(corpus_.find(ref.id));
6393
for(auto const& ref : scope.Enums)
6494
infos.emplace_back(corpus_.find(ref.id));
95+
for(auto const& ref : scope.Variables)
96+
infos.emplace_back(corpus_.find(ref.id));
6597
if(infos.size() < 2)
6698
return infos;
6799
std::string s0, s1;
@@ -92,6 +124,25 @@ class SafeNames::
92124

93125
void insertScope(ScopeInfos const& infos)
94126
{
127+
if(os_)
128+
{
129+
std::string temp;
130+
if( infos.size() > 0 &&
131+
infos.front()->Namespace.size() > 0)
132+
{
133+
auto const& P = corpus_.get<Info>(infos.front()->Namespace[0].id);
134+
P.getFullyQualifiedName(temp);
135+
temp.push_back(' ');
136+
}
137+
*os_ <<
138+
"------------------------\n" <<
139+
"Scope " << temp <<
140+
"with " << infos.size() << " names:\n\n";
141+
for(auto const& I : infos)
142+
*os_ << I->Name << '\n';
143+
*os_ << '\n';
144+
}
145+
95146
auto it0 = infos.begin();
96147
while(it0 != infos.end())
97148
{
@@ -108,7 +159,9 @@ class SafeNames::
108159
std::string s;
109160
s.assign(prefix_);
110161
s.append(getSafe(**it0));
111-
map.try_emplace(
162+
if(os_)
163+
*os_ << getSafe(**it0) << "\n";
164+
auto result = map.try_emplace(
112165
llvm::toStringRef((*it0)->id),
113166
std::move(s));
114167
it0 = it;
@@ -119,10 +172,14 @@ class SafeNames::
119172
{
120173
std::string s;
121174
s.assign(prefix_);
122-
s.append(std::to_string(i + 1));
175+
std::string suffix;
176+
suffix = std::to_string(i + 1);
123177
//s.push_back('@');
124-
s.append(getSafe(**it0));
125-
map.try_emplace(
178+
suffix.append(getSafe(**it0));
179+
if(os_)
180+
*os_ << suffix << "\n";
181+
s.append(suffix);
182+
auto result = map.try_emplace(
126183
llvm::toStringRef(it0[i]->id),
127184
std::move(s));
128185
}
@@ -187,6 +244,15 @@ SafeNames(
187244
map_ = std::move(b.map);
188245
}
189246

247+
SafeNames::
248+
SafeNames(
249+
llvm::raw_ostream& os,
250+
Corpus const& corpus)
251+
{
252+
Builder b(os, corpus);
253+
map_ = std::move(b.map);
254+
}
255+
190256
llvm::StringRef
191257
SafeNames::
192258
get(

source/api/Support/SafeNames.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <mrdox/MetadataFwd.hpp>
1616
#include <llvm/ADT/SmallString.h>
1717
#include <llvm/ADT/StringMap.h>
18+
#include <llvm/Support/raw_ostream.h>
1819
#include <string>
1920

2021
namespace clang {
@@ -31,6 +32,10 @@ class SafeNames
3132
SafeNames(
3233
Corpus const&);
3334

35+
SafeNames(
36+
llvm::raw_ostream& os,
37+
Corpus const&);
38+
3439
llvm::StringRef
3540
get(SymbolID const& id) const;
3641

source/api/_XML/XMLWriter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ build()
6363
"<!DOCTYPE mrdox SYSTEM \"mrdox.dtd\">\n" <<
6464
"<mrdox>\n";
6565

66-
// VFALCO Do we even need this?
67-
//writeAllSymbols();
68-
6966
if(! corpus_.visit(globalNamespaceID, *this))
7067
{
7168
if(fd_os_ && fd_os_->error())

source/api/_adoc/AdocMultiPageWriter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ build(
6767
write(I);
6868
}
6969

70+
void
71+
AdocMultiPageWriter::
72+
build(
73+
VariableInfo const& I)
74+
{
75+
}
76+
7077
void
7178
AdocMultiPageWriter::
7279
writeTitle(Info const& I)

source/api/_adoc/AdocMultiPageWriter.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class AdocMultiPageWriter
3737
void build(FunctionInfo const&);
3838
void build(TypedefInfo const&);
3939
void build(EnumInfo const&);
40+
void build(VariableInfo const&);
4041

4142
void build(OverloadInfo const&);
4243

0 commit comments

Comments
 (0)