clang-tools 22.0.0git
InfiniteLoopCheck.cpp File Reference
#include "InfiniteLoopCheck.h"
#include "../utils/Aliasing.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
#include "clang/Analysis/CallGraph.h"
#include "llvm/ADT/SCCIterator.h"

Go to the source code of this file.

Namespaces

namespace  clang
 ===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
namespace  clang::tidy
namespace  clang::tidy::bugprone

Functions

static Matcher< Stmt > clang::tidy::bugprone::loopEndingStmt (Matcher< Stmt > Internal)
static bool clang::tidy::bugprone::isChanged (const Stmt *LoopStmt, const ValueDecl *Var, ASTContext *Context)
 Return whether Var was changed in LoopStmt.
static bool clang::tidy::bugprone::isVarPossiblyChanged (const Decl *Func, const Stmt *LoopStmt, const ValueDecl *VD, ASTContext *Context)
static bool clang::tidy::bugprone::isVarThatIsPossiblyChanged (const Decl *Func, const Stmt *LoopStmt, const Stmt *Cond, ASTContext *Context)
 Return whether Cond is a variable that is possibly changed in LoopStmt.
static bool clang::tidy::bugprone::isAtLeastOneCondVarChanged (const Decl *Func, const Stmt *LoopStmt, const Stmt *Cond, ASTContext *Context)
 Return whether at least one variable of Cond changed in LoopStmt.
static std::string clang::tidy::bugprone::getCondVarNames (const Stmt *Cond)
 Return the variable names in Cond.
static bool clang::tidy::bugprone::isKnownToHaveValue (const Expr &Cond, const ASTContext &Ctx, bool ExpectedValue)
static bool clang::tidy::bugprone::populateCallees (const Stmt *StmtNode, llvm::SmallPtrSet< const Decl *, 16 > &Callees)
 populates the set Callees with all function (and objc method) declarations called in StmtNode if all visited call sites have resolved call targets.
static bool clang::tidy::bugprone::overlap (ArrayRef< CallGraphNode * > SCC, const llvm::SmallPtrSet< const Decl *, 16 > &Callees, const Decl *Func)
 returns true iff SCC contains Func and its' function set overlaps with Callees
static bool clang::tidy::bugprone::hasStaticLocalVariable (const Stmt *Cond)
 returns true iff Cond involves at least one static local variable.
static bool clang::tidy::bugprone::hasRecursionOverStaticLoopCondVariables (const Expr *Cond, const Stmt *LoopStmt, const Decl *Func, const ASTContext *Ctx)
 Tests if the loop condition Cond involves static local variables and the enclosing function Func is recursive.
bool hasPtrOrReferenceInFunc (const Decl *Func, const ValueDecl *Var)
 Returns whether Var has a pointer or reference in Func.

Function Documentation

◆ hasPtrOrReferenceInFunc()

bool clang::tidy::utils::hasPtrOrReferenceInFunc ( const Decl * Func,
const ValueDecl * Var )

Returns whether Var has a pointer or reference in Func.

Example: void f() { int n; ... int *p = &n; }

For f() and n the function returns true because p is a / pointer to n created in f().

Definition at line 92 of file Aliasing.cpp.

Referenced by clang::tidy::bugprone::RedundantBranchConditionCheck::check(), and clang::tidy::bugprone::isVarPossiblyChanged().