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

Represents any expression that calls an Objective-C method. More...

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

Inheritance diagram for clang::ento::ObjCMethodCall:
Inheritance graph
[legend]
Collaboration diagram for clang::ento::ObjCMethodCall:
Collaboration graph
[legend]

Public Member Functions

const ObjCMessageExprgetOriginExpr () const override
 Returns the expression whose value will be the result of this call. More...
 
const ObjCMethodDeclgetDecl () const override
 Returns the declaration of the function or method that will be called. More...
 
unsigned getNumArgs () const override
 Returns the number of arguments (explicit and implicit). More...
 
const ExprgetArgExpr (unsigned Index) const override
 Returns the expression associated with a given argument. More...
 
bool isInstanceMessage () const
 
ObjCMethodFamily getMethodFamily () const
 
Selector getSelector () const
 
SourceRange getSourceRange () const override
 Returns a source range for the entire call, suitable for outputting in diagnostics. More...
 
SVal getReceiverSVal () const
 Returns the value of the receiver at the time of this call. More...
 
const ObjCInterfaceDeclgetReceiverInterface () const
 Get the interface for the receiver. More...
 
bool isReceiverSelfOrSuper () const
 Checks if the receiver refers to 'self' or 'super'. More...
 
ObjCMessageKind getMessageKind () const
 Returns how the message was written in the source (property access, subscript, or explicit message send). More...
 
bool isSetter () const
 Returns true if this property access or subscript is a setter (has the form of an assignment). More...
 
const ObjCPropertyDeclgetAccessedProperty () const
 
RuntimeDefinition getRuntimeDefinition () const override
 Returns the definition of the function or method that will be called. More...
 
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. More...
 
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. More...
 
ArrayRef< ParmVarDecl * > parameters () const override
 Return call's formal parameters. More...
 
Kind getKind () const override
 Returns the kind of call this is. More...
 
StringRef getKindAsString () const override
 
- Public Member Functions inherited from clang::ento::CallEvent
CallEventoperator= (const CallEvent &)=delete
 
virtual ~CallEvent ()=default
 
const ProgramStateRefgetState () const
 The state in which the call is being evaluated. More...
 
const LocationContextgetLocationContext () const
 The context in which the call is being evaluated. More...
 
bool isInSystemHeader () const
 Returns true if the callee is known to be from a system header. More...
 
bool isCalled (const CallDescription &CD) const
 Returns true if the CallEvent is a call to a function that matches the CallDescription. More...
 
template<typename FirstCallDesc , typename... CallDescs>
bool isCalled (const FirstCallDesc &First, const CallDescs &... Rest) const
 Returns true whether the CallEvent is any of the CallDescriptions supplied as a parameter. More...
 
virtual SVal getArgSVal (unsigned Index) const
 Returns the value of a given argument at the time of the call. More...
 
virtual SourceRange getArgSourceRange (unsigned Index) const
 Returns the source range for errors associated with this argument. More...
 
QualType getResultType () const
 Returns the result type, adjusted for references. More...
 
SVal getReturnValue () const
 Returns the return value of the call. More...
 
bool hasNonNullArgumentsWithType (bool(*Condition)(QualType)) const
 Returns true if the type of any of the non-null arguments satisfies the condition. More...
 
bool hasNonZeroCallbackArg () const
 Returns true if any of the arguments appear to represent callbacks. More...
 
bool hasVoidPointerToNonConstArg () const
 Returns true if any of the arguments is void*. More...
 
bool isGlobalCFunction (StringRef SpecificName=StringRef()) const
 Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc. More...
 
const IdentifierInfogetCalleeIdentifier () const
 Returns the name of the callee, if its name is a simple identifier. More...
 
ProgramPoint getProgramPoint (bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
 Returns an appropriate ProgramPoint for this call. More...
 
ProgramStateRef invalidateRegions (unsigned BlockCount, ProgramStateRef Orig=nullptr) const
 Returns a new state with all argument regions invalidated. More...
 
template<typename T >
CallEventRef< T > cloneWithState (ProgramStateRef NewState) const
 Returns a copy of this CallEvent, but using the given state. More...
 
CallEventRef cloneWithState (ProgramStateRef NewState) const
 Returns a copy of this CallEvent, but using the given state. More...
 
AnalysisDeclContextgetCalleeAnalysisDeclContext () const
 Returns AnalysisDeclContext for the callee stack frame. More...
 
const StackFrameContextgetCalleeStackFrame (unsigned BlockCount) const
 Returns the callee stack frame. More...
 
const ParamVarRegiongetParameterLocation (unsigned Index, unsigned BlockCount) const
 Returns memory location for a parameter variable within the callee stack frame. More...
 
bool isArgumentConstructedDirectly (unsigned Index) const
 Returns true if on the current path, the argument was constructed by calling a C++ constructor over it. More...
 
virtual Optional< unsignedgetAdjustedParameterIndex (unsigned ASTArgumentIndex) const
 Some calls have parameter numbering mismatched from argument numbering. More...
 
virtual unsigned getASTArgumentIndex (unsigned CallArgumentIndex) const
 Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices. More...
 
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. More...
 
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. More...
 
param_type_iterator param_type_begin () const
 Returns an iterator over the types of the call's formal parameters. More...
 
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. More...
 
static QualType getDeclaredResultType (const Decl *D)
 Returns the result type of a function or method declaration. More...
 
static bool isVariadic (const Decl *D)
 Returns true if the given decl is known to be variadic. More...
 

Protected Member Functions

 ObjCMethodCall (const ObjCMessageExpr *Msg, ProgramStateRef St, const LocationContext *LCtx)
 
 ObjCMethodCall (const ObjCMethodCall &Other)=default
 
void cloneTo (void *Dest) const override
 Copies this CallEvent, with vtable intact, into a new block of memory. More...
 
void getExtraInvalidatedValues (ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
 Used to specify non-argument regions that will be invalidated as a result of this call. More...
 
virtual bool canBeOverridenInSubclass (ObjCInterfaceDecl *IDecl, Selector Sel) const
 Check if the selector may have multiple definitions (may have overrides). More...
 
- Protected Member Functions inherited from clang::ento::CallEvent
 CallEvent (const Expr *E, ProgramStateRef state, const LocationContext *lctx)
 
 CallEvent (const Decl *D, ProgramStateRef state, const LocationContext *lctx)
 
 CallEvent (const CallEvent &Original)
 
SVal getSVal (const Stmt *S) const
 Get the value of arbitrary expressions at this point in the path. More...
 

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 any expression that calls an Objective-C method.

This includes all of the kinds listed in ObjCMessageKind.

Definition at line 1120 of file CallEvent.h.

Constructor & Destructor Documentation

◆ ObjCMethodCall() [1/2]

clang::ento::ObjCMethodCall::ObjCMethodCall ( const ObjCMessageExpr Msg,
ProgramStateRef  St,
const LocationContext LCtx 
)
inlineprotected

Definition at line 1126 of file CallEvent.h.

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

Referenced by cloneTo().

◆ ObjCMethodCall() [2/2]

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

Member Function Documentation

◆ argumentsMayEscape()

bool ObjCMethodCall::argumentsMayEscape ( ) const
overridevirtual

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 1383 of file CallEvent.cpp.

References clang::ento::CallEvent::argumentsMayEscape(), clang::Selector::getIdentifierInfoForSlot(), clang::Selector::getNumArgs(), getSelector(), isInstanceMessage(), clang::ento::CallEvent::isInSystemHeader(), and clang::IdentifierInfo::isStr().

◆ canBeOverridenInSubclass()

bool ObjCMethodCall::canBeOverridenInSubclass ( ObjCInterfaceDecl IDecl,
Selector  Sel 
) const
protectedvirtual

◆ classof()

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

Definition at line 1223 of file CallEvent.h.

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

◆ cloneTo()

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

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

Implements clang::ento::CallEvent.

Definition at line 1134 of file CallEvent.h.

References ObjCMethodCall().

◆ getAccessedProperty()

const ObjCPropertyDecl * ObjCMethodCall::getAccessedProperty ( ) const

◆ getArgExpr()

const Expr* clang::ento::ObjCMethodCall::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 1156 of file CallEvent.h.

◆ getDecl()

const ObjCMethodDecl* clang::ento::ObjCMethodCall::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 1148 of file CallEvent.h.

References clang::ObjCMessageExpr::getMethodDecl(), and getOriginExpr().

Referenced by getAccessedProperty(), and parameters().

◆ getExtraInvalidatedValues()

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

◆ getInitialStackFrameContents()

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

◆ getKind()

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

Returns the kind of call this is.

Implements clang::ento::CallEvent.

Definition at line 1220 of file CallEvent.h.

References clang::ento::CE_ObjCMessage.

◆ getKindAsString()

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

Implements clang::ento::CallEvent.

Definition at line 1221 of file CallEvent.h.

◆ getMessageKind()

ObjCMessageKind ObjCMethodCall::getMessageKind ( ) const

Returns how the message was written in the source (property access, subscript, or explicit message send).

Definition at line 1074 of file CallEvent.cpp.

References clang::ento::CallEvent::Data, clang::ento::CallEvent::getLocationContext(), and clang::LocationContext::getParentMap().

Referenced by canBeOverridenInSubclass(), getAccessedProperty(), getSourceRange(), and isSetter().

◆ getMethodFamily()

ObjCMethodFamily clang::ento::ObjCMethodCall::getMethodFamily ( ) const
inline

Definition at line 1164 of file CallEvent.h.

References clang::ObjCMessageExpr::getMethodFamily(), and getOriginExpr().

◆ getNumArgs()

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

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

Referenced by isSetter().

◆ getOriginExpr()

const ObjCMessageExpr* clang::ento::ObjCMethodCall::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 1144 of file CallEvent.h.

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

Referenced by getDecl(), getMethodFamily(), getNumArgs(), getReceiverInterface(), getReceiverSVal(), getRuntimeDefinition(), getSelector(), getSourceRange(), isInstanceMessage(), and isReceiverSelfOrSuper().

◆ getReceiverInterface()

const ObjCInterfaceDecl* clang::ento::ObjCMethodCall::getReceiverInterface ( ) const
inline

Get the interface for the receiver.

This works whether this is an instance message or a class message. However, it currently just uses the static type of the receiver.

Definition at line 1181 of file CallEvent.h.

References getOriginExpr(), and clang::ObjCMessageExpr::getReceiverInterface().

◆ getReceiverSVal()

SVal ObjCMethodCall::getReceiverSVal ( ) const

◆ getRuntimeDefinition()

RuntimeDefinition ObjCMethodCall::getRuntimeDefinition ( ) const
overridevirtual

◆ getSelector()

Selector clang::ento::ObjCMethodCall::getSelector ( ) const
inline

Definition at line 1168 of file CallEvent.h.

References getOriginExpr(), and clang::ObjCMessageExpr::getSelector().

Referenced by argumentsMayEscape().

◆ getSourceRange()

SourceRange ObjCMethodCall::getSourceRange ( ) const
overridevirtual

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

Reimplemented from clang::ento::CallEvent.

Definition at line 1043 of file CallEvent.cpp.

References getMessageKind(), getOriginExpr(), clang::Stmt::getSourceRange(), clang::ento::OCM_Message, clang::ento::OCM_PropertyAccess, and clang::ento::OCM_Subscript.

◆ isInstanceMessage()

bool clang::ento::ObjCMethodCall::isInstanceMessage ( ) const
inline

◆ isReceiverSelfOrSuper()

bool ObjCMethodCall::isReceiverSelfOrSuper ( ) const

◆ isSetter()

bool clang::ento::ObjCMethodCall::isSetter ( ) const
inline

Returns true if this property access or subscript is a setter (has the form of an assignment).

Definition at line 1194 of file CallEvent.h.

References getMessageKind(), getNumArgs(), clang::ento::OCM_Message, clang::ento::OCM_PropertyAccess, and clang::ento::OCM_Subscript.

◆ parameters()

ArrayRef< ParmVarDecl * > ObjCMethodCall::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 981 of file CallEvent.cpp.

References getDecl(), and clang::ObjCMethodDecl::parameters().

Friends And Related Function Documentation

◆ CallEventManager

friend class CallEventManager
friend

Definition at line 1121 of file CallEvent.h.


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