@@ -1474,12 +1474,17 @@ TemplateTemplateParameter* Parser::WalkTemplateTemplateParameter(const clang::Te
14741474 if (TP)
14751475 return TP;
14761476
1477+ auto NS = GetNamespace (TTP);
1478+ assertm (NS, " Expected a valid namespace!\n " );
1479+
14771480 TP = new TemplateTemplateParameter ();
14781481 HandleDeclaration (TTP, TP);
1482+ TP->_namespace = NS;
14791483 TP->Parameters = WalkTemplateParameterList (TTP->getTemplateParameters ());
14801484 TP->isParameterPack = TTP->isParameterPack ();
14811485 TP->isPackExpansion = TTP->isPackExpansion ();
14821486 TP->isExpandedParameterPack = TTP->isExpandedParameterPack ();
1487+
14831488 if (TTP->getTemplatedDecl ())
14841489 {
14851490 auto TD = WalkDeclaration (TTP->getTemplatedDecl ());
@@ -1499,6 +1504,10 @@ TypeTemplateParameter* Parser::WalkTypeTemplateParameter(const clang::TemplateTy
14991504
15001505 TP = new TypeTemplateParameter ();
15011506 TP->name = GetDeclName (TTPD);
1507+ auto NS = GetNamespace (TTPD);
1508+ assertm (NS, " Expected a valid namespace!\n " );
1509+ TP->_namespace = NS;
1510+
15021511 HandleDeclaration (TTPD, TP);
15031512 if (TTPD->hasDefaultArgument ())
15041513 TP->defaultArgument = GetQualifiedType (TTPD->getDefaultArgument ());
@@ -1519,6 +1528,10 @@ NonTypeTemplateParameter* Parser::WalkNonTypeTemplateParameter(const clang::NonT
15191528
15201529 NTP = new NonTypeTemplateParameter ();
15211530 NTP->name = GetDeclName (NTTPD);
1531+ auto NS = GetNamespace (NTTPD);
1532+ assertm (NS, " Expected a valid namespace!\n " );
1533+ NTP->_namespace = NS;
1534+
15221535 HandleDeclaration (NTTPD, NTP);
15231536 if (NTTPD->hasDefaultArgument ())
15241537 NTP->defaultArgument = WalkExpressionObsolete (NTTPD->getDefaultArgument ());
@@ -1677,8 +1690,9 @@ TypeAliasTemplate* Parser::WalkTypeAliasTemplate(
16771690 HandleDeclaration (TD, TA);
16781691
16791692 TA->name = GetDeclName (TD);
1693+ TA->_namespace = NS;
16801694 NS->Templates .push_back (TA);
1681-
1695+ TA-> CanonicalDecl = WalkDeclaration (TD-> getCanonicalDecl ());
16821696 TA->TemplatedDecl = WalkDeclaration (TD->getTemplatedDecl ());
16831697 TA->Parameters = WalkTemplateParameterList (TD->getTemplateParameters ());
16841698
@@ -2119,6 +2133,10 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
21192133 if (Context->isTranslationUnit ())
21202134 return GetTranslationUnit (D);
21212135
2136+ auto NS = walkedNamespaces[Context];
2137+ if (NS)
2138+ return NS;
2139+
21222140 TranslationUnit* Unit = GetTranslationUnit (cast<Decl>(Context));
21232141
21242142 // Else we need to do a more expensive check to get all the namespaces,
@@ -2138,19 +2156,27 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
21382156 {
21392157 const auto * Ctx = *I;
21402158
2159+ auto CtxNS = walkedNamespaces[Ctx];
2160+ if (CtxNS)
2161+ {
2162+ DC = CtxNS;
2163+ continue ;
2164+ }
2165+
21412166 switch (Ctx->getDeclKind ())
21422167 {
21432168 case Decl::Namespace:
21442169 {
21452170 auto ND = cast<NamespaceDecl>(Ctx);
21462171 if (ND->isAnonymousNamespace ())
2147- continue ;
2172+ break ;
2173+
21482174 auto Name = ND->getName ();
21492175 DC = DC->FindCreateNamespace (Name.str ());
21502176 ((Namespace*)DC)->isAnonymous = ND->isAnonymousNamespace ();
21512177 ((Namespace*)DC)->isInline = ND->isInline ();
21522178 HandleDeclaration (ND, DC);
2153- continue ;
2179+ break ;
21542180 }
21552181 case Decl::LinkageSpec:
21562182 {
@@ -2161,7 +2187,7 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
21612187 {
21622188 auto RD = cast<CXXRecordDecl>(Ctx);
21632189 DC = WalkRecordCXX (RD);
2164- continue ;
2190+ break ;
21652191 }
21662192 case Decl::CXXDeductionGuide:
21672193 {
@@ -2172,9 +2198,13 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
21722198 auto D = cast<Decl>(Ctx);
21732199 auto Decl = WalkDeclaration (D);
21742200 DC = static_cast <DeclarationContext*>(Decl);
2201+ break ;
21752202 } }
2203+
2204+ walkedNamespaces[Ctx] = DC;
21762205 }
21772206
2207+ walkedNamespaces[Context] = DC;
21782208 return DC;
21792209}
21802210
0 commit comments