[PATCH] D76320: [clang] Fix crash on visiting null nestedNameSpecifier.
    Haojian Wu via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Mar 18 01:04:22 PDT 2020
    
    
  
hokein updated this revision to Diff 251006.
hokein marked an inline comment as done.
hokein added a comment.
address review comment.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76320/new/
https://reviews.llvm.org/D76320
Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Parser/cxx-template-decl.cpp
Index: clang/test/Parser/cxx-template-decl.cpp
===================================================================
--- clang/test/Parser/cxx-template-decl.cpp
+++ clang/test/Parser/cxx-template-decl.cpp
@@ -273,3 +273,9 @@
 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) {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -5928,7 +5928,9 @@
 
 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::VisitNestedNameSpecifier(
                                                     NestedNameSpecifier *NNS) {
+  assert(NNS);
   if (NNS->getPrefix() && VisitNestedNameSpecifier(NNS->getPrefix()))
     return true;
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76320.251006.patch
Type: text/x-patch
Size: 1406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200318/f11ffb16/attachment.bin>
    
    
More information about the cfe-commits
mailing list