Browse Source

Fixed a crash when parsing type aliases.

This was caused by a change in behaviour in Clang - a8770a7e8e (SVN revision 346146).

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1146/head
Dimitar Dobrev 7 years ago
parent
commit
e035b27686
  1. 8
      src/CppParser/Parser.cpp
  2. 9
      tests/Common/Common.h

8
src/CppParser/Parser.cpp

@ -2475,7 +2475,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
TST->_template = static_cast<Template*>(WalkDeclaration( TST->_template = static_cast<Template*>(WalkDeclaration(
Name.getAsTemplateDecl())); Name.getAsTemplateDecl()));
if (TS->isSugared()) if (TS->isSugared())
TST->desugared = GetQualifiedType(TS->desugar(), TL); TST->desugared = GetQualifiedType(TS->getCanonicalTypeInternal(), TL);
TypeLoc UTL, ETL, ITL; TypeLoc UTL, ETL, ITL;
@ -2518,7 +2518,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
auto TST = new DependentTemplateSpecializationType(); auto TST = new DependentTemplateSpecializationType();
if (TS->isSugared()) if (TS->isSugared())
TST->desugared = GetQualifiedType(TS->desugar(), TL); TST->desugared = GetQualifiedType(TS->getCanonicalTypeInternal(), TL);
TypeLoc UTL, ETL, ITL; TypeLoc UTL, ETL, ITL;
@ -2706,7 +2706,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
auto UTT = new UnaryTransformType(); auto UTT = new UnaryTransformType();
auto Loc = TL->getAs<UnaryTransformTypeLoc>().getUnderlyingTInfo()->getTypeLoc(); auto Loc = TL->getAs<UnaryTransformTypeLoc>().getUnderlyingTInfo()->getTypeLoc();
UTT->desugared = GetQualifiedType(UT->isSugared() ? UT->desugar() : UT->getBaseType(), &Loc); UTT->desugared = GetQualifiedType(UT->isSugared() ? UT->getCanonicalTypeInternal() : UT->getBaseType(), &Loc);
UTT->baseType = GetQualifiedType(UT->getBaseType(), &Loc); UTT->baseType = GetQualifiedType(UT->getBaseType(), &Loc);
Ty = UTT; Ty = UTT;
@ -2733,7 +2733,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
{ {
auto AT = Type->getAs<clang::AutoType>(); auto AT = Type->getAs<clang::AutoType>();
if (AT->isSugared()) if (AT->isSugared())
Ty = WalkType(AT->desugar()); Ty = WalkType(AT->getCanonicalTypeInternal());
else else
return nullptr; return nullptr;
break; break;

9
tests/Common/Common.h

@ -1457,3 +1457,12 @@ class MyIntList : public MyList<int>
}; };
void MyFunc(MyList<void *> *list); void MyFunc(MyList<void *> *list);
template<class T> using InvokeGenSeq = typename T::Type;
template<int N> struct DerivedTypeAlias;
template<int N> using TypeAlias = InvokeGenSeq<DerivedTypeAlias<N>>;
template<int N>
struct DerivedTypeAlias : TypeAlias<N / 2> {};

Loading…
Cancel
Save