clang-tools 10.0.0

DeclRefExprUtils.h
Go to the documentation of this file.
1 //===--- DeclRefExprUtils.h - clang-tidy-------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
11
12 #include "clang/AST/ASTContext.h"
13 #include "clang/AST/Type.h"
14 #include "llvm/ADT/SmallPtrSet.h"
15
16 namespace clang {
17 namespace tidy {
18 namespace utils {
19 namespace decl_ref_expr {
20
21 /// Returns true if all ``DeclRefExpr`` to the variable within ``Stmt``
22 /// do not modify it.
23 ///
24 /// Returns ``true`` if only const methods or operators are called on the
25 /// variable or the variable is a const reference or value argument to a
26 /// ``callExpr()``.
27 bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
28 ASTContext &Context);
29
30 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt``.
31 llvm::SmallPtrSet<const DeclRefExpr *, 16>
32 allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context);
33
34 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl``.
35 llvm::SmallPtrSet<const DeclRefExpr *, 16>
36 allDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context);
37
38 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt`` where
39 /// ``VarDecl`` is guaranteed to be accessed in a const fashion.
40 llvm::SmallPtrSet<const DeclRefExpr *, 16>
41 constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
42 ASTContext &Context);
43
44 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl`` where
45 /// ``VarDecl`` is guaranteed to be accessed in a const fashion.
46 llvm::SmallPtrSet<const DeclRefExpr *, 16>
47 constReferenceDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl,
48 ASTContext &Context);
49
50 /// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-constructor
51 /// call expression within ``Decl``.
52 bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
53 ASTContext &Context);
54
55 /// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-assignment
56 /// operator CallExpr within ``Decl``.
57 bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
58 ASTContext &Context);
59
60 } // namespace decl_ref_expr
61 } // namespace utils
62 } // namespace tidy
63 } // namespace clang
64
65 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
Decl
const FunctionDecl * Decl
Definition: AvoidBindCheck.cpp:93
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:120
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:140
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:107
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:45
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
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:154
DeclRef
const DeclRefExpr * DeclRef
Definition: UseAfterMoveCheck.cpp:29