Skip to content

Commit

Permalink
chore: build NameInfo using explicitly provided nested-name-specifier
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed May 30, 2024
1 parent 895cc6e commit d68d133
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{#if prefix~}}
{{#unless (or (contains @root.symbol.namespace prefix.symbol) (eq @root.symbol prefix.symbol))~}}
{{>name-info prefix nolink=nolink~}}::
{{~/unless~}}
{{/if~}}
{{~/if~}}
{{#if (and symbol.ref (not nolink))}}xref:{{symbol.ref}}[{{name}}]{{else~}}
{{name}}{{/if}}{{#if args}}{{>template-args args=args nolink=nolink}}{{/if~}}
42 changes: 18 additions & 24 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,14 @@ class ASTVisitor
return;

I.Name = extractName(D);
I.AliasedSymbol = buildNameInfo(D->getAliasedNamespace());
auto& Underlying = I.AliasedSymbol =
std::make_unique<NameInfo>();

NamedDecl* Aliased = D->getAliasedNamespace();
Underlying->Name = Aliased->getIdentifier()->getName();
getDependencyID(Aliased, Underlying->id);
if(NestedNameSpecifier* NNS = D->getQualifier())
Underlying->Prefix = buildNameInfo(NNS);

getParentNamespaces(I, D);
}
Expand Down Expand Up @@ -3074,7 +3081,7 @@ class TerminalTypeVisitor

unsigned Quals_ = 0;
bool IsPack_ = false;
const NestedNameSpecifier* NNS_ = nullptr;
const NestedNameSpecifier* NNS_;

Derived& getDerived()
{
Expand Down Expand Up @@ -3361,8 +3368,10 @@ class TerminalTypeVisitor

public:
TerminalTypeVisitor(
ASTVisitor& Visitor)
ASTVisitor& Visitor,
const NestedNameSpecifier* NNS = nullptr)
: Visitor_(Visitor)
, NNS_(NNS)
{
}

Expand Down Expand Up @@ -3462,10 +3471,7 @@ class TypeInfoBuilder
std::unique_ptr<TypeInfo>* Inner = &Result;

public:
TypeInfoBuilder(ASTVisitor& Visitor)
: TerminalTypeVisitor(Visitor)
{
}
using TerminalTypeVisitor::TerminalTypeVisitor;

std::unique_ptr<TypeInfo> result()
{
Expand Down Expand Up @@ -3615,8 +3621,6 @@ class TypeInfoBuilder
V.getDependencyID(V.getInstantiatedFrom(D), Name->id);
if(NNS)
Name->Prefix = V.buildNameInfo(NNS);
else
Name->Prefix = V.buildNameInfo(V.getParentDecl(D));

V.buildTemplateArgs(Name->TemplateArgs, *TArgs);
I->Name = std::move(Name);
Expand All @@ -3629,8 +3633,6 @@ class TypeInfoBuilder
V.getDependencyID(V.getInstantiatedFrom(D), Name->id);
if(NNS)
Name->Prefix = V.buildNameInfo(NNS);
else
Name->Prefix = V.buildNameInfo(V.getParentDecl(D));
I->Name = std::move(Name);
}
*Inner = std::move(I);
Expand Down Expand Up @@ -3661,10 +3663,7 @@ class NameInfoBuilder
std::unique_ptr<NameInfo> Result;

public:
NameInfoBuilder(ASTVisitor& Visitor)
: TerminalTypeVisitor(Visitor)
{
}
using TerminalTypeVisitor::TerminalTypeVisitor;

std::unique_ptr<NameInfo> result()
{
Expand Down Expand Up @@ -3752,8 +3751,6 @@ class NameInfoBuilder
}
if(NNS)
Result->Prefix = V.buildNameInfo(NNS);
else
Result->Prefix = V.buildNameInfo(V.getParentDecl(D));
}
};

Expand All @@ -3770,7 +3767,7 @@ buildNameInfo(
return I;
if(const Type* T = NNS->getAsType())
{
NameInfoBuilder Builder(*this);
NameInfoBuilder Builder(*this, NNS->getPrefix());
Builder.Visit(T);
I = Builder.result();
}
Expand All @@ -3785,17 +3782,14 @@ buildNameInfo(
I = std::make_unique<NameInfo>();
I->Name = ND->getIdentifier()->getName();
getDependencyID(ND, I->id);
I->Prefix = buildNameInfo(getParentDecl(ND), extract_mode);
I->Prefix = buildNameInfo(NNS->getPrefix(), extract_mode);
}
else if(const NamespaceAliasDecl* NAD = NNS->getAsNamespaceAlias())
{
I = std::make_unique<NameInfo>();
I->Name = NAD->getIdentifier()->getName();
const NamespaceDecl* ND = NAD->getNamespace();
// KRYSTIAN FIXME: this should use the SymbolID of the namespace alias
// once we add an Info kind to represent them
getDependencyID(ND, I->id);
I->Prefix = buildNameInfo(getParentDecl(ND), extract_mode);
getDependencyID(NAD, I->id);
I->Prefix = buildNameInfo(NNS->getPrefix(), extract_mode);
}
return I;
}
Expand Down
68 changes: 34 additions & 34 deletions test-files/old-tests/class-template-specializations-1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,55 +474,55 @@
<struct name="R5" id="sblGSlqZ8xD5IUQo0N0aPL4L0AQ=">
<file path="class-template-specializations-1.cpp" line="188" class="def"/>
<base>
<type id="96AKnFS/OwIoVISFMJoJhA0YXIU=" name="S0::S1::S2&lt;-1&gt;"/>
<type id="96AKnFS/OwIoVISFMJoJhA0YXIU=" name="S0&lt;3&gt;::S1::S2&lt;-1&gt;"/>
</base>
</struct>
<struct name="R6" id="5zygvvE+CiPrP7pOEMCT/ejsq0M=">
<file path="class-template-specializations-1.cpp" line="190" class="def"/>
<base>
<type id="8snJ9gp5ca88/AsWGEnFe6Ln6RQ=" name="S0::S1::S2&lt;5&gt;"/>
<type id="8snJ9gp5ca88/AsWGEnFe6Ln6RQ=" name="S0&lt;4&gt;::S1::S2&lt;5&gt;"/>
</base>
</struct>
<struct name="R7" id="96LOwhcPie1bYQb/+5hdjvtMZ3Y=">
<file path="class-template-specializations-1.cpp" line="192" class="def"/>
<base>
<type id="ZyL4aBHmvCmfq+HyxDSySKwRsdA=" name="S0::S1::S2&lt;7, void*&gt;"/>
<type id="ZyL4aBHmvCmfq+HyxDSySKwRsdA=" name="S0&lt;6&gt;::S1::S2&lt;7, void*&gt;"/>
</base>
</struct>
<struct name="R8" id="O02SUS1cO7f/cv+4rcolWMgr6Qk=">
<file path="class-template-specializations-1.cpp" line="194" class="def"/>
<base>
<type id="eWg27/kfn86dUmPA26mcOo6kkfs=" name="S0::S1::S2&lt;7, int*&gt;"/>
<type id="eWg27/kfn86dUmPA26mcOo6kkfs=" name="S0&lt;6&gt;::S1::S2&lt;7, int*&gt;"/>
</base>
</struct>
<struct name="R9" id="YRnUAYfQ4BYOxSF2Qkw3NnMX+OQ=">
<file path="class-template-specializations-1.cpp" line="196" class="def"/>
<base>
<type id="OuyCzwMT3B0xth9oee9dTlGkXVw=" name="S0::S1::S2&lt;9&gt;::S3"/>
<type id="OuyCzwMT3B0xth9oee9dTlGkXVw=" name="S0&lt;8&gt;::S1::S2&lt;9&gt;::S3"/>
</base>
</struct>
<struct name="R10" id="37Ll95zW61Q69eIGnUQU/KdOXdc=">
<file path="class-template-specializations-1.cpp" line="198" class="def"/>
<base>
<type id="jsWbJZfAfgKMXbl9GaZXHLmhL2U=" name="S0::S1::S2&lt;11&gt;::S4&lt;-1&gt;"/>
<type id="jsWbJZfAfgKMXbl9GaZXHLmhL2U=" name="S0&lt;10&gt;::S1::S2&lt;11&gt;::S4&lt;-1&gt;"/>
</base>
</struct>
<struct name="R11" id="KxlVqZyxd3ytKt5pMOq1MACEL0I=">
<file path="class-template-specializations-1.cpp" line="200" class="def"/>
<base>
<type id="yPCRvP9B34hMThomBKlaCzkFM54=" name="S0::S1::S2&lt;13&gt;::S4&lt;14&gt;"/>
<type id="yPCRvP9B34hMThomBKlaCzkFM54=" name="S0&lt;12&gt;::S1::S2&lt;13&gt;::S4&lt;14&gt;"/>
</base>
</struct>
<struct name="R12" id="4HX/nvJpOT6MbOcVPGC2BSJIB6I=">
<file path="class-template-specializations-1.cpp" line="202" class="def"/>
<base>
<type id="cV4O7e/J4xug1ZmsOQKwDVjE99M=" name="S0::S1::S2&lt;16&gt;::S4&lt;17, void*&gt;"/>
<type id="cV4O7e/J4xug1ZmsOQKwDVjE99M=" name="S0&lt;15&gt;::S1::S2&lt;16&gt;::S4&lt;17, void*&gt;"/>
</base>
</struct>
<struct name="R13" id="hNbRn1GOUhshsMWwyYhu+Mzr63Y=">
<file path="class-template-specializations-1.cpp" line="204" class="def"/>
<base>
<type id="J3UZDljdSJ1mGU9Js0JpA3TjVtc=" name="S0::S1::S2&lt;16&gt;::S4&lt;17, int*&gt;"/>
<type id="J3UZDljdSJ1mGU9Js0JpA3TjVtc=" name="S0&lt;15&gt;::S1::S2&lt;16&gt;::S4&lt;17, int*&gt;"/>
</base>
</struct>
<struct name="R14" id="o8fncABv2obQ8RPoe42PPkbV6EU=">
Expand Down Expand Up @@ -552,61 +552,61 @@
<struct name="R18" id="YJvTNkVKYomLYiXMPMOfXxP5Mn8=">
<file path="class-template-specializations-1.cpp" line="214" class="def"/>
<base>
<type id="w4IHOtNv5zozrqG240cCIM/ceiU=" name="S0::S5&lt;24&gt;::S6"/>
<type id="w4IHOtNv5zozrqG240cCIM/ceiU=" name="S0&lt;23&gt;::S5&lt;24&gt;::S6"/>
</base>
</struct>
<struct name="R19" id="XKdrAB7W4NV2H0u3z4YQyk01nsY=">
<file path="class-template-specializations-1.cpp" line="216" class="def"/>
<base>
<type id="ExhHzwlrMNSfv2bLNPrl3Ts+Nvk=" name="S0::S5::S6::S7&lt;-1&gt;"/>
<type id="ExhHzwlrMNSfv2bLNPrl3Ts+Nvk=" name="S0&lt;25&gt;::S5&lt;26&gt;::S6::S7&lt;-1&gt;"/>
</base>
</struct>
<struct name="R20" id="Djfh1tM7EofhMQEp2jD2W0SkCZc=">
<file path="class-template-specializations-1.cpp" line="218" class="def"/>
<base>
<type id="pbmVOgtPeZtTL7BQG/AM7NVsNdo=" name="S0::S5::S6::S7&lt;29, void*&gt;"/>
<type id="pbmVOgtPeZtTL7BQG/AM7NVsNdo=" name="S0&lt;27&gt;::S5&lt;28&gt;::S6::S7&lt;29, void*&gt;"/>
</base>
</struct>
<struct name="R21" id="c7vedsb0RL7v2uEX7fBxP+lLDUE=">
<file path="class-template-specializations-1.cpp" line="220" class="def"/>
<base>
<type id="3eTbiMMR3GPY7/xRty3EmJ9bdQU=" name="S0::S5::S6::S7&lt;29, int*&gt;"/>
<type id="3eTbiMMR3GPY7/xRty3EmJ9bdQU=" name="S0&lt;27&gt;::S5&lt;28&gt;::S6::S7&lt;29, int*&gt;"/>
</base>
</struct>
<struct name="R22" id="BRP738ePXtkkzTEx62BH/csijNU=">
<file path="class-template-specializations-1.cpp" line="222" class="def"/>
<base>
<type id="VxqDdgdkcw8E86ZiNolpXLlhyWs=" name="S0::S5::S6::S7&lt;32&gt;"/>
<type id="VxqDdgdkcw8E86ZiNolpXLlhyWs=" name="S0&lt;30&gt;::S5&lt;31&gt;::S6::S7&lt;32&gt;"/>
</base>
</struct>
<struct name="R23" id="tZycFfC5yVQHsLOhWKHuU4W5Q08=">
<file path="class-template-specializations-1.cpp" line="224" class="def"/>
<base>
<type id="3sBLDynoSyGl1xzXtqGZlO/q6dA=" name="S0::S5::S6::S7&lt;35&gt;::S8"/>
<type id="3sBLDynoSyGl1xzXtqGZlO/q6dA=" name="S0&lt;33&gt;::S5&lt;34&gt;::S6::S7&lt;35&gt;::S8"/>
</base>
</struct>
<struct name="R24" id="UxsGdsG7pWSk+aJLPGSFF8Dxiao=">
<file path="class-template-specializations-1.cpp" line="226" class="def"/>
<base>
<type id="KChFuNDElPROHklvCtkJ+O4+io8=" name="S0::S5::S6::S7&lt;38&gt;::S9&lt;-1&gt;"/>
<type id="KChFuNDElPROHklvCtkJ+O4+io8=" name="S0&lt;36&gt;::S5&lt;37&gt;::S6::S7&lt;38&gt;::S9&lt;-1&gt;"/>
</base>
</struct>
<struct name="R25" id="ugC1EM88IyyB7hKO6Gk3zxb26BI=">
<file path="class-template-specializations-1.cpp" line="228" class="def"/>
<base>
<type id="CvFJnK9Xu7B2Fbh91NqM0+gKVEU=" name="S0::S5::S6::S7&lt;41&gt;::S9&lt;42, void*&gt;"/>
<type id="CvFJnK9Xu7B2Fbh91NqM0+gKVEU=" name="S0&lt;39&gt;::S5&lt;40&gt;::S6::S7&lt;41&gt;::S9&lt;42, void*&gt;"/>
</base>
</struct>
<struct name="R26" id="qx49JH2sKz2ucLdeyOofzjOIIys=">
<file path="class-template-specializations-1.cpp" line="230" class="def"/>
<base>
<type id="hwfbdkFRNunC/3V+s6HA5BwWiSQ=" name="S0::S5::S6::S7&lt;41&gt;::S9&lt;42, int*&gt;"/>
<type id="hwfbdkFRNunC/3V+s6HA5BwWiSQ=" name="S0&lt;39&gt;::S5&lt;40&gt;::S6::S7&lt;41&gt;::S9&lt;42, int*&gt;"/>
</base>
</struct>
<struct name="R27" id="spTxXazLZhY+2ttJ4SvrUE5GHuE=">
<file path="class-template-specializations-1.cpp" line="232" class="def"/>
<base>
<type id="8PQtbs9xGpu1L+b0VOqfLlE6TnY=" name="S0::S5::S6::S7&lt;45&gt;::S9&lt;46&gt;"/>
<type id="8PQtbs9xGpu1L+b0VOqfLlE6TnY=" name="S0&lt;43&gt;::S5&lt;44&gt;::S6::S7&lt;45&gt;::S9&lt;46&gt;"/>
</base>
</struct>
<struct name="R28" id="UDzu/sD/ufLi70VH15nMFblNwe4=">
Expand All @@ -633,26 +633,26 @@
<struct name="R31" id="a6PZj6tjiEyiL0giu8norS/dpQ0=">
<file path="class-template-specializations-1.cpp" line="241" class="def"/>
<base>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0::S1::S2&lt;I, T&gt;"/>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0&lt;3, bool&gt;::S1::S2&lt;I, T&gt;"/>
</base>
</struct>
</template>
<struct name="R32" id="pGomjfageqLgG/f9fj7sj7IVZLU=">
<file path="class-template-specializations-1.cpp" line="243" class="def"/>
<base>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0::S1::S2&lt;5, bool&gt;"/>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0&lt;4, bool&gt;::S1::S2&lt;5, bool&gt;"/>
</base>
</struct>
<struct name="R33" id="BdqyL6agHf56B9/yi32jDJC7KFA=">
<file path="class-template-specializations-1.cpp" line="245" class="def"/>
<base>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0::S1::S2&lt;7, int&gt;"/>
<type id="oNfOAnUjZE7WlBGdMiNtQ9ePi8g=" name="S0&lt;6, bool&gt;::S1::S2&lt;7, int&gt;"/>
</base>
</struct>
<struct name="R34" id="igYKtzFDu8lhxosToWFs69BVPuM=">
<file path="class-template-specializations-1.cpp" line="247" class="def"/>
<base>
<type id="LjJr8jL1hFRtsFi7N5gXIU8pmt8=" name="S0::S1::S2&lt;9, bool&gt;::S3"/>
<type id="LjJr8jL1hFRtsFi7N5gXIU8pmt8=" name="S0&lt;8, bool&gt;::S1::S2&lt;9, bool&gt;::S3"/>
</base>
</struct>
<template>
Expand All @@ -661,20 +661,20 @@
<struct name="R35" id="eo8jQEg9QMloSGi6GpyAeQqlpCs=">
<file path="class-template-specializations-1.cpp" line="250" class="def"/>
<base>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0::S1::S2&lt;11, bool&gt;::S4&lt;I, T&gt;"/>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0&lt;10, bool&gt;::S1::S2&lt;11, bool&gt;::S4&lt;I, T&gt;"/>
</base>
</struct>
</template>
<struct name="R36" id="7oxAWQBGk8SBe1Ci9NUHRp2c/wY=">
<file path="class-template-specializations-1.cpp" line="252" class="def"/>
<base>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0::S1::S2&lt;13, bool&gt;::S4&lt;14, bool&gt;"/>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0&lt;12, bool&gt;::S1::S2&lt;13, bool&gt;::S4&lt;14, bool&gt;"/>
</base>
</struct>
<struct name="R37" id="A16UCOKGsKEteewO0ppRUQEljqY=">
<file path="class-template-specializations-1.cpp" line="254" class="def"/>
<base>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0::S1::S2&lt;16, bool&gt;::S4&lt;17, int&gt;"/>
<type id="8UtqZHVItGCqKLwlXny0WJDLkDQ=" name="S0&lt;15, bool&gt;::S1::S2&lt;16, bool&gt;::S4&lt;17, int&gt;"/>
</base>
</struct>
<template>
Expand Down Expand Up @@ -702,7 +702,7 @@
<struct name="R41" id="eUmJbtnqgN9sxJ1tY4V4JqqHWfM=">
<file path="class-template-specializations-1.cpp" line="263" class="def"/>
<base>
<type id="icRp7NeoOT+m93ddn+fcm7v0hWU=" name="S0::S5&lt;24, bool&gt;::S6"/>
<type id="icRp7NeoOT+m93ddn+fcm7v0hWU=" name="S0&lt;23, bool&gt;::S5&lt;24, bool&gt;::S6"/>
</base>
</struct>
<template>
Expand All @@ -711,26 +711,26 @@
<struct name="R42" id="Lw0S5zz85DmfSfnw5wqcfXhtZC4=">
<file path="class-template-specializations-1.cpp" line="266" class="def"/>
<base>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0::S5::S6::S7&lt;I, T&gt;"/>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0&lt;25, bool&gt;::S5&lt;26, bool&gt;::S6::S7&lt;I, T&gt;"/>
</base>
</struct>
</template>
<struct name="R43" id="JJ881dCpsJGfDwaJqBVrOM+FGfc=">
<file path="class-template-specializations-1.cpp" line="268" class="def"/>
<base>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0::S5::S6::S7&lt;29, int&gt;"/>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0&lt;27, bool&gt;::S5&lt;28, bool&gt;::S6::S7&lt;29, int&gt;"/>
</base>
</struct>
<struct name="R44" id="dLkPAIOQFX9NSi+ZbHAYUKQBB4M=">
<file path="class-template-specializations-1.cpp" line="270" class="def"/>
<base>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0::S5::S6::S7&lt;32, bool&gt;"/>
<type id="3ZrGNdgVY0Bl8pl2wuSUdgLSht4=" name="S0&lt;30, bool&gt;::S5&lt;31, bool&gt;::S6::S7&lt;32, bool&gt;"/>
</base>
</struct>
<struct name="R45" id="waLXJ0bLUTUAlFIlzxEcLUpezYY=">
<file path="class-template-specializations-1.cpp" line="272" class="def"/>
<base>
<type id="2R/ZzEEP3phjsDdKShbY468avc4=" name="S0::S5::S6::S7&lt;35, bool&gt;::S8"/>
<type id="2R/ZzEEP3phjsDdKShbY468avc4=" name="S0&lt;33, bool&gt;::S5&lt;34, bool&gt;::S6::S7&lt;35, bool&gt;::S8"/>
</base>
</struct>
<template>
Expand All @@ -739,20 +739,20 @@
<struct name="R46" id="zpWPNwEVFZZIH8TbPFJ12fiTZ9Y=">
<file path="class-template-specializations-1.cpp" line="275" class="def"/>
<base>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0::S5::S6::S7&lt;38, bool&gt;::S9&lt;I, T&gt;"/>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0&lt;36, bool&gt;::S5&lt;37, bool&gt;::S6::S7&lt;38, bool&gt;::S9&lt;I, T&gt;"/>
</base>
</struct>
</template>
<struct name="R47" id="v6xjYLdZoNOxa0pno//3eiAYYK0=">
<file path="class-template-specializations-1.cpp" line="277" class="def"/>
<base>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0::S5::S6::S7&lt;41, bool&gt;::S9&lt;42, int&gt;"/>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0&lt;39, bool&gt;::S5&lt;40, bool&gt;::S6::S7&lt;41, bool&gt;::S9&lt;42, int&gt;"/>
</base>
</struct>
<struct name="R48" id="0pV0D7DTQH+IJFmLMCQTWHqHg+U=">
<file path="class-template-specializations-1.cpp" line="279" class="def"/>
<base>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0::S5::S6::S7&lt;45, bool&gt;::S9&lt;46, bool&gt;"/>
<type id="T91uOH7uarKVQhSHZ7iIV+AOuBQ=" name="S0&lt;43, bool&gt;::S5&lt;44, bool&gt;::S6::S7&lt;45, bool&gt;::S9&lt;46, bool&gt;"/>
</base>
</struct>
</namespace>
Expand Down
Loading

0 comments on commit d68d133

Please sign in to comment.