From d2b8aaa05a7fa1eef696b5e43db3a535a63559ec Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Tue, 16 May 2017 17:33:17 +0000 Subject: [PATCH] [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 --- clang/lib/AST/CXXInheritance.cpp | 2 ++ clang/test/Index/Core/index-dependent-source.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index 4499ec7..746602d 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -278,6 +278,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, dyn_cast_or_null(TN.getAsTemplateDecl())) BaseRecord = TD->getTemplatedDecl(); } + if (BaseRecord && !BaseRecord->hasDefinition()) + BaseRecord = nullptr; } else { BaseRecord = cast( BaseSpec.getType()->castAs()->getDecl()); diff --git a/clang/test/Index/Core/index-dependent-source.cpp b/clang/test/Index/Core/index-dependent-source.cpp index 2541079..8c097b9 100644 --- a/clang/test/Index/Core/index-dependent-source.cpp +++ b/clang/test/Index/Core/index-dependent-source.cpp @@ -131,3 +131,13 @@ void undefinedTemplateLookup(UndefinedTemplateClass &x) { x.lookup; typename UndefinedTemplateClass::Type y; } + +template +struct UserOfUndefinedTemplateClass: UndefinedTemplateClass { }; + +template +void undefinedTemplateLookup2(UserOfUndefinedTemplateClass &x) { +// Shouldn't crash! + x.lookup; + typename UserOfUndefinedTemplateClass::Type y; +} -- 2.7.4