class CallEvent

Declaration

class CallEvent { /* full declaration omitted */ };

Description

Represents an abstract call to a function or method along a particular path. CallEvents are created through the factory methods of CallEventManager. CallEvents should always be cheap to create and destroy. In order for CallEventManager to be able to re-use CallEvent-sized memory blocks, subclasses of CallEvent may not add any data members to the base class. Use the "Data" and "Location" fields instead.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:148

Member Variables

private clang::ento::ProgramStateRef State
private const clang::LocationContext* LCtx
private llvm::PointerUnion<const Expr*, const Decl*> Origin
private Optional<bool> Foreign
protected const void* Data
protected clang::SourceLocation Location
private unsigned int RefCount = 0

Method Overview

Methods

CallEvent(const clang::Expr* E,
          clang::ento::ProgramStateRef state,
          const clang::LocationContext* lctx)

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:178

Parameters

const clang::Expr* E
clang::ento::ProgramStateRef state
const clang::LocationContext* lctx

CallEvent(const clang::Decl* D,
          clang::ento::ProgramStateRef state,
          const clang::LocationContext* lctx)

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:181

Parameters

const clang::Decl* D
clang::ento::ProgramStateRef state
const clang::LocationContext* lctx

CallEvent(const clang::ento::CallEvent& Original)

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:185

Parameters

const clang::ento::CallEvent& Original

void Release() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:173

void Retain() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:172

virtual bool argumentsMayEscape() const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:314

virtual void cloneTo(void* Dest) const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:190

Parameters

void* Dest

template <typename T>
CallEventRef<T> cloneWithState(
    clang::ento::ProgramStateRef NewState) const

Description

Returns a copy of this CallEvent, but using the given state.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:371

Templates

T

Parameters

clang::ento::ProgramStateRef NewState

CallEventRef<> cloneWithState(
    clang::ento::ProgramStateRef NewState) const

Description

Returns a copy of this CallEvent, but using the given state.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:374

Parameters

clang::ento::ProgramStateRef NewState

void dump() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:478

void dump(llvm::raw_ostream& Out) const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:477

Parameters

llvm::raw_ostream& Out

virtual unsigned int getASTArgumentIndex(
    unsigned int CallArgumentIndex) const

Description

Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices. This function converts an argument index as understood by CallEvent to the argument index as understood by the AST.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:433

Parameters

unsigned int CallArgumentIndex

virtual Optional<unsigned int>
getAdjustedParameterIndex(
    unsigned int ASTArgumentIndex) const

Description

Some calls have parameter numbering mismatched from argument numbering. This function converts an argument index to the corresponding parameter index. Returns None is the argument doesn't correspond to any parameter variable.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:426

Parameters

unsigned int ASTArgumentIndex

virtual const clang::Expr* getArgExpr(
    unsigned int Index) const

Description

Returns the expression associated with a given argument. May be null if this expression does not appear in the source.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:283

Parameters

unsigned int Index

virtual clang::ento::SVal getArgSVal(
    unsigned int Index) const

Description

Returns the value of a given argument at the time of the call.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:279

Parameters

unsigned int Index

virtual clang::SourceRange getArgSourceRange(
    unsigned int Index) const

Description

Returns the source range for errors associated with this argument. May be invalid if the argument is not written in the source.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:288

Parameters

unsigned int Index

clang::AnalysisDeclContext*
getCalleeAnalysisDeclContext() const

Description

Returns AnalysisDeclContext for the callee stack frame. Currently may fail; returns null on failure.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:394

const clang::IdentifierInfo* getCalleeIdentifier()
    const

Description

Returns the name of the callee, if its name is a simple identifier. Note that this will fail for Objective-C methods, blocks, and C++ overloaded operators. The former is named by a Selector rather than a simple identifier, and the latter two do not have names.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:343

const clang::StackFrameContext*
getCalleeStackFrame(unsigned int BlockCount) const

Description

Returns the callee stack frame. That stack frame will only be entered during analysis if the call is inlined, but it may still be useful in intermediate calculations even if the call isn't inlined. May fail; returns null on failure.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:400

Parameters

unsigned int BlockCount

const clang::ConstructionContext*
getConstructionContext() const

Description

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. Otherwise return nullptr.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:440

virtual const clang::Decl* getDecl() const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:214

static clang::QualType getDeclaredResultType(
    const clang::Decl* D)

Description

Returns the result type of a function or method declaration. This will return a null QualType if the result type cannot be determined.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:385

Parameters

const clang::Decl* D

virtual void getExtraInvalidatedValues(
    clang::ento::CallEvent::ValueList& Values,
    clang::ento::
        RegionAndSymbolInvalidationTraits*
            ETraits) const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:201

Parameters

clang::ento::CallEvent::ValueList& Values
clang::ento::RegionAndSymbolInvalidationTraits* ETraits

virtual void getInitialStackFrameContents(
    const clang::StackFrameContext* CalleeCtx,
    clang::ento::CallEvent::BindingsTy& Bindings)
    const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:366

Parameters

const clang::StackFrameContext* CalleeCtx
clang::ento::CallEvent::BindingsTy& Bindings

virtual clang::ento::CallEvent::Kind getKind()
    const

Description

Returns the kind of call this is.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:209

virtual llvm::StringRef getKindAsString() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:210

const clang::LocationContext* getLocationContext()
    const

Description

The context in which the call is being evaluated.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:230

virtual unsigned int getNumArgs() const

Description

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.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:249

virtual const clang::Expr* getOriginExpr() const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:240

const clang::ento::ParamVarRegion*
getParameterLocation(
    unsigned int Index,
    unsigned int BlockCount) const

Description

Returns memory location for a parameter variable within the callee stack frame. The behavior is undefined if the block count is different from the one that is there when call happens. May fail; returns null on failure.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:405

Parameters

unsigned int Index
unsigned int BlockCount

clang::ProgramPoint getProgramPoint(
    bool IsPreVisit = false,
    const clang::ProgramPointTag* Tag =
        nullptr) const

Description

Returns an appropriate ProgramPoint for this call.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:351

Parameters

bool IsPreVisit = false
const clang::ProgramPointTag* Tag = nullptr

clang::QualType getResultType() const

Description

Returns the result type, adjusted for references.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:291

clang::ento::SVal getReturnValue() const

Description

Returns the return value of the call. This should only be called if the CallEvent was created using a state in which the return value has already been bound to the origin expression.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:297

Optional<clang::ento::SVal>
getReturnValueUnderConstruction() const

Description

If the call returns a C++ record type then the region of its return value can be retrieved from its construction context.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:444

virtual clang::ento::RuntimeDefinition
getRuntimeDefinition() const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:236

clang::ento::SVal getSVal(
    const clang::Stmt* S) const

Description

Get the value of arbitrary expressions at this point in the path.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:193

Parameters

const clang::Stmt* S

virtual clang::SourceRange getSourceRange() const

Description

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

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:274

const clang::ento::ProgramStateRef& getState()
    const

Description

The state in which the call is being evaluated.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:225

bool hasNonNullArgumentsWithType(
    bool (*)(clang::QualType) Condition) const

Description

Returns true if the type of any of the non-null arguments satisfies the condition.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:301

Parameters

bool (*)(clang::QualType) Condition

bool hasNonZeroCallbackArg() const

Description

Returns true if any of the arguments appear to represent callbacks.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:304

bool hasVoidPointerToNonConstArg() const

Description

Returns true if any of the arguments is void*.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:307

clang::ento::ProgramStateRef invalidateRegions(
    unsigned int BlockCount,
    clang::ento::ProgramStateRef Orig =
        nullptr) const

Description

Returns a new state with all argument regions invalidated. This accepts an alternate state in case some processing has already occurred.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:358

Parameters

unsigned int BlockCount
clang::ento::ProgramStateRef Orig = nullptr

bool isArgumentConstructedDirectly(
    unsigned int Index) const

Description

Returns true if on the current path, the argument was constructed by calling a C++ constructor over it. This is an internal detail of the analysis which doesn't necessarily represent the program semantics: if we are supposed to construct an argument directly, we may still not do that because we don't know how (i.e., construction context is unavailable in the CFG or not supported by the analyzer).

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:414

Parameters

unsigned int Index

static bool isCallStmt(const clang::Stmt* S)

Description

Returns true if this is a statement is a function or method call of some kind.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:380

Parameters

const clang::Stmt* S

bool isForeign() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:218

bool isGlobalCFunction(
    llvm::StringRef SpecificName =
        llvm::StringRef()) const

Description

Returns true if the callee is an externally-visible function in the top-level namespace, such as \c malloc. You can use this call to determine that a particular function really is a library function and not, say, a C++ member function with the same name. If a name is provided, the function must additionally match the given name. Note that this deliberately excludes C++ library functions in the \c std namespace, but will include C library functions accessed through the\c std namespace. This also does not check if the function is declared as 'extern "C"', or if it uses C++ name mangling.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:334

Parameters

llvm::StringRef SpecificName = llvm::StringRef()

bool isInSystemHeader() const

Description

Returns true if the callee is known to be from a system header.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:252

static bool isVariadic(const clang::Decl* D)

Description

Returns true if the given decl is known to be variadic. \p D must not be null.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:390

Parameters

const clang::Decl* D

clang::ento::CallEvent::param_type_iterator
param_type_begin() const

Description

Returns an iterator over the types of the call's formal parameters. This uses the callee decl found by default name lookup rather than the definition because it represents a public interface, and probably has more annotations.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:468

clang::ento::CallEvent::param_type_iterator
param_type_end() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:472

virtual ArrayRef<clang::ParmVarDecl*> parameters()
    const

Description

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 \c getArgSVal(0).

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:458

void setForeign(bool B) const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:222

Parameters

bool B

virtual ~CallEvent()

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:206