[PATCH] D76320: [clang] Fix crash on visiting null nestedNameSpecifier.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 14:35:28 PDT 2020


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:5926
                                                    const DependentNameType* T) {
-  return VisitNestedNameSpecifier(T->getQualifier());
+  if (auto *Q = T->getQualifier())
+    return VisitNestedNameSpecifier(Q);
----------------
Do you have an idea of how we're getting here with a null qualifier?
AIUI DependentNameType is a type that's a name with a dependent qualifier. If the qualifier doesn't exist, it's not dependent. Is this a recovery path, where the qualifier doesn't exist because it contains an error? (Like the ABC<t> in your test where ABC can't be resolved).

(Docs do reference MSVC-compat cases where the qualifier need not be dependent, and maybe need not exist, but neither the linked bug nor the test use msvc-compat)


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:5989
                                                     NestedNameSpecifier *NNS) {
+  assert(NNS && "NNS must not be null!");
   if (NNS->getPrefix() && VisitNestedNameSpecifier(NNS->getPrefix()))
----------------
nit: this is just assert(NNS), the message doesn't say anything else.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76320/new/

https://reviews.llvm.org/D76320





More information about the cfe-commits mailing list