[libc++] Fixes clang-tidy plugin for clang-tidy 17.
authorMark de Wever <koraq@xs4all.nl>
Tue, 23 May 2023 15:22:12 +0000 (17:22 +0200)
committerMark de Wever <koraq@xs4all.nl>
Wed, 24 May 2023 16:07:12 +0000 (18:07 +0200)
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

libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp

index c4a51fa..5252087 100644 (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;
 }