15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLEVENT_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLEVENT_H
35#include "llvm/ADT/ArrayRef.h"
36#include "llvm/ADT/IntrusiveRefCntPtr.h"
37#include "llvm/ADT/PointerIntPair.h"
38#include "llvm/ADT/PointerUnion.h"
39#include "llvm/ADT/STLExtras.h"
40#include "llvm/ADT/SmallVector.h"
41#include "llvm/ADT/StringRef.h"
42#include "llvm/ADT/iterator_range.h"
43#include "llvm/Support/Allocator.h"
44#include "llvm/Support/Casting.h"
45#include "llvm/Support/ErrorHandling.h"
56class StackFrameContext;
82template <
typename T = CallEvent>
93 return this->get()->template cloneWithState<T>(State);
113 const Decl *D =
nullptr;
123 const bool Foreign =
false;
160 llvm::PointerUnion<const Expr *, const Decl *> Origin;
162 mutable std::optional<bool> Foreign;
176 mutable unsigned RefCount = 0;
178 void Retain()
const { ++RefCount; }
179 void Release()
const;
186 : State(
std::move(state)), LCtx(lctx), Origin(
E), ElemRef(ElemRef) {}
190 : State(
std::move(state)), LCtx(lctx), Origin(
D), ElemRef(ElemRef) {}
194 : State(Original.State), LCtx(Original.LCtx), Origin(Original.Origin),
195 ElemRef(Original.ElemRef),
Data(Original.
Data),
225 return Origin.dyn_cast<
const Decl *>();
229 assert(Foreign &&
"Foreign must be set before querying");
251 return Origin.dyn_cast<
const Expr *>();
270 getState()->getStateManager().getContext().getSourceManager();
271 return SM.isInSystemHeader(
D->getLocation());
276 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
277 return FD->isOverloadedOperator() && FD->isImplicit() && FD->isGlobal();
352 const auto *ND = dyn_cast_or_null<NamedDecl>(
getDecl());
355 return ND->getIdentifier();
378 template <
typename T>
383 return cloneWithState<CallEvent>(NewState);
414 unsigned BlockCount)
const;
433 virtual std::optional<unsigned>
435 return ASTArgumentIndex;
442 return CallArgumentIndex;
477 llvm::mapped_iterator<ArrayRef<ParmVarDecl *>::iterator, GetTypeFn>;
485 return llvm::map_iterator(
parameters().begin(), GetTypeFn());
489 return llvm::map_iterator(
parameters().end(), GetTypeFn());
493 void dump(raw_ostream &Out)
const;
625 assert(BR &&
"Block converted from lambda must have a block region");
628 assert(!ReferencedVars.empty());
629 return ReferencedVars.begin().getCapturedRegion();
759 std::optional<unsigned>
762 if (ASTArgumentIndex == 0)
764 return ASTArgumentIndex - 1;
769 return CallArgumentIndex + 1;
806 return CE->getNumArgs();
866 std::optional<unsigned>
870 return (ASTArgumentIndex > 0)
871 ? std::optional<unsigned>(ASTArgumentIndex - 1)
878 return CallArgumentIndex + 1;
894 using DtorDataTy = llvm::PointerIntPair<const MemRegion *, 1, bool>;
935 return DtorDataTy::getFromOpaqueValue(
Data).getInt();
954 assert(
E && (isa<CXXConstructExpr>(
E) || isa<CXXInheritedCtorInitExpr>(
E)));
1101 return "CXXInheritedConstructorCall";
1158 assert(
isArray() &&
"The allocator call doesn't allocate and array!");
1318 llvm_unreachable(
"This is not a pseudo-object access!");
1324 llvm_unreachable(
"Unknown message kind");
1359 llvm::BumpPtrAllocator &Alloc;
1364 void reclaim(
const void *Memory) {
1365 Cache.push_back(
const_cast<void *
>(Memory));
1371 return Alloc.Allocate<CallEventTemplateTy>();
1373 return Cache.pop_back_val();
1376 template <
typename T,
typename Arg>
1379 static_assert(
sizeof(
T) ==
sizeof(CallEventTemplateTy),
1380 "CallEvent subclasses are not all the same size");
1381 return new (allocate())
T(A, St, LCtx, ElemRef);
1384 template <
typename T,
typename Arg1,
typename Arg2>
1385 T *create(Arg1 A1, Arg2 A2,
ProgramStateRef St,
const LocationContext *LCtx,
1387 static_assert(
sizeof(
T) ==
sizeof(CallEventTemplateTy),
1388 "CallEvent subclasses are not all the same size");
1389 return new (allocate())
T(A1, A2, St, LCtx, ElemRef);
1392 template <
typename T,
typename Arg1,
typename Arg2,
typename Arg3>
1395 static_assert(
sizeof(
T) ==
sizeof(CallEventTemplateTy),
1396 "CallEvent subclasses are not all the same size");
1397 return new (allocate())
T(A1, A2, A3, St, LCtx, ElemRef);
1400 template <
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
1404 static_assert(
sizeof(
T) ==
sizeof(CallEventTemplateTy),
1405 "CallEvent subclasses are not all the same size");
1406 return new (allocate())
T(A1, A2, A3, A4, St, LCtx, ElemRef);
1430 return create<ObjCMethodCall>(
E, State, LCtx, ElemRef);
1437 return create<CXXConstructorCall>(
E,
Target, State, LCtx, ElemRef);
1445 return create<CXXInheritedConstructorCall>(
E,
Target, State, LCtx, ElemRef);
1453 return create<CXXDestructorCall>(DD, Trigger,
Target, IsBase, State, LCtx,
1461 return create<CXXAllocatorCall>(
E, State, LCtx, ElemRef);
1468 return create<CXXDeallocatorCall>(
E, State, LCtx, ElemRef);
1472template <
typename T>
1474 assert(isa<T>(*
this) &&
"Cloning to unrelated type");
1475 static_assert(
sizeof(
T) ==
sizeof(
CallEvent),
1476 "Subclasses may not add fields");
1478 if (NewState == State)
1479 return cast<T>(
this);
1482 T *
Copy =
static_cast<T *
>(Mgr.allocate());
1484 assert(
Copy->getKind() == this->getKind() &&
"Bad copy");
1486 Copy->State = NewState;
1490inline void CallEvent::Release()
const {
1491 assert(RefCount > 0 &&
"Reference count is already zero.");
1510template <
class T>
struct simplify_type<
clang::ento::CallEventRef<T>> {
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool isConversionFromLambda() const
ElementRefImpl< true > ConstCFGElementRef
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
Represents a C++ destructor within a class.
Represents a call to an inherited base class constructor from an inheriting constructor.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
Expr * getPlacementArg(unsigned I)
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
unsigned getNumPlacementArgs() const
FunctionDecl * getOperatorNew() const
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Represents a C++ struct/union/class.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
ConstructionContext's subclasses describe different ways of constructing an object in C++.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a function declaration or definition.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
One of these records is kept for each identifier that is lexed.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Represents an ObjC class declaration.
An expression that sends a message to the given Objective-C object or class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
ObjCMethodFamily getMethodFamily() const
Selector getSelector() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
const ObjCMethodDecl * getMethodDecl() const
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents one property declaration in an Objective-C interface.
Represents a parameter to a function.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a variable declaration or definition.
Represents any constructor invocation.
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 ca...
AnyCXXConstructorCall(const Expr *E, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
static bool classof(const CallEvent *Call)
Represents a call to any sort of function that might have a FunctionDecl.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
AnyFunctionCall(const Expr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
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 ca...
static bool classof(const CallEvent *CA)
AnyFunctionCall(const Decl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
AnyFunctionCall(const AnyFunctionCall &Other)=default
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
Represents a call to a block.
const BlockDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
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.
const BlockDataRegion * getBlockRegion() const
Returns the region associated with this instance of the block.
bool isConversionFromLambda() const
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
Kind getKind() const override
Returns the kind of call this is.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
const VarRegion * getRegionStoringCapturedLambda() const
For a block converted from a C++ lambda, returns the block VarRegion for the variable holding the cap...
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
BlockCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
BlockCall(const BlockCall &Other)=default
static bool classof(const CallEvent *CA)
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 ca...
StringRef getKindAsString() const override
const CallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
BlockDataRegion - A region that represents a block instance.
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
llvm::iterator_range< referenced_vars_iterator > referenced_vars() const
Represents the memory allocation call in a C++ new-expression.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
unsigned getNumImplicitArgs() const
Number of non-placement arguments to the call.
const CXXNewExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
Kind getKind() const override
Returns the kind of call this is.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
std::optional< const clang::Expr * > getArraySizeExpr() const
static bool classof(const CallEvent *CE)
const Expr * getPlacementArgExpr(unsigned Index) const
Number of placement arguments to the operator new() call.
CXXAllocatorCall(const CXXAllocatorCall &Other)=default
SVal getArraySizeVal() const
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
StringRef getKindAsString() const override
SVal getObjectUnderConstruction() const
CXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
Represents a call to a C++ constructor.
CXXConstructorCall(const CXXConstructorCall &Other)=default
const CXXConstructorDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const CXXConstructExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
Kind getKind() const override
Returns the kind of call this is.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXConstructorCall(const CXXConstructExpr *CE, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Creates a constructor call.
StringRef getKindAsString() const override
static bool classof(const CallEvent *CA)
Represents the memory deallocation call in a C++ delete-expression.
Kind getKind() const override
Returns the kind of call this is.
const CXXDeleteExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXDeallocatorCall(const CXXDeallocatorCall &Other)=default
static bool classof(const CallEvent *CE)
StringRef getKindAsString() const override
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
CXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Represents an implicit call to a C++ destructor.
static bool classof(const CallEvent *CA)
SVal getCXXThisVal() const override
Returns the value of the implicit 'this' object.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
bool isBaseDestructor() const
Returns true if this is a call to a base class destructor.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
llvm::PointerIntPair< const MemRegion *, 1, bool > DtorDataTy
CXXDestructorCall(const CXXDestructorCall &Other)=default
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
CXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBaseDestructor, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Creates an implicit destructor.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
Represents a call to a C++ inherited constructor.
CXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *CE, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CXXInheritedConstructorCall(const CXXInheritedConstructorCall &Other)=default
static bool classof(const CallEvent *CA)
const CXXInheritedCtorInitExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const StackFrameContext * getInheritingStackFrame() const
Obtain the stack frame of the inheriting constructor.
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CXXConstructorDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const CXXConstructExpr * getInheritingConstructor() const
Obtain the CXXConstructExpr for the sub-class that inherited the current constructor (possibly indire...
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
SVal getArgSVal(unsigned Index) const override
Returns the value of a given argument at the time of the call.
Represents a non-static C++ member function call, no matter how it is written.
CXXInstanceCall(const CXXInstanceCall &Other)=default
CXXInstanceCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CXXInstanceCall(const FunctionDecl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
virtual SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
static bool classof(const CallEvent *CA)
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
virtual const Expr * getCXXThisExpr() const
Returns the expression representing the implicit 'this' object.
const FunctionDecl * getDecl() const override
Returns the declaration 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 ca...
Represents a non-static C++ member function call.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
CXXMemberCall(const CXXMemberCall &Other)=default
const CXXMemberCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
static bool classof(const CallEvent *CA)
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXMemberCall(const CXXMemberCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
StringRef getKindAsString() const override
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
Kind getKind() const override
Returns the kind of call this is.
Represents a C++ overloaded operator call where the operator is implemented as a non-static member fu...
std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const override
Some calls have parameter numbering mismatched from argument numbering.
OverloadedOperatorKind getOverloadedOperator() const
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
Kind getKind() const override
Returns the kind of call this is.
StringRef getKindAsString() const override
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
CXXMemberOperatorCall(const CXXOperatorCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
CXXMemberOperatorCall(const CXXMemberOperatorCall &Other)=default
unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const override
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
static bool classof(const CallEvent *CA)
Represents a static C++ operator call.
std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const override
Some calls have parameter numbering mismatched from argument numbering.
CXXStaticOperatorCall(const CXXStaticOperatorCall &Other)=default
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
OverloadedOperatorKind getOverloadedOperator() const
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
CXXStaticOperatorCall(const CXXOperatorCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
static bool classof(const CallEvent *CA)
unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const override
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
Manages the lifetime of CallEvent objects.
CallEventRef< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getCall(const Stmt *S, ProgramStateRef State, const LocationContext *LC, CFGBlock::ConstCFGElementRef ElemRef)
Gets a call event for a function call, Objective-C method call, a 'new', or a 'delete' call.
CallEventRef< CXXDeallocatorCall > getCXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< ObjCMethodCall > getObjCMethodCall(const ObjCMessageExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXInheritedConstructorCall > getCXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventManager(llvm::BumpPtrAllocator &alloc)
CallEventRef getCaller(const StackFrameContext *CalleeCtx, ProgramStateRef State)
Gets an outside caller given a callee context.
CallEventRef(const T *Call)
CallEventRef(const CallEventRef &Orig)
CallEventRef & operator=(const CallEventRef &)=delete
CallEventRef< T > cloneWithState(ProgramStateRef State) const
Represents an abstract call to a function or method along a particular path.
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
virtual void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const
Used to specify non-argument regions that will be invalidated as a result of this call.
virtual StringRef getKindAsString() const =0
void setForeign(bool B) const
virtual const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
virtual RuntimeDefinition getRuntimeDefinition() const =0
Returns the definition of the function or method that will be called.
CallEventRef cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
CallEvent & operator=(const CallEvent &)=delete
llvm::mapped_iterator< ArrayRef< ParmVarDecl * >::iterator, GetTypeFn > param_type_iterator
const ConstructionContext * getConstructionContext() const
Returns the construction context of the call, if it is a C++ constructor call or a call of a function...
param_type_iterator param_type_end() const
const ParamVarRegion * getParameterLocation(unsigned Index, unsigned BlockCount) const
Returns memory location for a parameter variable within the callee stack frame.
bool isCalledFromSystemHeader() const
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
AnalysisDeclContext * getCalleeAnalysisDeclContext() const
Returns AnalysisDeclContext for the callee stack frame.
ProgramStateRef invalidateRegions(unsigned BlockCount, ProgramStateRef Orig=nullptr) const
Returns a new state with all argument regions invalidated.
virtual std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const
Some calls have parameter numbering mismatched from argument numbering.
const ProgramStateRef & getState() const
The state in which the call is being evaluated.
QualType getResultType() const
Returns the result type, adjusted for references.
CallEvent(const Expr *E, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< T > cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
bool isInSystemHeader() const
Returns true if the callee is known to be from a system header.
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace,...
virtual bool argumentsMayEscape() const
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
CallEvent(const CallEvent &Original)
param_type_iterator param_type_begin() const
Returns an iterator over the types of the call's formal parameters.
std::pair< SVal, SVal > FrameBindingTy
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
virtual ~CallEvent()=default
const StackFrameContext * getCalleeStackFrame(unsigned BlockCount) const
Returns the callee stack frame.
static QualType getDeclaredResultType(const Decl *D)
Returns the result type of a function or method declaration.
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
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 ca...
virtual void cloneTo(void *Dest) const =0
Copies this CallEvent, with vtable intact, into a new block of memory.
static bool isVariadic(const Decl *D)
Returns true if the given decl is known to be variadic.
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
bool hasNonNullArgumentsWithType(bool(*Condition)(QualType)) const
Returns true if the type of any of the non-null arguments satisfies the condition.
std::optional< SVal > getReturnValueUnderConstruction() const
If the call returns a C++ record type then the region of its return value can be retrieved from its c...
virtual const Expr * getArgExpr(unsigned Index) const
Returns the expression associated with a given argument.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
bool hasVoidPointerToNonConstArg() const
Returns true if any of the arguments is void*.
const CallEventRef getCaller() const
bool isArgumentConstructedDirectly(unsigned Index) const
Returns true if on the current path, the argument was constructed by calling a C++ constructor over i...
SmallVectorImpl< FrameBindingTy > BindingsTy
SVal getReturnValue() const
Returns the return value of the call.
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
const LocationContext * getLocationContext() const
The context in which the call is being evaluated.
const CFGBlock::ConstCFGElementRef & getCFGElementRef() const
CallEvent(const Decl *D, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
virtual ArrayRef< ParmVarDecl * > parameters() const =0
Return call's formal parameters.
bool hasNonZeroCallbackArg() const
Returns true if any of the arguments appear to represent callbacks.
virtual Kind getKind() const =0
Returns the kind of call this is.
virtual SourceRange getSourceRange() const
Returns a source range for the entire call, suitable for outputting in diagnostics.
virtual unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
bool isValid() const =delete
static std::optional< SVal > getObjectUnderConstruction(ProgramStateRef State, const ConstructionContextItem &Item, const LocationContext *LC)
By looking at a certain item that may be potentially part of an object's ConstructionContext,...
MemRegion - The root abstract class for all memory regions.
Represents any expression that calls an Objective-C method.
ObjCMethodCall(const ObjCMethodCall &Other)=default
const ObjCMethodDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
static bool classof(const CallEvent *CA)
bool isInstanceMessage() const
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
bool isSetter() const
Returns true if this property access or subscript is a setter (has the form of an assignment).
const ObjCMessageExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
ObjCMethodFamily getMethodFamily() const
ObjCMethodCall(const ObjCMessageExpr *Msg, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
StringRef getKindAsString() const override
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
virtual bool canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, Selector Sel) const
Check if the selector may have multiple definitions (may have overrides).
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
const ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
Selector getSelector() const
const ObjCPropertyDecl * getAccessedProperty() const
Kind getKind() const override
Returns the kind of call this is.
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 ca...
ParamVarRegion - Represents a region for paremters.
Information about invalidation for a particular region/symbol.
Defines the runtime definition of the called function.
RuntimeDefinition(const Decl *InD, const MemRegion *InR)
RuntimeDefinition(const Decl *InD, bool Foreign)
const MemRegion * getDispatchRegion()
When other definitions are possible, returns the region whose runtime type determines the method defi...
RuntimeDefinition()=default
RuntimeDefinition(const Decl *InD)
bool mayHaveOtherDefinitions()
Check if the definition we have is precise.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Represents a C function or static C++ member function call.
static bool classof(const CallEvent *CA)
Kind getKind() const override
Returns the kind of call this is.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
SimpleFunctionCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
SimpleFunctionCall(const SimpleFunctionCall &Other)=default
StringRef getKindAsString() const override
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const VarDecl * getDecl() const override=0
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
@ CE_END_CXX_CONSTRUCTOR_CALLS
@ CE_CXXInheritedConstructor
@ CE_END_CXX_INSTANCE_CALLS
@ CE_BEG_CXX_INSTANCE_CALLS
@ CE_BEG_CXX_CONSTRUCTOR_CALLS
ObjCMessageKind
Represents the ways an Objective-C message send can occur.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ObjCMethodFamily
A family of Objective-C methods.
const FunctionProtoType * T
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
static SimpleType getSimplifiedValue(clang::ento::CallEventRef< T > Val)