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

53 lines
1.5 KiB
C++

//===--- Matchers.h - clang-tidy-------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
#include "clang/ASTMatchers/ASTMatchers.h"
#include "TypeTraits.h"
namespace clang {
namespace tidy {
namespace matchers {
AST_MATCHER_P(Expr, ignoringImplicit,
ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
}
AST_MATCHER(BinaryOperator, isRelationalOperator) {
return Node.isRelationalOp();
}
AST_MATCHER(BinaryOperator, isEqualityOperator) {
return Node.isEqualityOp();
}
AST_MATCHER(BinaryOperator, isComparisonOperator) {
return Node.isComparisonOp();
}
AST_MATCHER(QualType, isExpensiveToCopy) {
llvm::Optional<bool> IsExpensive =
utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
return IsExpensive && *IsExpensive;
}
AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {
return utils::type_traits::recordIsTriviallyDefaultConstructible(
Node, Finder->getASTContext());
}
} // namespace matchers
} // namespace tidy
} // namespace clang
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H