@@ -1474,12 +1474,17 @@ TemplateTemplateParameter* Parser::WalkTemplateTemplateParameter(const clang::Te
1474
1474
if (TP)
1475
1475
return TP;
1476
1476
1477
+ auto NS = GetNamespace(TTP);
1478
+ assertm(NS, "Expected a valid namespace!\n");
1479
+
1477
1480
TP = new TemplateTemplateParameter();
1478
1481
HandleDeclaration(TTP, TP);
1482
+ TP->_namespace = NS;
1479
1483
TP->Parameters = WalkTemplateParameterList(TTP->getTemplateParameters());
1480
1484
TP->isParameterPack = TTP->isParameterPack();
1481
1485
TP->isPackExpansion = TTP->isPackExpansion();
1482
1486
TP->isExpandedParameterPack = TTP->isExpandedParameterPack();
1487
+
1483
1488
if (TTP->getTemplatedDecl())
1484
1489
{
1485
1490
auto TD = WalkDeclaration(TTP->getTemplatedDecl());
@@ -1499,6 +1504,10 @@ TypeTemplateParameter* Parser::WalkTypeTemplateParameter(const clang::TemplateTy
1499
1504
1500
1505
TP = new TypeTemplateParameter();
1501
1506
TP->name = GetDeclName(TTPD);
1507
+ auto NS = GetNamespace(TTPD);
1508
+ assertm(NS, "Expected a valid namespace!\n");
1509
+ TP->_namespace = NS;
1510
+
1502
1511
HandleDeclaration(TTPD, TP);
1503
1512
if (TTPD->hasDefaultArgument())
1504
1513
TP->defaultArgument = GetQualifiedType(TTPD->getDefaultArgument());
@@ -1519,6 +1528,10 @@ NonTypeTemplateParameter* Parser::WalkNonTypeTemplateParameter(const clang::NonT
1519
1528
1520
1529
NTP = new NonTypeTemplateParameter();
1521
1530
NTP->name = GetDeclName(NTTPD);
1531
+ auto NS = GetNamespace(NTTPD);
1532
+ assertm(NS, "Expected a valid namespace!\n");
1533
+ NTP->_namespace = NS;
1534
+
1522
1535
HandleDeclaration(NTTPD, NTP);
1523
1536
if (NTTPD->hasDefaultArgument())
1524
1537
NTP->defaultArgument = WalkExpressionObsolete(NTTPD->getDefaultArgument());
@@ -1677,8 +1690,9 @@ TypeAliasTemplate* Parser::WalkTypeAliasTemplate(
1677
1690
HandleDeclaration(TD, TA);
1678
1691
1679
1692
TA->name = GetDeclName(TD);
1693
+ TA->_namespace = NS;
1680
1694
NS->Templates.push_back(TA);
1681
-
1695
+ TA->CanonicalDecl = WalkDeclaration(TD->getCanonicalDecl());
1682
1696
TA->TemplatedDecl = WalkDeclaration(TD->getTemplatedDecl());
1683
1697
TA->Parameters = WalkTemplateParameterList(TD->getTemplateParameters());
1684
1698
@@ -2119,6 +2133,10 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
2119
2133
if (Context->isTranslationUnit())
2120
2134
return GetTranslationUnit(D);
2121
2135
2136
+ auto NS = walkedNamespaces[Context];
2137
+ if (NS)
2138
+ return NS;
2139
+
2122
2140
TranslationUnit* Unit = GetTranslationUnit(cast<Decl>(Context));
2123
2141
2124
2142
// 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,
2138
2156
{
2139
2157
const auto* Ctx = *I;
2140
2158
2159
+ auto CtxNS = walkedNamespaces[Ctx];
2160
+ if (CtxNS)
2161
+ {
2162
+ DC = CtxNS;
2163
+ continue;
2164
+ }
2165
+
2141
2166
switch(Ctx->getDeclKind())
2142
2167
{
2143
2168
case Decl::Namespace:
2144
2169
{
2145
2170
auto ND = cast<NamespaceDecl>(Ctx);
2146
2171
if (ND->isAnonymousNamespace())
2147
- continue;
2172
+ break;
2173
+
2148
2174
auto Name = ND->getName();
2149
2175
DC = DC->FindCreateNamespace(Name.str());
2150
2176
((Namespace*)DC)->isAnonymous = ND->isAnonymousNamespace();
2151
2177
((Namespace*)DC)->isInline = ND->isInline();
2152
2178
HandleDeclaration(ND, DC);
2153
- continue ;
2179
+ break ;
2154
2180
}
2155
2181
case Decl::LinkageSpec:
2156
2182
{
@@ -2161,7 +2187,7 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
2161
2187
{
2162
2188
auto RD = cast<CXXRecordDecl>(Ctx);
2163
2189
DC = WalkRecordCXX(RD);
2164
- continue ;
2190
+ break ;
2165
2191
}
2166
2192
case Decl::CXXDeductionGuide:
2167
2193
{
@@ -2172,9 +2198,13 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
2172
2198
auto D = cast<Decl>(Ctx);
2173
2199
auto Decl = WalkDeclaration(D);
2174
2200
DC = static_cast<DeclarationContext*>(Decl);
2201
+ break;
2175
2202
} }
2203
+
2204
+ walkedNamespaces[Ctx] = DC;
2176
2205
}
2177
2206
2207
+ walkedNamespaces[Context] = DC;
2178
2208
return DC;
2179
2209
}
2180
2210
0 commit comments