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

in a record that has no definition

rdar://32194921

llvm-svn: 303045
This commit is contained in:
Alex Lorenz 2017-05-15 10:20:39 +00:00
parent 1a5a5e6a2a
commit 09653330bc
3 changed files with 15 additions and 0 deletions

View File

@ -165,6 +165,9 @@ public:
if (!TD) if (!TD)
return true; return true;
CXXRecordDecl *RD = TD->getTemplatedDecl(); CXXRecordDecl *RD = TD->getTemplatedDecl();
if (!RD->hasDefinition())
return true;
RD = RD->getDefinition();
std::vector<const NamedDecl *> Symbols = std::vector<const NamedDecl *> Symbols =
RD->lookupDependentName(NameInfo.getName(), Filter); RD->lookupDependentName(NameInfo.getName(), Filter);
// FIXME: Improve overload handling. // FIXME: Improve overload handling.

View File

@ -157,6 +157,9 @@ public:
if (!TD) if (!TD)
return true; return true;
CXXRecordDecl *RD = TD->getTemplatedDecl(); CXXRecordDecl *RD = TD->getTemplatedDecl();
if (!RD->hasDefinition())
return true;
RD = RD->getDefinition();
DeclarationName Name(DNT->getIdentifier()); DeclarationName Name(DNT->getIdentifier());
std::vector<const NamedDecl *> Symbols = RD->lookupDependentName( std::vector<const NamedDecl *> Symbols = RD->lookupDependentName(
Name, [](const NamedDecl *ND) { return isa<TypeDecl>(ND); }); Name, [](const NamedDecl *ND) { return isa<TypeDecl>(ND); });

View File

@ -122,3 +122,12 @@ void indexDependentOverloads(const TemplateClass<T, S> &object) {
object.overload1(Y()); object.overload1(Y());
// CHECK-NOT: [[@LINE-1]] // CHECK-NOT: [[@LINE-1]]
} }
template<typename T> struct UndefinedTemplateClass;
template<typename T>
void undefinedTemplateLookup(UndefinedTemplateClass<T> &x) {
// Shouldn't crash!
x.lookup;
typename UndefinedTemplateClass<T>::Type y;
}