r303045 - [index] Avoid a crash that happens when looking up a dependent name
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Mon May 15 03:20:39 PDT 2017
Author: arphaman
Date: Mon May 15 05:20:39 2017
New Revision: 303045
URL: http://llvm.org/viewvc/llvm-project?rev=303045&view=rev
Log:
[index] Avoid a crash that happens when looking up a dependent name
in a record that has no definition
rdar://32194921
Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
cfe/trunk/test/Index/Core/index-dependent-source.cpp
Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=303045&r1=303044&r2=303045&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon May 15 05:20:39 2017
@@ -165,6 +165,9 @@ public:
if (!TD)
return true;
CXXRecordDecl *RD = TD->getTemplatedDecl();
+ if (!RD->hasDefinition())
+ return true;
+ RD = RD->getDefinition();
std::vector<const NamedDecl *> Symbols =
RD->lookupDependentName(NameInfo.getName(), Filter);
// FIXME: Improve overload handling.
Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=303045&r1=303044&r2=303045&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Mon May 15 05:20:39 2017
@@ -157,6 +157,9 @@ public:
if (!TD)
return true;
CXXRecordDecl *RD = TD->getTemplatedDecl();
+ if (!RD->hasDefinition())
+ return true;
+ RD = RD->getDefinition();
DeclarationName Name(DNT->getIdentifier());
std::vector<const NamedDecl *> Symbols = RD->lookupDependentName(
Name, [](const NamedDecl *ND) { return isa<TypeDecl>(ND); });
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=303045&r1=303044&r2=303045&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-dependent-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-dependent-source.cpp Mon May 15 05:20:39 2017
@@ -122,3 +122,12 @@ void indexDependentOverloads(const Templ
object.overload1(Y());
// 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;
+}
More information about the cfe-commits
mailing list