clang  16.0.0git
Classes | Namespaces | Typedefs | Functions
RetainCountDiagnostics.cpp File Reference
#include "RetainCountDiagnostics.h"
#include "RetainCountChecker.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
Include dependency graph for RetainCountDiagnostics.cpp:

Go to the source code of this file.


class  clang::ento::retaincountchecker::RefCountReportVisitor
class  clang::ento::retaincountchecker::RefLeakReportVisitor
class  VarBindingsCollector




using Bindings = llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 >


static bool isNumericLiteralExpression (const Expr *E)
static std::string getPrettyTypeName (QualType QT)
 If type represents a pointer to CXXRecordDecl, and is not a typedef, return the decl name. More...
static bool shouldGenerateNote (llvm::raw_string_ostream &os, const RefVal *PrevT, const RefVal &CurrV, bool DeallocSent)
 Write information about the type state change to os, return whether the note should be generated. More...
static Optional< unsignedfindArgIdxOfSymbol (ProgramStateRef CurrSt, const LocationContext *LCtx, SymbolRef &Sym, Optional< CallEventRef<>> CE)
 Finds argument index of the out paramter in the call S corresponding to the symbol Sym. More...
static Optional< std::stringfindMetaClassAlloc (const Expr *Callee)
static std::string findAllocatedObjectName (const Stmt *S, QualType QT)
static void generateDiagnosticsForCallLike (ProgramStateRef CurrSt, const LocationContext *LCtx, const RefVal &CurrV, SymbolRef &Sym, const Stmt *S, llvm::raw_string_ostream &os)
static const ExplodedNodegetCalleeNode (const ExplodedNode *Pred)
 Find the first node with the parent stack frame. More...
static std::shared_ptr< PathDiagnosticEventPieceannotateConsumedSummaryMismatch (const ExplodedNode *N, CallExitBegin &CallExitLoc, const SourceManager &SM, CallEventManager &CEMgr)
 Insert a diagnostic piece at function exit if a function parameter is annotated as "os_consumed", but it does not actually consume the reference. More...
static std::shared_ptr< PathDiagnosticEventPieceannotateStartParameter (const ExplodedNode *N, SymbolRef Sym, const SourceManager &SM)
 Annotate the parameter at the analysis entry point. More...
static Optional< std::stringdescribeRegion (const MemRegion *MR)
Bindings getAllVarBindingsForSymbol (ProgramStateManager &Manager, const ExplodedNode *Node, SymbolRef Sym)
static AllocationInfo GetAllocationSite (ProgramStateManager &StateMgr, const ExplodedNode *N, SymbolRef Sym)

Typedef Documentation

◆ Bindings

using Bindings = llvm::SmallVector<std::pair<const MemRegion *, SVal>, 4>

Function Documentation

◆ annotateConsumedSummaryMismatch()

static std::shared_ptr<PathDiagnosticEventPiece> annotateConsumedSummaryMismatch ( const ExplodedNode N,
CallExitBegin CallExitLoc,
const SourceManager SM,
CallEventManager CEMgr 

◆ annotateStartParameter()

static std::shared_ptr<PathDiagnosticEventPiece> annotateStartParameter ( const ExplodedNode N,
SymbolRef  Sym,
const SourceManager SM 

◆ describeRegion()

static Optional<std::string> describeRegion ( const MemRegion MR)

◆ findAllocatedObjectName()

static std::string findAllocatedObjectName ( const Stmt S,
QualType  QT 

Definition at line 203 of file RetainCountDiagnostics.cpp.

◆ findArgIdxOfSymbol()

static Optional<unsigned> findArgIdxOfSymbol ( ProgramStateRef  CurrSt,
const LocationContext LCtx,
SymbolRef Sym,
Optional< CallEventRef<>>  CE 

Finds argument index of the out paramter in the call S corresponding to the symbol Sym.

If none found, returns None.

Definition at line 169 of file RetainCountDiagnostics.cpp.

◆ findMetaClassAlloc()

static Optional<std::string> findMetaClassAlloc ( const Expr Callee)

◆ generateDiagnosticsForCallLike()

static void generateDiagnosticsForCallLike ( ProgramStateRef  CurrSt,
const LocationContext LCtx,
const RefVal &  CurrV,
SymbolRef Sym,
const Stmt S,
llvm::raw_string_ostream &  os 

Definition at line 210 of file RetainCountDiagnostics.cpp.

◆ GetAllocationSite()

static AllocationInfo GetAllocationSite ( ProgramStateManager StateMgr,
const ExplodedNode N,
SymbolRef  Sym 

◆ getAllVarBindingsForSymbol()

Bindings getAllVarBindingsForSymbol ( ProgramStateManager Manager,
const ExplodedNode Node,
SymbolRef  Sym 

◆ getCalleeNode()

static const ExplodedNode* getCalleeNode ( const ExplodedNode Pred)

◆ getPrettyTypeName()

static std::string getPrettyTypeName ( QualType  QT)

If type represents a pointer to CXXRecordDecl, and is not a typedef, return the decl name.

Otherwise, return the serialization of type.

Definition at line 83 of file RetainCountDiagnostics.cpp.

References clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::QualType::getAsString(), clang::Type::getPointeeType(), clang::QualType::isNull(), and string().

Referenced by clang::ento::retaincountchecker::RefLeakReportVisitor::getEndPath().

◆ isNumericLiteralExpression()

static bool isNumericLiteralExpression ( const Expr E)

Definition at line 74 of file RetainCountDiagnostics.cpp.

References clang::isa().

◆ shouldGenerateNote()

static bool shouldGenerateNote ( llvm::raw_string_ostream &  os,
const RefVal *  PrevT,
const RefVal &  CurrV,
bool  DeallocSent