clang 20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
clang::ento::BlockCall Class Reference

Represents a call to a block. More...

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

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

Public Member Functions

const CallExprgetOriginExpr () const override
 Returns the expression whose value will be the result of this call.
 
unsigned getNumArgs () const override
 Returns the number of arguments (explicit and implicit).
 
const ExprgetArgExpr (unsigned Index) const override
 Returns the expression associated with a given argument.
 
const BlockDataRegiongetBlockRegion () const
 Returns the region associated with this instance of the block.
 
const BlockDeclgetDecl () const override
 Returns the declaration of the function or method that will be called.
 
bool isConversionFromLambda () const
 
const VarRegiongetRegionStoringCapturedLambda () const
 For a block converted from a C++ lambda, returns the block VarRegion for the variable holding the captured C++ lambda record.
 
RuntimeDefinition getRuntimeDefinition () const override
 Returns the definition of the function or method that will be called.
 
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.
 
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.
 
ArrayRef< ParmVarDecl * > parameters () const override
 Return call's formal parameters.
 
Kind getKind () const override
 Returns the kind of call this is.
 
StringRef getKindAsString () const override
 
- Public Member Functions inherited from clang::ento::CallEvent
CallEventoperator= (const CallEvent &)=delete
 
virtual ~CallEvent ()=default
 
virtual Kind getKind () const =0
 Returns the kind of call this is.
 
virtual StringRef getKindAsString () const =0
 
virtual const DeclgetDecl () const
 Returns the declaration of the function or method that will be called.
 
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 RuntimeDefinition getRuntimeDefinition () const =0
 Returns the definition of the function or method that will be called.
 
virtual const ExprgetOriginExpr () const
 Returns the expression whose value will be the result of this call.
 
virtual unsigned getNumArgs () const =0
 Returns the number of arguments (explicit and implicit).
 
bool isInSystemHeader () const
 Returns true if the callee is known to be from a system header.
 
virtual SourceRange getSourceRange () const
 Returns a source range for the entire call, suitable for outputting in diagnostics.
 
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*.
 
virtual bool argumentsMayEscape () const
 Returns true if any of the arguments are known to escape to long- term storage, even if this method will not modify them.
 
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.
 
virtual void getInitialStackFrameContents (const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const =0
 Populates the given SmallVector with the bindings in the callee's stack frame at the start of this call.
 
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
 
virtual ArrayRef< ParmVarDecl * > parameters () const =0
 Return call's formal parameters.
 
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::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 Member Functions

 BlockCall (const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
 
 BlockCall (const BlockCall &Other)=default
 
void cloneTo (void *Dest) const override
 Copies this CallEvent, with vtable intact, into a new block of memory.
 
void getExtraInvalidatedValues (ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
 Used to specify non-argument regions that will be invalidated as a result of this call.
 
- 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)
 
virtual void cloneTo (void *Dest) const =0
 Copies this CallEvent, with vtable intact, into a new block of memory.
 
SVal getSVal (const Stmt *S) const
 Get the value of arbitrary expressions at this point in the path.
 
virtual void getExtraInvalidatedValues (ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const
 Used to specify non-argument regions that will be invalidated as a result of this call.
 

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 = llvm::mapped_iterator< ArrayRef< ParmVarDecl * >::iterator, GetTypeFn >
 
- Protected Types inherited from clang::ento::CallEvent
using ValueList = SmallVectorImpl< SVal >
 
- Protected Attributes inherited from clang::ento::CallEvent
const void * Data
 
SourceLocation Location
 

Detailed Description

Represents a call to a block.

Example: ^{ statement-body }()

Definition at line 574 of file CallEvent.h.

Constructor & Destructor Documentation

◆ BlockCall() [1/2]

clang::ento::BlockCall::BlockCall ( const CallExpr CE,
ProgramStateRef  St,
const LocationContext LCtx,
CFGBlock::ConstCFGElementRef  ElemRef 
)
inlineprotected

Definition at line 578 of file CallEvent.h.

◆ BlockCall() [2/2]

clang::ento::BlockCall::BlockCall ( const BlockCall Other)
protecteddefault

Member Function Documentation

◆ argumentsMayEscape()

bool clang::ento::BlockCall::argumentsMayEscape ( ) const
inlineoverridevirtual

Returns true if any of the arguments are known to escape to long- term storage, even if this method will not modify them.

Reimplemented from clang::ento::CallEvent.

Definition at line 662 of file CallEvent.h.

◆ classof()

static bool clang::ento::BlockCall::classof ( const CallEvent CA)
inlinestatic

Definition at line 672 of file CallEvent.h.

References clang::ento::CE_Block, and clang::ento::CallEvent::getKind().

◆ cloneTo()

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

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

Implements clang::ento::CallEvent.

Definition at line 583 of file CallEvent.h.

◆ getArgExpr()

const Expr * clang::ento::BlockCall::getArgExpr ( unsigned  Index) const
inlineoverridevirtual

Returns the expression associated with a given argument.

May be null if this expression does not appear in the source.

Reimplemented from clang::ento::CallEvent.

Definition at line 596 of file CallEvent.h.

References clang::CallExpr::getArg(), and getOriginExpr().

◆ getBlockRegion()

const BlockDataRegion * BlockCall::getBlockRegion ( ) const

Returns the region associated with this instance of the block.

This may be NULL if the block's origin is unknown.

Definition at line 876 of file CallEvent.cpp.

References clang::ento::SVal::getAsRegion(), clang::CallExpr::getCallee(), getOriginExpr(), and clang::ento::CallEvent::getSVal().

Referenced by getDecl(), getExtraInvalidatedValues(), and getRegionStoringCapturedLambda().

◆ getDecl()

const BlockDecl * clang::ento::BlockCall::getDecl ( ) const
inlineoverridevirtual

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

May be null.

Reimplemented from clang::ento::CallEvent.

Definition at line 605 of file CallEvent.h.

References getBlockRegion(), and clang::ento::BlockDataRegion::getDecl().

Referenced by getRuntimeDefinition(), isConversionFromLambda(), and parameters().

◆ getExtraInvalidatedValues()

void BlockCall::getExtraInvalidatedValues ( ValueList Values,
RegionAndSymbolInvalidationTraits ETraits 
) const
overrideprotectedvirtual

Used to specify non-argument regions that will be invalidated as a result of this call.

Reimplemented from clang::ento::CallEvent.

Definition at line 890 of file CallEvent.cpp.

References getBlockRegion().

◆ getInitialStackFrameContents()

void BlockCall::getInitialStackFrameContents ( const StackFrameContext CalleeCtx,
BindingsTy Bindings 
) const
overridevirtual

Populates the given SmallVector with the bindings in the callee's stack frame at the start of this call.

Implements clang::ento::CallEvent.

Definition at line 897 of file CallEvent.cpp.

References addParameterValuesToBindings(), clang::ento::SValBuilder::getCXXThis(), clang::LocationContext::getDecl(), getRegionStoringCapturedLambda(), clang::ento::CallEvent::getState(), and isConversionFromLambda().

◆ getKind()

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

Returns the kind of call this is.

Implements clang::ento::CallEvent.

Definition at line 669 of file CallEvent.h.

References clang::ento::CE_Block.

◆ getKindAsString()

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

Implements clang::ento::CallEvent.

Definition at line 670 of file CallEvent.h.

◆ getNumArgs()

unsigned clang::ento::BlockCall::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 594 of file CallEvent.h.

References clang::CallExpr::getNumArgs(), and getOriginExpr().

◆ getOriginExpr()

const CallExpr * clang::ento::BlockCall::getOriginExpr ( ) const
inlineoverridevirtual

Returns the expression whose value will be the result of this call.

May be null.

Reimplemented from clang::ento::CallEvent.

Definition at line 590 of file CallEvent.h.

References clang::ento::CallEvent::getOriginExpr().

Referenced by getArgExpr(), getBlockRegion(), and getNumArgs().

◆ getRegionStoringCapturedLambda()

const VarRegion * clang::ento::BlockCall::getRegionStoringCapturedLambda ( ) const
inline

For a block converted from a C++ lambda, returns the block VarRegion for the variable holding the captured C++ lambda record.

Definition at line 622 of file CallEvent.h.

References getBlockRegion(), isConversionFromLambda(), and clang::ento::BlockDataRegion::referenced_vars().

Referenced by getInitialStackFrameContents(), and getRuntimeDefinition().

◆ getRuntimeDefinition()

RuntimeDefinition clang::ento::BlockCall::getRuntimeDefinition ( ) const
inlineoverridevirtual

◆ isConversionFromLambda()

bool clang::ento::BlockCall::isConversionFromLambda ( ) const
inline

◆ parameters()

ArrayRef< ParmVarDecl * > BlockCall::parameters ( ) const
overridevirtual

Return call's formal parameters.

Remember that the number of formal parameters may not match the number of arguments for all calls. However, the first parameter will always correspond with the argument value returned by getArgSVal(0).

Implements clang::ento::CallEvent.

Definition at line 883 of file CallEvent.cpp.

References D, and getDecl().

Friends And Related Function Documentation

◆ CallEventManager

friend class CallEventManager
friend

Definition at line 575 of file CallEvent.h.


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