@@ -212,9 +212,7 @@ build()
212212 // declarations which satisfy all filter conditions.
213213 // dependencies will be tracked, but not extracted
214214 traverseAny (context_.getTranslationUnitDecl ());
215-
216- // Ensure the global namespace is always present
217- upsert<NamespaceInfo>(SymbolID::global);
215+ MRDOCS_ASSERT (find (SymbolID::global));
218216
219217 // Dependency extraction is disabled: we are done
220218 if (config_->referencedDeclarations ==
@@ -449,11 +447,7 @@ void
449447ASTVisitor::
450448traverse (UsingDirectiveDecl* D)
451449{
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));
457451
458452 Decl* PD = getParentDecl (D);
459453 bool const isNamespaceScope = cast<DeclContext>(PD)->isFileContext ();
@@ -713,6 +707,21 @@ populate(
713707 populateNamespaces (I, D);
714708}
715709
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+
716725void
717726ASTVisitor::
718727populate (
@@ -2624,6 +2633,12 @@ inExtractedFile(
26242633 }
26252634
26262635 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+ }
26272642 // KRYSTIAN NOTE: I'm unsure under what conditions
26282643 // this assert would fire.
26292644 MRDOCS_ASSERT (file);
@@ -2755,6 +2770,10 @@ ASTVisitor::FileInfo*
27552770ASTVisitor::
27562771findFileInfo (clang::SourceLocation const loc)
27572772{
2773+ if (loc.isInvalid ())
2774+ {
2775+ return nullptr ;
2776+ }
27582777 // KRYSTIAN FIXME: we really should not be
27592778 // calling getPresumedLoc this often,
27602779 // it's quite expensive
0 commit comments