clang-tools 6.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, isAssignmentOperator) {
21 return Node.isAssignmentOp();
22 }
23
24 AST_MATCHER(BinaryOperator, isRelationalOperator) {
25 return Node.isRelationalOp();
26 }
27
28 AST_MATCHER(BinaryOperator, isEqualityOperator) { return Node.isEqualityOp(); }
29
30 AST_MATCHER(BinaryOperator, isComparisonOperator) {
31 return Node.isComparisonOp();
32 }
33
34 AST_MATCHER(QualType, isExpensiveToCopy) {
35 llvm::Optional<bool> IsExpensive =
36 utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
37 return IsExpensive && *IsExpensive;
38 }
39
40 AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {
41 return utils::type_traits::recordIsTriviallyDefaultConstructible(
42 Node, Finder->getASTContext());
43 }
44
45 // Returns QualType matcher for references to const.
46 AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) {
47 using namespace ast_matchers;
48 return referenceType(pointee(qualType(isConstQualified())));
49 }
50
51 } // namespace matchers
52 } // namespace tidy
53 } // namespace clang
54
55 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
clang::tidy::matchers::AST_MATCHER
AST_MATCHER(BinaryOperator, isAssignmentOperator)
Definition: Matchers.h:20
TypeTraits.h
clang::tidy::matchers::AST_MATCHER_FUNCTION
AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst)
Definition: Matchers.h:46
clang::tidy::utils::type_traits::recordIsTriviallyDefaultConstructible
bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, const ASTContext &Context)
Returns true if RecordDecl is trivially default constructible.
Definition: TypeTraits.cpp:51
clang::tidy::utils::type_traits::isExpensiveToCopy
llvm::Optional< bool > isExpensiveToCopy(QualType Type, const ASTContext &Context)
Returns true if Type is expensive to copy.
Definition: TypeTraits.cpp:42
clang::tidy::utils::type_traits::isTriviallyDefaultConstructible
bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context)
Returns true if Type is trivially default constructible.
Definition: TypeTraits.cpp:88
clang
Definition: AndroidTidyModule.cpp:28