llvm/clang-tools-extra/clang-tidy/utils/Matchers.h

//===--- Matchers.h - clang-tidy-------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H

#include "TypeTraits.h"
#include "clang/AST/ExprConcepts.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include <optional>

namespace clang::tidy::matchers {

AST_MATCHER(BinaryOperator, isRelationalOperator) {}

AST_MATCHER(BinaryOperator, isEqualityOperator) {}

AST_MATCHER(QualType, isExpensiveToCopy) {}

AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {}

AST_MATCHER(QualType, isTriviallyDestructible) {}

// Returns QualType matcher for references to const.
AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) {}

// Returns QualType matcher for pointers to const.
AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {}

// Returns QualType matcher for target char type only.
AST_MATCHER(QualType, isSimpleChar) {}

AST_MATCHER(Expr, hasUnevaluatedContext) {}

// A matcher implementation that matches a list of type name regular expressions
// against a NamedDecl. If a regular expression contains the substring "::"
// matching will occur against the qualified name, otherwise only the typename.
class MatchesAnyListedNameMatcher
    : public ast_matchers::internal::MatcherInterface<NamedDecl> {};

// Returns a matcher that matches NamedDecl's against a list of provided regular
// expressions. If a regular expression contains starts ':' the NamedDecl's
// qualified name will be used for matching, otherwise its name will be used.
inline ::clang::ast_matchers::internal::Matcher<NamedDecl>
matchesAnyListedName(llvm::ArrayRef<StringRef> NameList) {}

// Predicate that verify if statement is not identical to one bound to ID node.
struct NotIdenticalStatementsPredicate {};

// Checks if statement is identical (utils::areStatementsIdentical) to one bound
// to ID node.
AST_MATCHER_P(Stmt, isStatementIdenticalToBoundNode, std::string, ID) {}

// A matcher implementation that matches a list of type name regular expressions
// against a QualType.
class MatchesAnyListedTypeNameMatcher
    : public ast_matchers::internal::MatcherInterface<QualType> {};

// Returns a matcher that matches QualType against a list of provided regular.
inline ::clang::ast_matchers::internal::Matcher<QualType>
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList) {}

} // namespace clang::tidy::matchers

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H