@@ -212,9 +212,7 @@ build()
212
212
// declarations which satisfy all filter conditions.
213
213
// dependencies will be tracked, but not extracted
214
214
traverseAny (context_.getTranslationUnitDecl ());
215
-
216
- // Ensure the global namespace is always present
217
- upsert<NamespaceInfo>(SymbolID::global);
215
+ MRDOCS_ASSERT (find (SymbolID::global));
218
216
219
217
// Dependency extraction is disabled: we are done
220
218
if (config_->referencedDeclarations ==
@@ -449,11 +447,7 @@ void
449
447
ASTVisitor::
450
448
traverse (UsingDirectiveDecl* D)
451
449
{
452
- // A using directive such as `using namespace std;`
453
- if (!shouldExtract (D, getAccess (D)))
454
- {
455
- return ;
456
- }
450
+ MRDOCS_CHECK_OR (shouldExtract (D));
457
451
458
452
Decl* PD = getParentDecl (D);
459
453
bool const isNamespaceScope = cast<DeclContext>(PD)->isFileContext ();
@@ -713,6 +707,21 @@ populate(
713
707
populateNamespaces (I, D);
714
708
}
715
709
710
+ void
711
+ ASTVisitor::
712
+ populate (
713
+ NamespaceInfo& I,
714
+ bool const isNew,
715
+ TranslationUnitDecl*)
716
+ {
717
+ // Only extract Namespace data once
718
+ MRDOCS_CHECK_OR (isNew);
719
+ I.id = SymbolID::global;
720
+ I.IsAnonymous = false ;
721
+ I.Name .clear ();
722
+ I.IsInline = false ;
723
+ }
724
+
716
725
void
717
726
ASTVisitor::
718
727
populate (
@@ -2624,6 +2633,12 @@ inExtractedFile(
2624
2633
}
2625
2634
2626
2635
FileInfo const * file = findFileInfo (D->getBeginLoc ());
2636
+ if (!file && isa<TranslationUnitDecl>(D))
2637
+ {
2638
+ // TranslationUnitDecl is a special case
2639
+ // that doesn't have a valid SourceLocation
2640
+ return true ;
2641
+ }
2627
2642
// KRYSTIAN NOTE: I'm unsure under what conditions
2628
2643
// this assert would fire.
2629
2644
MRDOCS_ASSERT (file);
@@ -2755,6 +2770,10 @@ ASTVisitor::FileInfo*
2755
2770
ASTVisitor::
2756
2771
findFileInfo (clang::SourceLocation const loc)
2757
2772
{
2773
+ if (loc.isInvalid ())
2774
+ {
2775
+ return nullptr ;
2776
+ }
2758
2777
// KRYSTIAN FIXME: we really should not be
2759
2778
// calling getPresumedLoc this often,
2760
2779
// it's quite expensive
0 commit comments