Skip to content

Commit aed34a1

Browse files
committed
functions are members of ASTVisitor
1 parent 5579004 commit aed34a1

File tree

2 files changed

+108
-33
lines changed

2 files changed

+108
-33
lines changed

source/lib/api/AST/ASTVisitor.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <clang/Index/USRGeneration.h>
2727
#include <clang/Lex/Lexer.h>
2828
#include <llvm/ADT/Hashing.h>
29-
#include <llvm/ADT/Optional.h>
3029
#include <llvm/ADT/StringExtras.h>
3130
#include <llvm/Support/Error.h>
3231
#include <llvm/Support/Path.h>
@@ -65,9 +64,9 @@ ASTVisitor(
6564
// a relatively small amount of memory (vs storing
6665
// USRs directly).
6766
//
68-
static
6967
SymbolID
70-
getUSRForDecl(
68+
ASTVisitor::
69+
getSymbolID(
7170
Decl const* D)
7271
{
7372
llvm::SmallString<128> USR;
@@ -78,8 +77,8 @@ getUSRForDecl(
7877

7978
//------------------------------------------------
8079

81-
static
8280
bool
81+
ASTVisitor::
8382
shouldSerializeInfo(
8483
bool PublicOnly,
8584
bool IsInAnonymousNamespace,
@@ -106,8 +105,8 @@ shouldSerializeInfo(
106105

107106
//------------------------------------------------
108107

109-
static
110108
void
109+
ASTVisitor::
111110
getParent(
112111
SymbolID& parent,
113112
Decl const* D)
@@ -121,19 +120,19 @@ getParent(
121120
{
122121
isParentAnonymous = true;
123122
}
124-
parent = getUSRForDecl(N);
123+
parent = getSymbolID(N);
125124
}
126125
else if(auto const* N = dyn_cast<RecordDecl>(DC))
127126
{
128-
parent = getUSRForDecl(N);
127+
parent = getSymbolID(N);
129128
}
130129
else if(auto const* N = dyn_cast<FunctionDecl>(DC))
131130
{
132-
parent = getUSRForDecl(N);
131+
parent = getSymbolID(N);
133132
}
134133
else if(auto const* N = dyn_cast<EnumDecl>(DC))
135134
{
136-
parent = getUSRForDecl(N);
135+
parent = getSymbolID(N);
137136
}
138137
else
139138
{
@@ -142,8 +141,8 @@ getParent(
142141
(void)isParentAnonymous;
143142
}
144143

145-
static
146144
void
145+
ASTVisitor::
147146
getParentNamespaces(
148147
llvm::SmallVector<Reference, 4>& Namespaces,
149148
Decl const* D,
@@ -166,28 +165,28 @@ getParentNamespaces(
166165
Namespace = N->getNameAsString();
167166
}
168167
Namespaces.emplace_back(
169-
getUSRForDecl(N),
168+
getSymbolID(N),
170169
Namespace,
171170
InfoType::IT_namespace);
172171
}
173172
else if(auto const* N = dyn_cast<RecordDecl>(DC))
174173
{
175174
Namespaces.emplace_back(
176-
getUSRForDecl(N),
175+
getSymbolID(N),
177176
N->getNameAsString(),
178177
InfoType::IT_record);
179178
}
180179
else if(auto const* N = dyn_cast<FunctionDecl>(DC))
181180
{
182181
Namespaces.emplace_back(
183-
getUSRForDecl(N),
182+
getSymbolID(N),
184183
N->getNameAsString(),
185184
InfoType::IT_function);
186185
}
187186
else if(auto const* N = dyn_cast<EnumDecl>(DC))
188187
{
189188
Namespaces.emplace_back(
190-
getUSRForDecl(N),
189+
getSymbolID(N),
191190
N->getNameAsString(),
192191
InfoType::IT_enum);
193192
}
@@ -212,8 +211,8 @@ getParentNamespaces(
212211

213212
//------------------------------------------------
214213

215-
static
216214
std::string
215+
ASTVisitor::
217216
getSourceCode(
218217
Decl const* D,
219218
SourceRange const& R)
@@ -226,8 +225,8 @@ getSourceCode(
226225

227226
//------------------------------------------------
228227

229-
static
230228
Access
229+
ASTVisitor::
231230
getAccessFromSpecifier(
232231
AccessSpecifier as) noexcept
233232
{
@@ -244,8 +243,8 @@ getAccessFromSpecifier(
244243
}
245244
}
246245

247-
static
248246
TagDecl*
247+
ASTVisitor::
249248
getTagDeclForType(
250249
QualType const& T)
251250
{
@@ -254,8 +253,8 @@ getTagDeclForType(
254253
return nullptr;
255254
}
256255

257-
static
258256
RecordDecl*
257+
ASTVisitor::
259258
getRecordDeclForType(
260259
QualType const& T)
261260
{
@@ -264,8 +263,8 @@ getRecordDeclForType(
264263
return nullptr;
265264
}
266265

267-
static
268266
TypeInfo
267+
ASTVisitor::
269268
getTypeInfoForType(
270269
QualType const& T)
271270
{
@@ -283,11 +282,11 @@ getTypeInfoForType(
283282
else
284283
IT = InfoType::IT_default;
285284
return TypeInfo(Reference(
286-
getUSRForDecl(TD), TD->getNameAsString(), IT));
285+
getSymbolID(TD), TD->getNameAsString(), IT));
287286
}
288287

289-
static
290288
void
289+
ASTVisitor::
291290
parseParameters(
292291
FunctionInfo& I,
293292
FunctionDecl const* D)
@@ -308,6 +307,7 @@ parseParameters(
308307
}
309308

310309
void
310+
ASTVisitor::
311311
getTemplateParams(
312312
llvm::Optional<TemplateInfo>& TemplateInfo,
313313
const Decl* D)
@@ -326,9 +326,9 @@ getTemplateParams(
326326
}
327327
}
328328

329-
static
330329
void
331-
parseJavadoc(
330+
ASTVisitor::
331+
parseRawComment(
332332
llvm::Optional<Javadoc>& javadoc,
333333
Decl const* D,
334334
Reporter& R)
@@ -350,15 +350,15 @@ parseJavadoc(
350350

351351
//------------------------------------------------
352352

353-
static
354353
void
354+
ASTVisitor::
355355
getMemberTypeInfo(
356356
MemberTypeInfo& I,
357357
FieldDecl const* D,
358358
Reporter& R)
359359
{
360360
Assert(D && "Expect non-null FieldDecl in getMemberTypeInfo");
361-
parseJavadoc(I.javadoc, D, R);
361+
parseRawComment(I.javadoc, D, R);
362362

363363
for (auto attr : D->attrs())
364364
{
@@ -510,8 +510,8 @@ writeParent(
510510
return writeBitcode(P);
511511
}
512512

513-
static
514513
void
514+
ASTVisitor::
515515
parseFields(
516516
RecordInfo& I,
517517
const RecordDecl* D,
@@ -534,8 +534,8 @@ parseFields(
534534
}
535535
}
536536

537-
static
538537
void
538+
ASTVisitor::
539539
parseEnumerators(
540540
EnumInfo& I,
541541
const EnumDecl* D)
@@ -640,7 +640,7 @@ extractInfo(
640640
if(! extractSymbolID(I.id, D))
641641
return false;
642642
I.Name = D->getNameAsString();
643-
parseJavadoc(I.javadoc, D, R_);
643+
parseRawComment(I.javadoc, D, R_);
644644
return true;
645645
}
646646

@@ -685,15 +685,15 @@ extractBases(
685685
{
686686
TemplateDecl const* D = Ty->getTemplateName().getAsTemplateDecl();
687687
I.Bases.emplace_back(
688-
getUSRForDecl(D),
688+
getSymbolID(D),
689689
B.getType().getAsString(),
690690
getAccessFromSpecifier(B.getAccessSpecifier()),
691691
isVirtual);
692692
}
693693
else if(RecordDecl const* P = getRecordDeclForType(B.getType()))
694694
{
695695
I.Bases.emplace_back(
696-
getUSRForDecl(P),
696+
getSymbolID(P),
697697
P->getNameAsString(),
698698
getAccessFromSpecifier(B.getAccessSpecifier()),
699699
isVirtual);
@@ -742,7 +742,7 @@ constructFunction(
742742
I.Template->Specialization.emplace();
743743
auto& Specialization = *I.Template->Specialization;
744744

745-
Specialization.SpecializationOf = getUSRForDecl(FTSI->getTemplate());
745+
Specialization.SpecializationOf = getSymbolID(FTSI->getTemplate());
746746

747747
// Template parameters to the specialization.
748748
if(FTSI->TemplateArguments)
@@ -917,12 +917,12 @@ buildRecord(
917917
if(SpecOf.is<ClassTemplateDecl*>())
918918
{
919919
Specialization.SpecializationOf =
920-
getUSRForDecl(SpecOf.get<ClassTemplateDecl*>());
920+
getSymbolID(SpecOf.get<ClassTemplateDecl*>());
921921
}
922922
else if(SpecOf.is<ClassTemplatePartialSpecializationDecl*>())
923923
{
924924
Specialization.SpecializationOf =
925-
getUSRForDecl(SpecOf.get<ClassTemplatePartialSpecializationDecl*>());
925+
getSymbolID(SpecOf.get<ClassTemplatePartialSpecializationDecl*>());
926926
}
927927

928928
// Parameters to the specilization. For partial specializations, get the

source/lib/api/AST/ASTVisitor.hpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#include "api/ConfigImpl.hpp"
1616
#include <mrdox/Reporter.hpp>
1717
#include <mrdox/MetadataFwd.hpp>
18+
#include <mrdox/Metadata/Access.hpp>
1819
#include <clang/AST/RecursiveASTVisitor.h>
1920
#include <clang/Tooling/Execution.h>
21+
#include <llvm/ADT/Optional.h>
2022
#include <unordered_map>
2123

2224
namespace clang {
@@ -70,6 +72,79 @@ class ASTVisitor
7072
ConfigImpl const& config,
7173
Reporter& R) noexcept;
7274

75+
SymbolID getSymbolID(Decl const* D);
76+
77+
bool shouldSerializeInfo(
78+
bool PublicOnly,
79+
bool IsInAnonymousNamespace,
80+
NamedDecl const* D) noexcept;
81+
82+
void
83+
getParent(
84+
SymbolID& parent,
85+
Decl const* D);
86+
87+
void
88+
getParentNamespaces(
89+
llvm::SmallVector<Reference, 4>& Namespaces,
90+
Decl const* D,
91+
bool& IsInAnonymousNamespace);
92+
93+
std::string
94+
getSourceCode(
95+
Decl const* D,
96+
SourceRange const& R);
97+
98+
Access
99+
getAccessFromSpecifier(
100+
AccessSpecifier as) noexcept;
101+
102+
TagDecl*
103+
getTagDeclForType(
104+
QualType const& T);
105+
106+
RecordDecl*
107+
getRecordDeclForType(
108+
QualType const& T);
109+
110+
TypeInfo
111+
getTypeInfoForType(
112+
QualType const& T);
113+
114+
void
115+
parseParameters(
116+
FunctionInfo& I,
117+
FunctionDecl const* D);
118+
119+
void
120+
getTemplateParams(
121+
llvm::Optional<TemplateInfo>& TemplateInfo,
122+
const Decl* D);
123+
void
124+
parseRawComment(
125+
llvm::Optional<Javadoc>& javadoc,
126+
Decl const* D,
127+
Reporter& R);
128+
129+
void
130+
getMemberTypeInfo(
131+
MemberTypeInfo& I,
132+
FieldDecl const* D,
133+
Reporter& R);
134+
135+
void
136+
parseFields(
137+
RecordInfo& I,
138+
const RecordDecl* D,
139+
bool PublicOnly,
140+
AccessSpecifier Access,
141+
Reporter& R);
142+
143+
void
144+
parseEnumerators(
145+
EnumInfo& I,
146+
const EnumDecl* D);
147+
73148
public://private:
74149
bool shouldExtract(Decl const* D);
75150
bool extractSymbolID(SymbolID& id, NamedDecl const* D);

0 commit comments

Comments
 (0)