Browse Source

Fixed an assert when parsing nested types which use template instantiations of void.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
cpp_module_crash
Dimitar Dobrev 10 years ago
parent
commit
f29e3a2240
  1. 23
      src/CppParser/Parser.cpp
  2. 9
      tests/Common/Common.h

23
src/CppParser/Parser.cpp

@ -2241,14 +2241,9 @@ static const clang::Type* GetFinalType(const clang::Type* Ty)
} }
} }
static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty) static bool CheckTypeIfRecord(const clang::Type* Ty)
{ {
auto FinalType = GetFinalType(Ty); if (auto RT = Ty->getAs<clang::RecordType>())
if (FinalType->isDependentType() || FinalType->isInstantiationDependentType())
return false;
if (auto RT = FinalType->getAs<clang::RecordType>())
{ {
if (RT->getDecl()->isInvalidDecl() || RT->getDecl()->isDependentContext() || if (RT->getDecl()->isInvalidDecl() || RT->getDecl()->isDependentContext() ||
!RT->getDecl()->getDefinition()) !RT->getDecl()->getDefinition())
@ -2257,15 +2252,23 @@ static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
for (const auto& F : RT->getDecl()->fields()) for (const auto& F : RT->getDecl()->fields())
{ {
auto FT = GetFinalType(F->getType().getTypePtr()); auto FT = GetFinalType(F->getType().getTypePtr());
const clang::RecordType* FR; if (FT != Ty && !CheckTypeIfRecord(FT))
if ((FR = FT->getAs<clang::RecordType>()) && FR->getDecl()->isInvalidDecl())
return false; return false;
} }
} }
return true; return true;
} }
static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
{
auto FinalType = GetFinalType(Ty);
if (FinalType->isDependentType() || FinalType->isInstantiationDependentType())
return false;
return CheckTypeIfRecord(FinalType);
}
void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F, void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
bool IsDependent) bool IsDependent)
{ {

9
tests/Common/Common.h

@ -1101,8 +1101,17 @@ private:
T t; T t;
}; };
template <class T>
class SpecialisesVoidInUnion
{
union {
SpecialisesVoid<T>* e;
}* u;
};
class UsesSpecialisationOfVoid class UsesSpecialisationOfVoid
{ {
private: private:
SpecialisesVoid<void>* s; SpecialisesVoid<void>* s;
SpecialisesVoidInUnion<void>* h;
}; };

Loading…
Cancel
Save