[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:21 PDT 2020


hokein marked 2 inline comments as done.
hokein added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:5926
                                                    const DependentNameType* T) {
-  return VisitNestedNameSpecifier(T->getQualifier());
+  if (auto *Q = T->getQualifier())
+    return VisitNestedNameSpecifier(Q);
----------------
sammccall wrote:
> 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)
right, the crash only happens on `DependentTemplateSpecializationType`. I made this change initially when trying the fix the crash (they look quite suspicious).

It can be ran on a recovery path, but I just checked all call sides, qualifier can not be null for DependentNameType (even for the MSVC mode). Reverted the change here.


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