summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2020-03-17 21:39:19 +0100
committerHaojian Wu <hokein.wu@gmail.com>2020-06-10 11:46:53 +0200
commit3f4a753f597357db77fe395561234a50daa451b3 (patch)
treec1d5f5756b80f3a40824ddc5bb0d6d998e67c1fb
parentd942a81c71a3f970857e92e98cc6503b61b589b0 (diff)
downloadbcm5719-llvm-3f4a753f597357db77fe395561234a50daa451b3.tar.gz
bcm5719-llvm-3f4a753f597357db77fe395561234a50daa451b3.zip
[clang] Fix crash on visiting null nestedNameSpecifier.
Summary: Fix https://github.com/clangd/clangd/issues/293 Reviewers: sammccall Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76320 (cherry picked from commit bd763e2cf7c1d84bab95064cc5cbe542b227b025)
-rwxr-xr-xclang/lib/Sema/SemaTemplate.cpp5
-rw-r--r--clang/test/Parser/cxx-template-decl.cpp6
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 943e8f422a7..264c903209a 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5928,7 +5928,9 @@ bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
const DependentTemplateSpecializationType* T) {
- return VisitNestedNameSpecifier(T->getQualifier());
+ if (auto *Q = T->getQualifier())
+ return VisitNestedNameSpecifier(Q);
+ return false;
}
bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
@@ -5982,6 +5984,7 @@ bool UnnamedLocalNoLinkageFinder::VisitTagDecl(const TagDecl *Tag) {
bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
NestedNameSpecifier *NNS) {
+ assert(NNS);
if (NNS->getPrefix() && VisitNestedNameSpecifier(NNS->getPrefix()))
return true;
diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp
index 3d7a3dc14f4..0d52ad8fb50 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -273,3 +273,9 @@ namespace AnnotateAfterInvalidTemplateId {
namespace PR45063 {
template<class=class a::template b<>> struct X {}; // expected-error {{undeclared identifier 'a'}}
}
+
+namespace NoCrashOnEmptyNestedNameSpecifier {
+ template <typename FnT,
+ typename T = typename ABC<FnT>::template arg_t<0>> // expected-error {{no template named 'ABC'}}
+ void foo(FnT) {}
+}
OpenPOWER on IntegriCloud