Skip to content

Commit

Permalink
Parser.cpp: fix WalkType for clang::Type::TypeClass == clang::Type::T…
Browse files Browse the repository at this point in the history
…emplateSpecialization
  • Loading branch information
deadlocklogic committed Dec 31, 2023
1 parent 7b0375d commit 2e1133d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/CppParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,10 +2638,11 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
if (TS->isSugared())
TST->desugared = GetQualifiedType(TS->getCanonicalTypeInternal(), TL);

TypeLoc UTL, ETL, ITL;
TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TS->template_arguments());

if (LocValid)
{
TypeLoc UTL, ETL, ITL;
auto TypeLocClass = TL->getTypeLocClass();
if (TypeLocClass == TypeLoc::Qualified)
{
Expand All @@ -2655,20 +2656,26 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
TL = &ITL;
}

assert(TL->getTypeLocClass() == TypeLoc::TemplateSpecialization);
if (TL->getTypeLocClass() == TypeLoc::DependentTemplateSpecialization)
{
DependentTemplateSpecializationTypeLoc TSpecTL = TL->getAs<DependentTemplateSpecializationTypeLoc>();
TST->Arguments = WalkTemplateArgumentList(&TArgs, &TSpecTL);
}
else if (TL->getTypeLocClass() == TypeLoc::TemplateSpecialization)
{
TemplateSpecializationTypeLoc TSpecTL = TL->getAs<TemplateSpecializationTypeLoc>();
TST->Arguments = WalkTemplateArgumentList(&TArgs, &TSpecTL);
}
else
{
llvm_unreachable("Unexpected semantics");
}
}

TemplateSpecializationTypeLoc TSpecTL;
TemplateSpecializationTypeLoc *TSTL = 0;
if (LocValid)
else
{
TSpecTL = TL->getAs<TemplateSpecializationTypeLoc>();
TSTL = &TSpecTL;
TST->Arguments = WalkTemplateArgumentList(&TArgs, (TemplateSpecializationTypeLoc*)nullptr);
}

TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TS->template_arguments());
TST->Arguments = WalkTemplateArgumentList(&TArgs, TSTL);

Ty = TST;
break;
}
Expand Down

0 comments on commit 2e1133d

Please sign in to comment.