From 81fb5a0e1cf8550ad20700ea1461030de0bc052d Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Tue, 23 May 2023 17:22:12 +0200 Subject: [PATCH] [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 --- libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp index c4a51fa..5252087 100644 --- a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp +++ b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp @@ -69,7 +69,7 @@ std::vector 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; } -- 2.7.4