@@ -555,17 +555,6 @@ class TerminalTypeVisitor
555555 return true ;
556556 }
557557
558- bool
559- VisitDependentTemplateSpecializationType (
560- clang::DependentTemplateSpecializationType const * T)
561- {
562- MRDOCS_SYMBOL_TRACE (T, Visitor_.context_ );
563- const clang::DependentTemplateStorage &S = T->getDependentTemplateName ();
564- getDerived ().buildTerminal (S.getQualifier (), S.getName ().getIdentifier (),
565- T->template_arguments (), Quals_, IsPack_);
566- return true ;
567- }
568-
569558 // Visit a template specialization such as `A<T>`
570559 bool
571560 VisitTemplateSpecializationType (
@@ -589,31 +578,44 @@ class TerminalTypeVisitor
589578
590579 // The list of template parameters and a reference to
591580 // the templated scoped declaration
592- clang::NamedDecl* D = TN.getAsTemplateDecl ();
593- MRDOCS_SYMBOL_TRACE (TN, Visitor_.context_ );
594-
595- if (!T->isTypeAlias ())
581+ clang::NamedDecl* D = nullptr ;
582+ if (auto * CT = dyn_cast<clang::TagType>(T->getCanonicalTypeInternal ());
583+ !T->isTypeAlias () && CT)
596584 {
597- if (auto * CT = dyn_cast<clang::TagType>(T->getCanonicalTypeInternal ()))
598- {
599- MRDOCS_SYMBOL_TRACE (CT, Visitor_.context_ );
600- D = CT->getOriginalDecl ()->getDefinitionOrSelf ();
601- MRDOCS_SYMBOL_TRACE (D, Visitor_.context_ );
602- }
585+ MRDOCS_SYMBOL_TRACE (CT, Visitor_.context_ );
586+ D = CT->getDecl ()->getDefinitionOrSelf ();
587+ MRDOCS_SYMBOL_TRACE (D, Visitor_.context_ );
588+ }
589+ else
590+ {
591+ D = TN.getAsTemplateDecl (/* IgnoreDeduced=*/ true );
592+ }
593+ if (D)
594+ {
595+ getDerived ().buildTerminal (
596+ TN.getQualifier (),
597+ D,
598+ T->template_arguments (),
599+ Quals_,
600+ IsPack_);
601+ }
602+ else if (auto const * S = TN.getAsDependentTemplateName ())
603+ {
604+ getDerived ().buildTerminal (
605+ S->getQualifier (),
606+ S->getName ().getIdentifier (),
607+ T->template_arguments (),
608+ Quals_,
609+ IsPack_);
603610 }
604-
605- getDerived ().buildTerminal (
606- TN.getQualifier (), D,
607- T->template_arguments (),
608- Quals_, IsPack_);
609611 return true ;
610612 }
611613
612614 bool
613615 VisitRecordType (
614616 clang::RecordType const * T)
615617 {
616- clang::RecordDecl* RD = T->getOriginalDecl ()->getDefinitionOrSelf ();
618+ clang::RecordDecl* RD = T->getDecl ()->getDefinitionOrSelf ();
617619 // if this is an instantiation of a class template,
618620 // create a SpecializationType & extract the template arguments
619621 Optional<llvm::ArrayRef<clang::TemplateArgument>> TArgs = std::nullopt ;
@@ -630,7 +632,7 @@ class TerminalTypeVisitor
630632 VisitInjectedClassNameType (
631633 clang::InjectedClassNameType const * T)
632634 {
633- getDerived ().buildTerminal (T->getQualifier (), T->getOriginalDecl ()->getDefinitionOrSelf (),
635+ getDerived ().buildTerminal (T->getQualifier (), T->getDecl ()->getDefinitionOrSelf (),
634636 std::nullopt , Quals_, IsPack_);
635637 return true ;
636638 }
@@ -639,7 +641,7 @@ class TerminalTypeVisitor
639641 VisitEnumType (
640642 clang::EnumType const * T)
641643 {
642- getDerived ().buildTerminal (T->getQualifier (), T->getOriginalDecl ()->getDefinitionOrSelf (),
644+ getDerived ().buildTerminal (T->getQualifier (), T->getDecl ()->getDefinitionOrSelf (),
643645 std::nullopt , Quals_, IsPack_);
644646 return true ;
645647 }
0 commit comments