clang 22.0.0git
clang::ento::CXXDestructorCall Class Reference

Represents an implicit call to a C++ destructor. More...

#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"

Inheritance diagram for clang::ento::CXXDestructorCall:
[legend]

Public Member Functions

SourceRange getSourceRange () const override
 Returns a source range for the entire call, suitable for outputting in diagnostics.
unsigned getNumArgs () const override
 Returns the number of arguments (explicit and implicit).
RuntimeDefinition getRuntimeDefinition () const override
 Returns the definition of the function or method that will be called.
SVal getCXXThisVal () const override
 Returns the value of the implicit 'this' object.
bool isBaseDestructor () const
 Returns true if this is a call to a base class destructor.
Kind getKind () const override
 Returns the kind of call this is.
StringRef getKindAsString () const override
Public Member Functions inherited from clang::ento::CXXInstanceCall
virtual const ExprgetCXXThisExpr () const
 Returns the expression representing the implicit 'this' object.
const FunctionDeclgetDecl () const override
 Returns the declaration of the function or method that will be called.
RuntimeDefinition getRuntimeDefinition () const override
 Returns the definition of the function or method that will be called.
void getInitialStackFrameContents (const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
 Populates the given SmallVector with the bindings in the callee's stack frame at the start of this call.
Public Member Functions inherited from clang::ento::AnyFunctionCall
bool argumentsMayEscape () const override
 Returns true if any of the arguments are known to escape to long- term storage, even if this method will not modify them.
ArrayRef< ParmVarDecl * > parameters () const override
 Return call's formal parameters.
Public Member Functions inherited from clang::ento::CallEvent
CallEventoperator= (const CallEvent &)=delete
virtual ~CallEvent ()=default
bool isForeign () const
void setForeign (bool B) const
const ProgramStateRefgetState () const
 The state in which the call is being evaluated.
const LocationContextgetLocationContext () const
 The context in which the call is being evaluated.
const CFGBlock::ConstCFGElementRefgetCFGElementRef () const
virtual const ExprgetOriginExpr () const
 Returns the expression whose value will be the result of this call.
bool isInSystemHeader () const
 Returns true if the callee is known to be from a system header.
virtual SVal getArgSVal (unsigned Index) const
 Returns the value of a given argument at the time of the call.
virtual const ExprgetArgExpr (unsigned Index) const
 Returns the expression associated with a given argument.
virtual SourceRange getArgSourceRange (unsigned Index) const
 Returns the source range for errors associated with this argument.
QualType getResultType () const
 Returns the result type, adjusted for references.
SVal getReturnValue () const
 Returns the return value of the call.
bool hasNonNullArgumentsWithType (bool(*Condition)(QualType)) const
 Returns true if the type of any of the non-null arguments satisfies the condition.
bool hasNonZeroCallbackArg () const
 Returns true if any of the arguments appear to represent callbacks.
bool hasVoidPointerToNonConstArg () const
 Returns true if any of the arguments is void*.
bool isGlobalCFunction (StringRef SpecificName=StringRef()) const
 Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc.
const IdentifierInfogetCalleeIdentifier () const
 Returns the name of the callee, if its name is a simple identifier.
ProgramPoint getProgramPoint (bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
 Returns an appropriate ProgramPoint for this call.
ProgramStateRef invalidateRegions (unsigned BlockCount, ProgramStateRef Orig=nullptr) const
 Returns a new state with all argument regions invalidated.
template<typename T>
CallEventRef< TcloneWithState (ProgramStateRef NewState) const
 Returns a copy of this CallEvent, but using the given state.
CallEventRef cloneWithState (ProgramStateRef NewState) const
 Returns a copy of this CallEvent, but using the given state.
AnalysisDeclContextgetCalleeAnalysisDeclContext () const
 Returns AnalysisDeclContext for the callee stack frame.
const StackFrameContextgetCalleeStackFrame (unsigned BlockCount) const
 Returns the callee stack frame.
const ParamVarRegiongetParameterLocation (unsigned Index, unsigned BlockCount) const
 Returns memory location for a parameter variable within the callee stack frame.
bool isArgumentConstructedDirectly (unsigned Index) const
 Returns true if on the current path, the argument was constructed by calling a C++ constructor over it.
virtual std::optional< unsignedgetAdjustedParameterIndex (unsigned ASTArgumentIndex) const
 Some calls have parameter numbering mismatched from argument numbering.
virtual unsigned getASTArgumentIndex (unsigned CallArgumentIndex) const
 Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
const ConstructionContextgetConstructionContext () const
 Returns the construction context of the call, if it is a C++ constructor call or a call of a function returning a C++ class instance.
std::optional< SValgetReturnValueUnderConstruction () const
 If the call returns a C++ record type then the region of its return value can be retrieved from its construction context.
const CallEventRef getCaller () const
bool isCalledFromSystemHeader () const
param_type_iterator param_type_begin () const
 Returns an iterator over the types of the call's formal parameters.
param_type_iterator param_type_end () const
void dump (raw_ostream &Out) const
void dump () const

Static Public Member Functions

static bool classof (const CallEvent *CA)
Static Public Member Functions inherited from clang::ento::CXXInstanceCall
static bool classof (const CallEvent *CA)
Static Public Member Functions inherited from clang::ento::AnyFunctionCall
static bool classof (const CallEvent *CA)
Static Public Member Functions inherited from clang::ento::CallEvent
static bool isCallStmt (const Stmt *S)
 Returns true if this is a statement is a function or method call of some kind.
static QualType getDeclaredResultType (const Decl *D)
 Returns the result type of a function or method declaration.
static bool isVariadic (const Decl *D)
 Returns true if the given decl is known to be variadic.

Protected Types

using DtorDataTy = llvm::PointerIntPair<const MemRegion *, 1, bool>
Protected Types inherited from clang::ento::CallEvent
using ValueList = SmallVectorImpl<SVal>

Protected Member Functions

 CXXDestructorCall (const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBaseDestructor, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 Creates an implicit destructor.
 CXXDestructorCall (const CXXDestructorCall &Other)=default
void cloneTo (void *Dest) const override
 Copies this CallEvent, with vtable intact, into a new block of memory.
Protected Member Functions inherited from clang::ento::CXXInstanceCall
 CXXInstanceCall (const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 CXXInstanceCall (const FunctionDecl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 CXXInstanceCall (const CXXInstanceCall &Other)=default
void getExtraInvalidatedValues (ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
 Used to specify non-argument regions that will be invalidated as a result of this call.
std::pair< const CXXRecordDecl *, boolgetDeclForDynamicType () const
 Returns the decl refered to by the "dynamic type" of the current object and if the class can be a sub-class or not.
Protected Member Functions inherited from clang::ento::AnyFunctionCall
 AnyFunctionCall (const Expr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 AnyFunctionCall (const Decl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 AnyFunctionCall (const AnyFunctionCall &Other)=default
Protected Member Functions inherited from clang::ento::CallEvent
 CallEvent (const Expr *E, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
 CallEvent (const Decl *D, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
 CallEvent (const CallEvent &Original)
SVal getSVal (const Stmt *S) const
 Get the value of arbitrary expressions at this point in the path.

Friends

class CallEventManager

Additional Inherited Members

Public Types inherited from clang::ento::CallEvent
using Kind = CallEventKind
using FrameBindingTy = std::pair<SVal, SVal>
using BindingsTy = SmallVectorImpl<FrameBindingTy>
using param_type_iterator
Protected Attributes inherited from clang::ento::CallEvent
const void * Data
SourceLocation Location

Detailed Description

Represents an implicit call to a C++ destructor.

This can occur at the end of a scope (for automatic objects), at the end of a full-expression (for temporaries), or as part of a delete.

Definition at line 897 of file CallEvent.h.

Member Typedef Documentation

◆ DtorDataTy

using clang::ento::CXXDestructorCall::DtorDataTy = llvm::PointerIntPair<const MemRegion *, 1, bool>
protected

Definition at line 901 of file CallEvent.h.

Constructor & Destructor Documentation

◆ CXXDestructorCall() [1/2]

clang::ento::CXXDestructorCall::CXXDestructorCall ( const CXXDestructorDecl * DD,
const Stmt * Trigger,
const MemRegion * Target,
bool IsBaseDestructor,
ProgramStateRef St,
const LocationContext * LCtx,
CFGBlock::ConstCFGElementRef ElemRef )
inlineprotected

Creates an implicit destructor.

Parameters
DDThe destructor that will be called.
TriggerThe statement whose completion causes this destructor call.
TargetThe object region to be destructed.
StThe path-sensitive state at this point in the program.
LCtxThe location context at this point in the program.
ElemRefThe reference to this destructor in the CFG.

FIXME: Eventually we want to drop

Parameters
Targetand deduce it from
ElemRef.To do that we need to migrate the logic for target region lookup from ExprEngine::ProcessImplicitDtor() and make it independent from ExprEngine.

Definition at line 916 of file CallEvent.h.

References clang::ento::CXXInstanceCall::CXXInstanceCall(), clang::ento::CallEvent::Data, clang::Stmt::getEndLoc(), clang::ento::CallEvent::Location, and clang::Target.

Referenced by cloneTo(), and CXXDestructorCall().

◆ CXXDestructorCall() [2/2]

clang::ento::CXXDestructorCall::CXXDestructorCall ( const CXXDestructorCall & Other)
protecteddefault

Member Function Documentation

◆ classof()

bool clang::ento::CXXDestructorCall::classof ( const CallEvent * CA)
inlinestatic

◆ cloneTo()

void clang::ento::CXXDestructorCall::cloneTo ( void * Dest) const
inlineoverrideprotectedvirtual

Copies this CallEvent, with vtable intact, into a new block of memory.

Implements clang::ento::CallEvent.

Definition at line 927 of file CallEvent.h.

References CXXDestructorCall().

◆ getCXXThisVal()

SVal CXXDestructorCall::getCXXThisVal ( ) const
overridevirtual

Returns the value of the implicit 'this' object.

Reimplemented from clang::ento::CXXInstanceCall.

Definition at line 980 of file CallEvent.cpp.

References clang::ento::CallEvent::Data.

◆ getKind()

Kind clang::ento::CXXDestructorCall::getKind ( ) const
inlineoverridevirtual

Returns the kind of call this is.

Implements clang::ento::CallEvent.

Definition at line 945 of file CallEvent.h.

References clang::ento::CE_CXXDestructor.

◆ getKindAsString()

StringRef clang::ento::CXXDestructorCall::getKindAsString ( ) const
inlineoverridevirtual

Implements clang::ento::CallEvent.

Definition at line 946 of file CallEvent.h.

◆ getNumArgs()

unsigned clang::ento::CXXDestructorCall::getNumArgs ( ) const
inlineoverridevirtual

Returns the number of arguments (explicit and implicit).

Note that this may be greater than the number of parameters in the callee's declaration, and that it may include arguments not written in the source.

Implements clang::ento::CallEvent.

Definition at line 933 of file CallEvent.h.

◆ getRuntimeDefinition()

RuntimeDefinition CXXDestructorCall::getRuntimeDefinition ( ) const
overridevirtual

Returns the definition of the function or method that will be called.

Reimplemented from clang::ento::AnyFunctionCall.

Definition at line 986 of file CallEvent.cpp.

References clang::ento::AnyFunctionCall::getRuntimeDefinition(), clang::ento::CXXInstanceCall::getRuntimeDefinition(), and isBaseDestructor().

◆ getSourceRange()

SourceRange clang::ento::CXXDestructorCall::getSourceRange ( ) const
inlineoverridevirtual

Returns a source range for the entire call, suitable for outputting in diagnostics.

Reimplemented from clang::ento::CallEvent.

Definition at line 932 of file CallEvent.h.

References clang::ento::CallEvent::Location.

◆ isBaseDestructor()

bool clang::ento::CXXDestructorCall::isBaseDestructor ( ) const
inline

Returns true if this is a call to a base class destructor.

Definition at line 941 of file CallEvent.h.

References clang::ento::CallEvent::Data.

Referenced by getRuntimeDefinition().

◆ CallEventManager

friend class CallEventManager
friend

Definition at line 898 of file CallEvent.h.

References CallEventManager.

Referenced by CallEventManager.


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