1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "clang-tidy/ClangTidyCheck.h"
11 #include "nodebug_on_aliases.hpp"
12 #include "utilities.hpp"
16 AST_MATCHER(clang::NamedDecl
, isPretty
) { return !is_ugly_name(Node
.getName()); }
19 nodebug_on_aliases::nodebug_on_aliases(llvm::StringRef name
, clang::tidy::ClangTidyContext
* context
)
20 : clang::tidy::ClangTidyCheck(name
, context
) {}
22 void nodebug_on_aliases::registerMatchers(clang::ast_matchers::MatchFinder
* finder
) {
23 using namespace clang::ast_matchers
;
25 typeAliasDecl(unless(anyOf(isPretty(), hasAttr(clang::attr::NoDebug
), hasAncestor(functionDecl()))))
26 .bind("nodebug_on_internal_aliases"),
30 void nodebug_on_aliases::check(const clang::ast_matchers::MatchFinder::MatchResult
& result
) {
31 if (const auto* alias
= result
.Nodes
.getNodeAs
<clang::TypeAliasDecl
>("nodebug_on_internal_aliases")) {
32 diag(alias
->getBeginLoc(), "Internal aliases should always be marked _LIBCPP_NODEBUG");