clang 19.0.0git
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
clang::ento::NoOwnershipChangeVisitor Class Referenceabstract

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h"

Inheritance diagram for clang::ento::NoOwnershipChangeVisitor:
Inheritance graph
[legend]

Public Types

using OwnerSet = llvm::SmallPtrSet< const MemRegion *, 8 >
 

Public Member Functions

 NoOwnershipChangeVisitor (SymbolRef Sym, const CheckerBase *Checker)
 
void Profile (llvm::FoldingSetNodeID &ID) const override
 
- Public Member Functions inherited from clang::ento::NoStateChangeFuncVisitor
 NoStateChangeFuncVisitor (bugreporter::TrackingKind TKind)
 
PathDiagnosticPieceRef VisitNode (const ExplodedNode *N, BugReporterContext &BR, PathSensitiveBugReport &R) final
 Return a diagnostic piece which should be associated with the given node.
 
- Public Member Functions inherited from clang::ento::BugReporterVisitor
 BugReporterVisitor ()=default
 
 BugReporterVisitor (const BugReporterVisitor &)=default
 
 BugReporterVisitor (BugReporterVisitor &&)
 
BugReporterVisitoroperator= (const BugReporterVisitor &)=delete
 
BugReporterVisitoroperator= (BugReporterVisitor &&)=delete
 
virtual ~BugReporterVisitor ()
 
virtual PathDiagnosticPieceRef VisitNode (const ExplodedNode *Succ, BugReporterContext &BRC, PathSensitiveBugReport &BR)=0
 Return a diagnostic piece which should be associated with the given node.
 
virtual void finalizeVisitor (BugReporterContext &BRC, const ExplodedNode *EndPathNode, PathSensitiveBugReport &BR)
 Last function called on the visitor, no further calls to VisitNode would follow.
 
virtual PathDiagnosticPieceRef getEndPath (BugReporterContext &BRC, const ExplodedNode *N, PathSensitiveBugReport &BR)
 Provide custom definition for the final diagnostic piece on the path - the piece, which is displayed before the path is expanded.
 
virtual void Profile (llvm::FoldingSetNodeID &ID) const =0
 

Protected Member Functions

virtual bool doesFnIntendToHandleOwnership (const Decl *Callee, ASTContext &ACtx)=0
 Heuristically guess whether the callee intended to free the resource.
 
virtual bool hasResourceStateChanged (ProgramStateRef CallEnterState, ProgramStateRef CallExitEndState)=0
 
bool wasModifiedInFunction (const ExplodedNode *CallEnterN, const ExplodedNode *CallExitEndN) final
 
virtual PathDiagnosticPieceRef emitNote (const ExplodedNode *N)=0
 
PathDiagnosticPieceRef maybeEmitNoteForObjCSelf (PathSensitiveBugReport &R, const ObjCMethodCall &Call, const ExplodedNode *N) final
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 
PathDiagnosticPieceRef maybeEmitNoteForCXXThis (PathSensitiveBugReport &R, const CXXConstructorCall &Call, const ExplodedNode *N) final
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 
PathDiagnosticPieceRef maybeEmitNoteForParameters (PathSensitiveBugReport &R, const CallEvent &Call, const ExplodedNode *N) final
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 
- Protected Member Functions inherited from clang::ento::NoStateChangeFuncVisitor
virtual bool wasModifiedBeforeCallExit (const ExplodedNode *CurrN, const ExplodedNode *CallExitBeginN)
 
virtual bool wasModifiedInFunction (const ExplodedNode *CallEnterN, const ExplodedNode *CallExitEndN)
 
virtual PathDiagnosticPieceRef maybeEmitNoteForObjCSelf (PathSensitiveBugReport &R, const ObjCMethodCall &Call, const ExplodedNode *N)=0
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 
virtual PathDiagnosticPieceRef maybeEmitNoteForCXXThis (PathSensitiveBugReport &R, const CXXConstructorCall &Call, const ExplodedNode *N)=0
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 
virtual PathDiagnosticPieceRef maybeEmitNoteForParameters (PathSensitiveBugReport &R, const CallEvent &Call, const ExplodedNode *N)=0
 Consume the information on the non-modifying stack frame in order to either emit a note or not.
 

Static Protected Member Functions

static LLVM_DUMP_METHOD std::string getFunctionName (const ExplodedNode *CallEnterN)
 

Protected Attributes

SymbolRef Sym
 
const CheckerBaseChecker
 
- Protected Attributes inherited from clang::ento::NoStateChangeFuncVisitor
bugreporter::TrackingKind TKind
 

Additional Inherited Members

- Static Public Member Functions inherited from clang::ento::BugReporterVisitor
static PathDiagnosticPieceRef getDefaultEndPath (const BugReporterContext &BRC, const ExplodedNode *N, const PathSensitiveBugReport &BR)
 Generates the default final diagnostic piece.
 

Detailed Description

Definition at line 16 of file NoOwnershipChangeVisitor.h.

Member Typedef Documentation

◆ OwnerSet

Definition at line 60 of file NoOwnershipChangeVisitor.h.

Constructor & Destructor Documentation

◆ NoOwnershipChangeVisitor()

clang::ento::NoOwnershipChangeVisitor::NoOwnershipChangeVisitor ( SymbolRef  Sym,
const CheckerBase Checker 
)
inline

Definition at line 66 of file NoOwnershipChangeVisitor.h.

Member Function Documentation

◆ doesFnIntendToHandleOwnership()

virtual bool clang::ento::NoOwnershipChangeVisitor::doesFnIntendToHandleOwnership ( const Decl Callee,
ASTContext ACtx 
)
protectedpure virtual

Heuristically guess whether the callee intended to free the resource.

This is done syntactically, because we are trying to argue about alternative paths of execution, and as a consequence we don't have path-sensitive information.

Referenced by wasModifiedInFunction().

◆ emitNote()

virtual PathDiagnosticPieceRef clang::ento::NoOwnershipChangeVisitor::emitNote ( const ExplodedNode N)
protectedpure virtual

◆ getFunctionName()

LLVM_DUMP_METHOD std::string NoOwnershipChangeVisitor::getFunctionName ( const ExplodedNode CallEnterN)
staticprotected

◆ hasResourceStateChanged()

virtual bool clang::ento::NoOwnershipChangeVisitor::hasResourceStateChanged ( ProgramStateRef  CallEnterState,
ProgramStateRef  CallExitEndState 
)
protectedpure virtual

Referenced by wasModifiedInFunction().

◆ maybeEmitNoteForCXXThis()

PathDiagnosticPieceRef clang::ento::NoOwnershipChangeVisitor::maybeEmitNoteForCXXThis ( PathSensitiveBugReport R,
const CXXConstructorCall Call,
const ExplodedNode N 
)
inlinefinalprotectedvirtual

Consume the information on the non-modifying stack frame in order to either emit a note or not.

May suppress the report entirely.

Returns
Diagnostics piece for the unmodified state in the current function, if it decides to emit one. A good description might start with "Returning without...".

Implements clang::ento::NoStateChangeFuncVisitor.

Definition at line 47 of file NoOwnershipChangeVisitor.h.

◆ maybeEmitNoteForObjCSelf()

PathDiagnosticPieceRef clang::ento::NoOwnershipChangeVisitor::maybeEmitNoteForObjCSelf ( PathSensitiveBugReport R,
const ObjCMethodCall Call,
const ExplodedNode N 
)
inlinefinalprotectedvirtual

Consume the information on the non-modifying stack frame in order to either emit a note or not.

May suppress the report entirely.

Returns
Diagnostics piece for the unmodified state in the current function, if it decides to emit one. A good description might start with "Returning without...".

Implements clang::ento::NoStateChangeFuncVisitor.

Definition at line 40 of file NoOwnershipChangeVisitor.h.

◆ maybeEmitNoteForParameters()

PathDiagnosticPieceRef NoOwnershipChangeVisitor::maybeEmitNoteForParameters ( PathSensitiveBugReport R,
const CallEvent Call,
const ExplodedNode N 
)
finalprotectedvirtual

Consume the information on the non-modifying stack frame in order to either emit a note or not.

May suppress the report entirely.

Returns
Diagnostics piece for the unmodified state in the current function, if it decides to emit one. A good description might start with "Returning without...".

Implements clang::ento::NoStateChangeFuncVisitor.

Definition at line 105 of file NoOwnershipChangeVisitor.cpp.

References clang::Call, emitNote(), Sym, and V.

◆ Profile()

void clang::ento::NoOwnershipChangeVisitor::Profile ( llvm::FoldingSetNodeID &  ID) const
inlineoverridevirtual

Implements clang::ento::BugReporterVisitor.

Definition at line 70 of file NoOwnershipChangeVisitor.h.

References ID, and Sym.

◆ wasModifiedInFunction()

bool NoOwnershipChangeVisitor::wasModifiedInFunction ( const ExplodedNode CallEnterN,
const ExplodedNode CallExitEndN 
)
finalprotectedvirtual
Returns
Whether the state was modified in the inlined function call in between CallEnterN and CallExitEndN. Mind that the stack frame retrieved from a CallEnterN and CallExitEndN is the caller's stack frame! The inlined function's stack should be retrieved from either the immediate successor to CallEnterN or immediate predecessor to CallExitEndN. Clients should override this function if a state changes local to the inlined function are not interesting, only the change occuring as a result of it. Example: we want to leave a not about a leaked resource object not being deallocated / its ownership changed inside a function, and we don't care if it was assigned to a local variable (its change in ownership is inconsequential).

Reimplemented from clang::ento::NoStateChangeFuncVisitor.

Definition at line 71 of file NoOwnershipChangeVisitor.cpp.

References doesFnIntendToHandleOwnership(), clang::LocationContext::getDecl(), clang::ento::ExplodedNode::getFirstPred(), clang::ento::ExplodedNode::getLocationContext(), clang::ento::ExplodedNode::getState(), clang::FunctionDecl::hasBody(), and hasResourceStateChanged().

Member Data Documentation

◆ Checker

const CheckerBase& clang::ento::NoOwnershipChangeVisitor::Checker
protected

Definition at line 20 of file NoOwnershipChangeVisitor.h.

◆ Sym

SymbolRef clang::ento::NoOwnershipChangeVisitor::Sym
protected

Definition at line 19 of file NoOwnershipChangeVisitor.h.

Referenced by maybeEmitNoteForParameters(), and Profile().


The documentation for this class was generated from the following files: