clang-tools 19.0.0git
Functions
clang::tidy::utils::decl_ref_expr Namespace Reference

Functions

SmallPtrSet< const DeclRefExpr *, 16 > constReferenceDeclRefExprs (const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context, int Indirections)
 Returns set of all DeclRefExprs to VarDecl within Stmt where VarDecl is guaranteed to be accessed in a const fashion.
 
bool isOnlyUsedAsConst (const VarDecl &Var, const Stmt &Stmt, ASTContext &Context, int Indirections)
 Returns true if all DeclRefExpr to the variable within Stmt do not modify it.
 
SmallPtrSet< const DeclRefExpr *, 16 > allDeclRefExprs (const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context)
 Returns set of all DeclRefExprs to VarDecl within Stmt.
 
SmallPtrSet< const DeclRefExpr *, 16 > allDeclRefExprs (const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context)
 Returns set of all DeclRefExprs to VarDecl within Decl.
 
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.
 
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.
 

Function Documentation

◆ allDeclRefExprs() [1/2]

llvm::SmallPtrSet< const DeclRefExpr *, 16 > clang::tidy::utils::decl_ref_expr::allDeclRefExprs ( const VarDecl &  VarDecl,
const Decl Decl,
ASTContext &  Context 
)

Returns set of all DeclRefExprs to VarDecl within Decl.

Definition at line 231 of file DeclRefExprUtils.cpp.

References allDeclRefExprs(), and Decl.

◆ allDeclRefExprs() [2/2]

llvm::SmallPtrSet< const DeclRefExpr *, 16 > clang::tidy::utils::decl_ref_expr::allDeclRefExprs ( const VarDecl &  VarDecl,
const Stmt &  Stmt,
ASTContext &  Context 
)

◆ constReferenceDeclRefExprs()

llvm::SmallPtrSet< const DeclRefExpr *, 16 > clang::tidy::utils::decl_ref_expr::constReferenceDeclRefExprs ( const VarDecl &  VarDecl,
const Stmt &  Stmt,
ASTContext &  Context,
int  Indirections 
)

Returns set of all DeclRefExprs to VarDecl within Stmt where VarDecl is guaranteed to be accessed in a const fashion.

If VarDecl is of pointer type, Indirections specifies the level of indirection of the object whose mutations we are tracking.

For example, given:

int i;
int* p;
p = &i; // (A)
*p = 3; // (B)
  • constReferenceDeclRefExprs(P, Stmt, Context, 0) returns the reference

constReferenceDeclRefExprs(P, Stmt, Context, 1) returns the reference

Definition at line 195 of file DeclRefExprUtils.cpp.

Referenced by isOnlyUsedAsConst().

◆ isCopyAssignmentArgument()

bool clang::tidy::utils::decl_ref_expr::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 at line 255 of file DeclRefExprUtils.cpp.

References Decl, and DeclRef.

Referenced by clang::tidy::performance::UnnecessaryValueParamCheck::check().

◆ isCopyConstructorArgument()

bool clang::tidy::utils::decl_ref_expr::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 at line 241 of file DeclRefExprUtils.cpp.

References Decl, and DeclRef.

Referenced by clang::tidy::performance::UnnecessaryValueParamCheck::check().

◆ isOnlyUsedAsConst()

bool clang::tidy::utils::decl_ref_expr::isOnlyUsedAsConst ( const VarDecl &  Var,
const Stmt &  Stmt,
ASTContext &  Context,
int  Indirections 
)

Returns true if all DeclRefExpr to the variable within Stmt do not modify it.

See constReferenceDeclRefExprs for the meaning of Indirections.

Definition at line 207 of file DeclRefExprUtils.cpp.

References allDeclRefExprs(), constReferenceDeclRefExprs(), and isOnlyUsedAsConst().

Referenced by isOnlyUsedAsConst().