[libc++] Fixes clang-tidy plugin for clang-tidy 17.

When using with clang-tidy 17 Node.getAttrName() sometimes returns a
nullptr. This caused segfaults in the CI.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D151224
This commit is contained in:
Mark de Wever 2023-05-23 17:22:12 +02:00
parent 94daee2e73
commit 81fb5a0e1c

View File

@ -69,7 +69,7 @@ std::vector<const char*> get_standard_attributes(const clang::LangOptions& lang_
}
AST_MATCHER(clang::Attr, isPretty) {
if (Node.isKeywordAttribute())
if (Node.isKeywordAttribute() || !Node.getAttrName())
return false;
if (Node.isCXX11Attribute() && !Node.hasScope()) {
if (isUgly(Node.getAttrName()->getName()))
@ -80,8 +80,7 @@ AST_MATCHER(clang::Attr, isPretty) {
if (Node.hasScope())
if (!isUgly(Node.getScopeName()->getName()))
return true;
if (Node.getAttrName())
return !isUgly(Node.getAttrName()->getName());
return !isUgly(Node.getAttrName()->getName());
return false;
}