r303192 - [index] Avoid another crash that happens when looking up a dependent name
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue May 16 10:33:18 PDT 2017
Author: arphaman
Date: Tue May 16 12:33:17 2017
New Revision: 303192
URL: http://llvm.org/viewvc/llvm-project?rev=303192&view=rev
Log:
[index] Avoid another crash that happens when looking up a dependent name
in a record that has a base without a definition
rdar://32224197
Modified:
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/test/Index/Core/index-dependent-source.cpp
Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=303192&r1=303191&r2=303192&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Tue May 16 12:33:17 2017
@@ -278,6 +278,8 @@ bool CXXBasePaths::lookupInBases(ASTCont
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());
Modified: cfe/trunk/test/Index/Core/index-dependent-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-dependent-source.cpp?rev=303192&r1=303191&r2=303192&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-dependent-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-dependent-source.cpp Tue May 16 12:33:17 2017
@@ -131,3 +131,13 @@ void undefinedTemplateLookup(UndefinedTe
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;
+}
More information about the cfe-commits
mailing list