@@ -160,7 +160,7 @@ ASTVisitor::
160
160
traverse (UsingDirectiveDecl* D)
161
161
{
162
162
// Find the parent namespace
163
- ScopeExitRestore s1 (mode_, ExtractionMode ::Dependency);
163
+ ScopeExitRestore s1 (mode_, TraversalMode ::Dependency);
164
164
Decl* P = getParent (D);
165
165
MRDOCS_SYMBOL_TRACE (P, context_);
166
166
Info* PI = findOrTraverse (P);
@@ -171,7 +171,7 @@ traverse(UsingDirectiveDecl* D)
171
171
// Find the nominated namespace
172
172
Decl* ND = D->getNominatedNamespace ();
173
173
MRDOCS_SYMBOL_TRACE (ND, context_);
174
- ScopeExitRestore s2 (mode_, ExtractionMode ::Dependency);
174
+ ScopeExitRestore s2 (mode_, TraversalMode ::Dependency);
175
175
Info* NDI = findOrTraverse (ND);
176
176
MRDOCS_CHECK_OR (NDI, nullptr );
177
177
@@ -205,29 +205,35 @@ traverseMembers(InfoTy& I, DeclTy* DC)
205
205
std::derived_from<DeclTy, DeclContext>)
206
206
{
207
207
// We only need members of regular symbols and see-below namespaces
208
- // - SeeBelow symbols (that are not namespaces) are only the
209
- // symbol and the documentation.
210
- // - ImplementationDefined symbols have no pages
211
- // - Dependency symbols only need the names
212
- MRDOCS_CHECK_OR (
213
- I.Extraction == ExtractionMode::Regular ||
214
- I.Extraction == ExtractionMode::SeeBelow);
208
+ // - If symbol is SeeBelow we want the members if it's a namespace
215
209
MRDOCS_CHECK_OR (
216
210
I.Extraction != ExtractionMode::SeeBelow ||
217
211
I.Kind == InfoKind::Namespace);
218
212
219
- // Set the context for the members
220
- ScopeExitRestore s (mode_, I.Extraction );
213
+ // - If symbol is a Dependency, we only want the members if
214
+ // the traversal mode is BaseClass
215
+ MRDOCS_CHECK_OR (
216
+ I.Extraction != ExtractionMode::Dependency ||
217
+ mode_ == TraversalMode::BaseClass);
221
218
222
- // There are many implicit declarations in the
223
- // translation unit declaration, so we preemtively
224
- // skip them here.
219
+ // - If symbol is ImplementationDefined, we only want the members if
220
+ // the traversal mode is BaseClass
221
+ MRDOCS_CHECK_OR (
222
+ I.Extraction != ExtractionMode::ImplementationDefined ||
223
+ mode_ == TraversalMode::BaseClass);
224
+
225
+ // There are many implicit declarations, especially in the
226
+ // translation unit declaration, so we preemtively skip them here.
225
227
auto explicitMembers = std::ranges::views::filter (DC->decls (), [](Decl* D)
226
228
{
227
229
return !D->isImplicit () || isa<IndirectFieldDecl>(D);
228
230
});
229
231
for (auto * D : explicitMembers)
230
232
{
233
+ // No matter what happens in the process, we restore the
234
+ // traversal mode to the original mode for the next member
235
+ ScopeExitRestore s (mode_);
236
+ // Traverse the member
231
237
traverse (D);
232
238
}
233
239
}
@@ -259,12 +265,11 @@ traverseParents(InfoTy& I, DeclTy* DC)
259
265
// Check if we haven't already extracted or started
260
266
// to extract the parent scope
261
267
262
-
263
268
// Traverse the parent scope as a dependency if it
264
269
// hasn't been extracted yet
265
270
Info* PI = nullptr ;
266
271
{
267
- ScopeExitRestore s (mode_, ExtractionMode:: Dependency);
272
+ ScopeExitRestore s (mode_, Dependency);
268
273
if (PI = findOrTraverse (PD); !PI)
269
274
{
270
275
return ;
@@ -548,7 +553,7 @@ populateInfoBases(InfoTy& I, bool const isNew, DeclTy* D)
548
553
I.Extraction = ExtractionMode::Regular;
549
554
// default mode also becomes regular for its
550
555
// members
551
- mode_ = ExtractionMode ::Regular;
556
+ mode_ = TraversalMode ::Regular;
552
557
}
553
558
}
554
559
@@ -773,7 +778,7 @@ populate(
773
778
}
774
779
775
780
QualType const BT = B.getType ();
776
- auto BaseType = toTypeInfo (BT);
781
+ auto BaseType = toTypeInfo (BT, BaseClass );
777
782
778
783
// CXXBaseSpecifier::getEllipsisLoc indicates whether the
779
784
// base was a pack expansion; a PackExpansionType is not built
@@ -1210,10 +1215,9 @@ populate(
1210
1215
I.Qualifier = toNameInfo (D->getQualifier ());
1211
1216
for (UsingShadowDecl const * UDS: D->shadows ())
1212
1217
{
1213
- ScopeExitRestore s (mode_, ExtractionMode:: Dependency);
1218
+ ScopeExitRestore s (mode_, Dependency);
1214
1219
Decl* S = UDS->getTargetDecl ();
1215
- Info* SI = findOrTraverse (S);
1216
- if (SI)
1220
+ if (Info* SI = findOrTraverse (S))
1217
1221
{
1218
1222
I.UsingSymbols .emplace_back (SI->id );
1219
1223
}
@@ -1647,15 +1651,15 @@ generateJavadoc(
1647
1651
1648
1652
std::unique_ptr<TypeInfo>
1649
1653
ASTVisitor::
1650
- toTypeInfo (QualType const qt)
1654
+ toTypeInfo (QualType const qt, TraversalMode const mode )
1651
1655
{
1652
1656
MRDOCS_SYMBOL_TRACE (qt, context_);
1653
1657
1654
1658
// The qualified symbol referenced by a regular symbol is a dependency.
1655
1659
// For library types, can be proved wrong and the Info type promoted
1656
1660
// to a regular type later on if the type matches the regular
1657
1661
// extraction criteria
1658
- ScopeExitRestore s (mode_, ExtractionMode::Dependency );
1662
+ ScopeExitRestore s (mode_, mode );
1659
1663
1660
1664
// Build the TypeInfo representation for the type
1661
1665
TypeInfoBuilder Builder (*this );
@@ -1674,7 +1678,7 @@ toNameInfo(
1674
1678
}
1675
1679
MRDOCS_SYMBOL_TRACE (NNS, context_);
1676
1680
1677
- ScopeExitRestore scope (mode_,ExtractionMode:: Dependency);
1681
+ ScopeExitRestore scope (mode_, Dependency);
1678
1682
std::unique_ptr<NameInfo> I = nullptr ;
1679
1683
if (const Type* T = NNS->getAsType ())
1680
1684
{
@@ -1763,7 +1767,7 @@ toNameInfo(
1763
1767
{
1764
1768
return nullptr ;
1765
1769
}
1766
- ScopeExitRestore scope (mode_, ExtractionMode:: Dependency);
1770
+ ScopeExitRestore scope (mode_, Dependency);
1767
1771
auto * ID = getInstantiatedFrom (D);
1768
1772
if (Info const * info = findOrTraverse (const_cast <Decl*>(ID)))
1769
1773
{
@@ -2397,15 +2401,15 @@ shouldExtract(
2397
2401
MRDOCS_CHECK_OR (!isa<TranslationUnitDecl>(D), true );
2398
2402
2399
2403
// Check if this kind of symbol should be extracted.
2400
- // This filters symbols supported by mrdocs and
2404
+ // This filters symbols supported by MrDocs and
2401
2405
// symbol types whitelisted in the configuration,
2402
2406
// such as private members and anonymous namespaces.
2403
2407
MRDOCS_CHECK_OR (checkTypeFilters (D, access), false );
2404
2408
2405
2409
// In dependency mode, we don't need the file and symbol
2406
2410
// filters because this is a dependency of another
2407
2411
// declaration that passes the filters.
2408
- if (mode_ == ExtractionMode::Dependency )
2412
+ if (mode_ != TraversalMode::Regular )
2409
2413
{
2410
2414
// If the whole declaration is implicit, we should
2411
2415
// not promote the extraction mode to regular
@@ -2426,7 +2430,7 @@ shouldExtract(
2426
2430
if (checkSymbolFilters (D) &&
2427
2431
checkFileFilters (D))
2428
2432
{
2429
- mode_ = ExtractionMode ::Regular;
2433
+ mode_ = TraversalMode ::Regular;
2430
2434
}
2431
2435
// But we return true either way
2432
2436
return true ;
@@ -2477,7 +2481,7 @@ checkTypeFilters(Decl const* D, AccessSpecifier access)
2477
2481
// KRYSTIAN FIXME: is this correct? a namespace should not
2478
2482
// be extracted as a dependency (until namespace aliases and
2479
2483
// using directives are supported)
2480
- MRDOCS_CHECK_OR (mode_ == ExtractionMode ::Regular, false );
2484
+ MRDOCS_CHECK_OR (mode_ == TraversalMode ::Regular, false );
2481
2485
}
2482
2486
2483
2487
return true ;
@@ -2832,7 +2836,9 @@ upsert(SymbolID const& id)
2832
2836
{
2833
2837
info = info_.emplace (std::make_unique<
2834
2838
InfoTy>(id)).first ->get ();
2835
- info->Extraction = mostSpecific (info->Extraction , mode_);
2839
+ auto const minExtract = mode_ == TraversalMode::Regular ?
2840
+ ExtractionMode::Regular : ExtractionMode::Dependency;
2841
+ info->Extraction = mostSpecific (info->Extraction , minExtract);
2836
2842
}
2837
2843
MRDOCS_ASSERT (info->Kind == InfoTy::kind_id);
2838
2844
return {static_cast <InfoTy&>(*info), isNew};
@@ -2873,11 +2879,11 @@ upsert(DeclType* D)
2873
2879
// this time.
2874
2880
bool const previouslyExtractedAsDependency =
2875
2881
!isNew &&
2876
- mode_ != ExtractionMode ::Dependency &&
2882
+ mode_ != TraversalMode ::Dependency &&
2877
2883
I.Extraction == ExtractionMode::Dependency;
2878
2884
if (previouslyExtractedAsDependency)
2879
2885
{
2880
- I.Extraction = mostSpecific (I.Extraction , mode_ );
2886
+ I.Extraction = mostSpecific (I.Extraction , ExtractionMode::Regular );
2881
2887
isNew = true ;
2882
2888
}
2883
2889
0 commit comments