[MLIR] Extend MPI dialect (#123255)
[llvm-project.git] / libcxx / test / tools / clang_tidy_checks / nodebug_on_aliases.cpp
blob9b96269e5980599bc4d37f4f36d67809a147234c
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "clang-tidy/ClangTidyCheck.h"
11 #include "nodebug_on_aliases.hpp"
12 #include "utilities.hpp"
14 namespace libcpp {
15 namespace {
16 AST_MATCHER(clang::NamedDecl, isPretty) { return !is_ugly_name(Node.getName()); }
17 } // namespace
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;
24 finder->addMatcher(
25 typeAliasDecl(unless(anyOf(isPretty(), hasAttr(clang::attr::NoDebug), hasAncestor(functionDecl()))))
26 .bind("nodebug_on_internal_aliases"),
27 this);
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");
35 } // namespace libcpp