[index] Avoid another crash that happens when looking up a dependent name

in a record that has a base without a definition

rdar://32224197

llvm-svn: 303192
This commit is contained in:
Alex Lorenz 2017-05-16 17:33:17 +00:00
parent b215d473dd
commit d2b8aaa05a
2 changed files with 12 additions and 0 deletions

View File

@ -278,6 +278,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl()))
BaseRecord = TD->getTemplatedDecl();
}
if (BaseRecord && !BaseRecord->hasDefinition())
BaseRecord = nullptr;
} else {
BaseRecord = cast<CXXRecordDecl>(
BaseSpec.getType()->castAs<RecordType>()->getDecl());

View File

@ -131,3 +131,13 @@ void undefinedTemplateLookup(UndefinedTemplateClass<T> &x) {
x.lookup;
typename UndefinedTemplateClass<T>::Type y;
}
template<typename T>
struct UserOfUndefinedTemplateClass: UndefinedTemplateClass<T> { };
template<typename T>
void undefinedTemplateLookup2(UserOfUndefinedTemplateClass<T> &x) {
// Shouldn't crash!
x.lookup;
typename UserOfUndefinedTemplateClass<T>::Type y;
}