diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-05-15 10:20:39 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-05-15 10:20:39 +0000 |
commit | 09653330bca7b9894401271879bf62ceda6c03c3 (patch) | |
tree | b2f62672a4b2e7cb36bb6f25ea1e912d931b1725 /clang | |
parent | 1a5a5e6a2aa5dc12a14f09d752525b951276c4fe (diff) | |
download | bcm5719-llvm-09653330bca7b9894401271879bf62ceda6c03c3.tar.gz bcm5719-llvm-09653330bca7b9894401271879bf62ceda6c03c3.zip |
[index] Avoid a crash that happens when looking up a dependent name
in a record that has no definition
rdar://32194921
llvm-svn: 303045
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Index/IndexBody.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Index/IndexTypeSourceInfo.cpp | 3 | ||||
-rw-r--r-- | clang/test/Index/Core/index-dependent-source.cpp | 9 |
3 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp index 9439c11dac0..08d233fb83e 100644 --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -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. diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp index 7e2041c6cb0..e9ca651e002 100644 --- a/clang/lib/Index/IndexTypeSourceInfo.cpp +++ b/clang/lib/Index/IndexTypeSourceInfo.cpp @@ -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); }); diff --git a/clang/test/Index/Core/index-dependent-source.cpp b/clang/test/Index/Core/index-dependent-source.cpp index 35f5cf45c35..25410799a86 100644 --- a/clang/test/Index/Core/index-dependent-source.cpp +++ b/clang/test/Index/Core/index-dependent-source.cpp @@ -122,3 +122,12 @@ void indexDependentOverloads(const TemplateClass<T, S> &object) { 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; +} |