Browse Source

Fixed processing of type locations in the case of template specializations (the new behavior deals properly with elaborated and qualified types). Fixes some crashes in template-heavy code.

pull/1/head
triton 13 years ago
parent
commit
1d151178ff
  1. 17
      src/Parser/Parser.cpp

17
src/Parser/Parser.cpp

@ -784,8 +784,21 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -784,8 +784,21 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
TST->Template = safe_cast<Cxxi::Template^>(WalkDeclaration(
Name.getAsTemplateDecl(), 0, /*IgnoreSystemDecls=*/false));
clang::TypeLoc::TypeLocClass Class = TL->getTypeLocClass();
auto TypeLocClass = TL->getTypeLocClass();
if (TypeLocClass == TypeLoc::Qualified)
{
auto UTL = TL->getUnqualifiedLoc();
TL = &UTL;
}
else if (TypeLocClass == TypeLoc::Elaborated)
{
auto ETL = TL->getAs<ElaboratedTypeLoc>();
auto ITL = ETL.getNextTypeLoc();
TL = &ITL;
}
assert(TL->getTypeLocClass() == TypeLoc::TemplateSpecialization);
auto TSTL = TL->getAs<TemplateSpecializationTypeLoc>();
for (unsigned I = 0, E = TS->getNumArgs(); I != E; ++I)
@ -794,7 +807,6 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -794,7 +807,6 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto Arg = Cxxi::TemplateArgument();
TemplateArgumentLoc ArgLoc;
if (Class == clang::TypeLoc::TemplateSpecialization)
ArgLoc = TSTL.getArgLoc(I);
switch(TA.getKind())
@ -803,7 +815,6 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -803,7 +815,6 @@ Cxxi::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{
Arg.Kind = Cxxi::TemplateArgument::ArgumentKind::Type;
TypeLoc ArgTL;
if (Class == clang::TypeLoc::TemplateSpecialization)
ArgTL = ArgLoc.getTypeSourceInfo()->getTypeLoc();
Arg.Type = WalkType(TA.getAsType(), &ArgTL);
break;

Loading…
Cancel
Save