[all-commits] [llvm/llvm-project] a1879e: Fix crash on invalid code involving late parsed in...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Thu Dec 16 04:59:07 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a1879e52e3ae9424b59747d9b837a7a87bcb996d
      https://github.com/llvm/llvm-project/commit/a1879e52e3ae9424b59747d9b837a7a87bcb996d
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2021-12-16 (Thu, 16 Dec 2021)

  Changed paths:
    M clang/lib/Parse/ParseCXXInlineMethods.cpp
    M clang/test/Parser/cxx1z-class-template-argument-deduction.cpp

  Log Message:
  -----------
  Fix crash on invalid code involving late parsed inline methods

When parsing the following construct, we parse it as an erroneous
deduction guide declaration and correctly diagnose the issues with it.

template<class> struct B;
struct A { B() noexcept(false); };

However, we then go on to finish late parsing the declaration and this
expects that what we've parsed is a CXXMethodDecl. A
CXXDeductionGuideDecl is not a CXXMethodDecl (it's a FunctionDecl), and
so we assert on the cast.

This fixes the crash by switching from cast<> to dyn_cast<> and not
setting up a "this" scope when the declaration is not a CXXMethodDecl.

This fixes PR49735.




More information about the All-commits mailing list