clang-tools  5.0.0
Matchers.h
Go to the documentation of this file.
1 //===--- Matchers.h - clang-tidy-------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
12 
13 #include "TypeTraits.h"
14 #include "clang/ASTMatchers/ASTMatchers.h"
15 
16 namespace clang {
17 namespace tidy {
18 namespace matchers {
19 
20 AST_MATCHER(BinaryOperator, isRelationalOperator) {
21  return Node.isRelationalOp();
22 }
23 
24 AST_MATCHER(BinaryOperator, isEqualityOperator) { return Node.isEqualityOp(); }
25 
26 AST_MATCHER(BinaryOperator, isComparisonOperator) {
27  return Node.isComparisonOp();
28 }
29 
31  llvm::Optional<bool> IsExpensive =
32  utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
33  return IsExpensive && *IsExpensive;
34 }
35 
38  Node, Finder->getASTContext());
39 }
40 
41 // Returns QualType matcher for references to const.
42 AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) {
43  using namespace ast_matchers;
44  return referenceType(pointee(qualType(isConstQualified())));
45 }
46 
47 } // namespace matchers
48 } // namespace tidy
49 } // namespace clang
50 
51 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:275
AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst)
Definition: Matchers.h:42
bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, const ASTContext &Context)
Returns true if RecordDecl is trivially default constructible.
Definition: TypeTraits.cpp:51
llvm::Optional< bool > isExpensiveToCopy(QualType Type, const ASTContext &Context)
Returns true if Type is expensive to copy.
Definition: TypeTraits.cpp:42
bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context)
Returns true if Type is trivially default constructible.
Definition: TypeTraits.cpp:88
AST_MATCHER(BinaryOperator, isRelationalOperator)
Definition: Matchers.h:20