Skip to content

Commit 0655c84

Browse files
committed
chore: buildNameInfo does not skip the innermost declaration
1 parent 62793c4 commit 0655c84

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/lib/AST/ASTVisitor.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ class ASTVisitor
864864

865865
std::unique_ptr<NameInfo>
866866
buildNameInfo(
867-
const NamedDecl* ND,
867+
const Decl* D,
868868
ExtractMode extract_mode = ExtractMode::IndirectDependency);
869869

870870

@@ -3428,7 +3428,7 @@ class TypeInfoBuilder
34283428
if(NNS)
34293429
Name->Prefix = V.buildNameInfo(NNS);
34303430
else
3431-
Name->Prefix = V.buildNameInfo(D);
3431+
Name->Prefix = V.buildNameInfo(V.getParentDecl(D));
34323432

34333433
V.buildTemplateArgs(Name->TemplateArgs, *TArgs);
34343434
I->Name = std::move(Name);
@@ -3442,7 +3442,7 @@ class TypeInfoBuilder
34423442
if(NNS)
34433443
Name->Prefix = V.buildNameInfo(NNS);
34443444
else
3445-
Name->Prefix = V.buildNameInfo(D);
3445+
Name->Prefix = V.buildNameInfo(V.getParentDecl(D));
34463446
I->Name = std::move(Name);
34473447
}
34483448
*Inner = std::move(I);
@@ -3565,7 +3565,7 @@ class NameInfoBuilder
35653565
if(NNS)
35663566
Result->Prefix = V.buildNameInfo(NNS);
35673567
else
3568-
Result->Prefix = V.buildNameInfo(D);
3568+
Result->Prefix = V.buildNameInfo(V.getParentDecl(D));
35693569
}
35703570
};
35713571

@@ -3597,35 +3597,35 @@ buildNameInfo(
35973597
I = std::make_unique<NameInfo>();
35983598
I->Name = ND->getIdentifier()->getName();
35993599
getDependencyID(ND, I->id);
3600-
I->Prefix = buildNameInfo(ND, extract_mode);
3600+
I->Prefix = buildNameInfo(getParentDecl(ND), extract_mode);
36013601
}
3602-
else if(const NamespaceAliasDecl* ND = NNS->getAsNamespaceAlias())
3602+
else if(const NamespaceAliasDecl* NAD = NNS->getAsNamespaceAlias())
36033603
{
36043604
I = std::make_unique<NameInfo>();
3605-
I->Name = ND->getIdentifier()->getName();
3606-
getDependencyID(ND->getNamespace(), I->id);
3607-
I->Prefix = buildNameInfo(ND->getNamespace(), extract_mode);
3605+
I->Name = NAD->getIdentifier()->getName();
3606+
const NamespaceDecl* ND = NAD->getNamespace();
3607+
// KRYSTIAN FIXME: this should use the SymbolID of the namespace alias
3608+
// once we add an Info kind to represent them
3609+
getDependencyID(ND, I->id);
3610+
I->Prefix = buildNameInfo(getParentDecl(ND), extract_mode);
36083611
}
36093612
return I;
36103613
}
36113614

36123615
std::unique_ptr<NameInfo>
36133616
ASTVisitor::
36143617
buildNameInfo(
3615-
const NamedDecl* ND,
3618+
const Decl* D,
36163619
ExtractMode extract_mode)
36173620
{
3618-
if(! ND)
3619-
return nullptr;
3620-
const NamedDecl* PD = dyn_cast_if_present<
3621-
NamedDecl>(getParentDecl(ND));
3622-
if(! PD || PD->getKind() == Decl::TranslationUnit)
3621+
const auto* ND = dyn_cast_if_present<NamedDecl>(D);
3622+
if(! ND || ND->getKind() == Decl::TranslationUnit)
36233623
return nullptr;
36243624
auto I = std::make_unique<NameInfo>();
3625-
if(const IdentifierInfo* II = PD->getIdentifier())
3625+
if(const IdentifierInfo* II = ND->getIdentifier())
36263626
I->Name = II->getName();
3627-
getDependencyID(getInstantiatedFrom(PD), I->id);
3628-
I->Prefix = buildNameInfo(PD, extract_mode);
3627+
getDependencyID(getInstantiatedFrom(D), I->id);
3628+
I->Prefix = buildNameInfo(getParentDecl(D), extract_mode);
36293629
return I;
36303630
}
36313631

0 commit comments

Comments
 (0)