clang-tools 6.0.0

DeclRefExprUtils.h
Go to the documentation of this file.
1 //===--- DeclRefExprUtils.h - clang-tidy-------------------------*- C++ -*-===//
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_DECLREFEXPRUTILS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
12
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/Type.h"
15 #include "llvm/ADT/SmallPtrSet.h"
16
17 namespace clang {
18 namespace tidy {
19 namespace utils {
20 namespace decl_ref_expr {
21
22 /// \brief Returns true if all ``DeclRefExpr`` to the variable within ``Stmt``
23 /// do not modify it.
24 ///
25 /// Returns ``true`` if only const methods or operators are called on the
26 /// variable or the variable is a const reference or value argument to a
27 /// ``callExpr()``.
28 bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
29 ASTContext &Context);
30
31 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt``.
32 llvm::SmallPtrSet<const DeclRefExpr *, 16>
33 allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context);
34
35 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl``.
36 llvm::SmallPtrSet<const DeclRefExpr *, 16>
37 allDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context);
38
39 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt`` where
40 /// ``VarDecl`` is guaranteed to be accessed in a const fashion.
41 llvm::SmallPtrSet<const DeclRefExpr *, 16>
42 constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
43 ASTContext &Context);
44
45 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl`` where
46 /// ``VarDecl`` is guaranteed to be accessed in a const fashion.
47 llvm::SmallPtrSet<const DeclRefExpr *, 16>
48 constReferenceDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl,
49 ASTContext &Context);
50
51 /// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-constructor
52 /// call expression within ``Decl``.
53 bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
54 ASTContext &Context);
55
56 /// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-assignment
57 /// operator CallExpr within ``Decl``.
58 bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
59 ASTContext &Context);
60
61 } // namespace decl_ref_expr
62 } // namespace utils
63 } // namespace tidy
64 } // namespace clang
65
66 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
clang::tidy::utils::decl_ref_expr::allDeclRefExprs
SmallPtrSet< const DeclRefExpr *, 16 > allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context)
Returns set of all DeclRefExprs to VarDecl within Stmt.
Definition: DeclRefExprUtils.cpp:121
clang::tidy::utils::decl_ref_expr::isCopyConstructorArgument
bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl, ASTContext &Context)
Returns true if DeclRefExpr is the argument of a copy-constructor call expression within Decl...
Definition: DeclRefExprUtils.cpp:141
clang::tidy::utils::decl_ref_expr::isOnlyUsedAsConst
bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt, ASTContext &Context)
Returns true if all DeclRefExpr to the variable within Stmt do not modify it.
Definition: DeclRefExprUtils.cpp:108
clang::tidy::utils::decl_ref_expr::constReferenceDeclRefExprs
SmallPtrSet< const DeclRefExpr *, 16 > constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context)
Returns set of all DeclRefExprs to VarDecl within Stmt where VarDecl is guaranteed to be accessed in ...
Definition: DeclRefExprUtils.cpp:46
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::utils::decl_ref_expr::isCopyAssignmentArgument
bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl, ASTContext &Context)
Returns true if DeclRefExpr is the argument of a copy-assignment operator CallExpr within Decl...
Definition: DeclRefExprUtils.cpp:155
DeclRef
const DeclRefExpr * DeclRef
Definition: UseAfterMoveCheck.cpp:30