[Clang] Fix crash when visting a fold expression in a default argument (#67514)

CheckDefaultArgumentVisitor::Visit(...) assumes that the children of
Expr will not be NULL. This is not a valid assumption and when we have a
CXXFoldExpr the children can be NULL and this causes a crash.

Fixes: https://github.com/llvm/llvm-project/issues/67395
This commit is contained in:
Shafik Yaghmour 2023-09-28 12:20:22 -07:00 committed by GitHub
parent 36a518317f
commit 8f768ec005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -363,6 +363,10 @@ Bug Fixes to C++ Support
in the enclosing expression of a lambda expression with a noexcept specifier.
(`#67492 <https://github.com/llvm/llvm-project/issues/67492>`_)
- Fix crash when fold expression was used in the initialization of default
argument. Fixes:
(`#67395 <https://github.com/llvm/llvm-project/issues/67395>`_)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an import failure of recursive friend class template.

View File

@ -86,7 +86,8 @@ public:
bool CheckDefaultArgumentVisitor::VisitExpr(const Expr *Node) {
bool IsInvalid = false;
for (const Stmt *SubStmt : Node->children())
IsInvalid |= Visit(SubStmt);
if (SubStmt)
IsInvalid |= Visit(SubStmt);
return IsInvalid;
}

View File

@ -124,3 +124,11 @@ namespace PR30738 {
int test_h3 = h<struct X>(1, 2, 3);
N::S test_h4 = h<struct X>(N::S(), N::S(), N::S()); // expected-note {{instantiation of}}
}
namespace GH67395 {
template <typename>
bool f();
template <typename... T>
void g(bool = (f<T>() || ...));
}