49#include "llvm/ADT/ArrayRef.h"
50#include "llvm/ADT/DenseMap.h"
51#include "llvm/ADT/ImmutableList.h"
52#include "llvm/ADT/PointerIntPair.h"
53#include "llvm/ADT/SmallSet.h"
54#include "llvm/ADT/SmallVector.h"
55#include "llvm/ADT/StringExtras.h"
56#include "llvm/ADT/StringRef.h"
57#include "llvm/Support/Casting.h"
58#include "llvm/Support/Compiler.h"
59#include "llvm/Support/Debug.h"
60#include "llvm/Support/ErrorHandling.h"
61#include "llvm/Support/raw_ostream.h"
66#define DEBUG_TYPE "static-analyzer-call-event"
94 for (
const auto *I : RD->
fields()) {
125 I !=
E && Idx < NumOfArgs; ++I, ++Idx) {
145 const auto *FD = dyn_cast_or_null<FunctionDecl>(
getDecl());
183 unsigned Idx = 0, Sz = B->
size();
184 for (; Idx < Sz; ++Idx)
185 if (
auto StmtElem = (*B)[Idx].getAs<CFGStmt>())
186 if (StmtElem->getStmt() ==
E)
201 State->getStateManager().getRegionManager().getParamVarRegion(
226 E =
Call.param_type_end();
227 I !=
E; ++I, ++Idx) {
229 PreserveArgs.insert(Idx);
239 if (callee->hasAttr<PureAttr>() || callee->hasAttr<ConstAttr>())
248 llvm::SmallSet<unsigned, 4> PreserveArgs;
252 for (
unsigned Idx = 0, Count =
getNumArgs(); Idx != Count; ++Idx) {
255 if (PreserveArgs.count(Idx))
257 ETraits.
setTrait(MR->getBaseRegion(),
261 ValuesToInvalidate.push_back(
getArgSVal(Idx));
285 nullptr,
this, &ETraits);
298 assert(
D &&
"Cannot get a program point without a statement or decl");
299 assert(ElemRef.getParent() &&
300 "Cannot get a program point without a CFGElementRef");
348 return isa<CallExpr, ObjCMessageExpr, CXXConstructExpr, CXXNewExpr>(S);
353 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
354 return FD->getReturnType();
355 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
356 return MD->getReturnType();
357 if (
const auto *BD = dyn_cast<BlockDecl>(
D)) {
369 Ty = FT->getReturnType();
377 llvm_unreachable(
"unknown callable kind");
383 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
384 return FD->isVariadic();
385 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
386 return MD->isVariadic();
387 if (
const auto *BD = dyn_cast<BlockDecl>(
D))
388 return BD->isVariadic();
390 llvm_unreachable(
"unknown callable kind");
438 Call.getRuntimeDefinition().getDecl()->getAsFunction();
439 const auto *CallExprDecl = dyn_cast_or_null<FunctionDecl>(
Call.getDecl());
441 if (!RTDecl || !CallExprDecl)
448 if (CallExprDecl->hasPrototype() || !RTDecl->
hasPrototype())
456 const Expr *ArgExpr =
Call.getArgExpr(ArgIdx);
470 unsigned NumArgs =
Call.getNumArgs();
473 for (; I !=
E && Idx < NumArgs; ++I, ++Idx) {
474 assert(*I &&
"Formal parameter has no decl?");
478 if (
Call.isArgumentConstructedDirectly(
Call.getASTArgumentIndex(Idx)))
485 const Expr *ArgExpr =
Call.getArgExpr(Idx);
510 return Ctor->getConstructionContext();
514 return RecCall->getConstructionContext();
522 if (!CallLocationContext || CallLocationContext->inTopFrame())
525 const auto *CallStackFrameContext = CallLocationContext->getStackFrame();
526 if (!CallStackFrameContext)
530 return CEMgr.
getCaller(CallStackFrameContext, State);
535 return Caller->isInSystemHeader();
557 return D->parameters();
569 getManager()->getContext(FD);
570 bool IsAutosynthesized;
573 if (IsAutosynthesized)
574 llvm::dbgs() <<
"Using autosynthesized body for " << FD->
getName()
580 *Engine.getCrossTranslationUnitContext();
596 if (!Opts.IsNaiveCTUEnabled)
601 Opts.DisplayCTUProgress);
603 if (!CTUDeclOrError) {
604 handleAllErrors(CTUDeclOrError.takeError(),
606 CTUCtx.emitCrossTUDiagnostics(IE);
617 const auto *
D = cast<FunctionDecl>(CalleeCtx->
getDecl());
641 if (II->
isStr(
"pthread_setspecific"))
646 if (II->
isStr(
"xpc_connection_set_context"))
650 if (II->
isStr(
"funopen"))
655 if (II->
isStr(
"__cxa_demangle"))
658 StringRef FName = II->
getName();
662 if (FName.ends_with(
"NoCopy"))
667 if (FName.starts_with(
"NS") && FName.contains(
"Insert"))
672 if (FName.starts_with(
"CF") || FName.starts_with(
"CG")) {
673 return StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
674 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
675 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
676 StrInStrNoCase(FName,
"WithData") != StringRef::npos ||
677 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
678 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos;
707 Values.push_back(ThisVal);
710 if (
const auto *
D = cast_or_null<CXXMethodDecl>(
getDecl())) {
722 assert(ParentRecord);
740 if (isa<NonLoc>(ThisVal)) {
743 return SVB.
evalCast(ThisVal,
Base->getType(), OriginalTy);
757 const auto *MD = cast<CXXMethodDecl>(
D);
758 if (!MD->isVirtual())
773 assert(!RegionType.
isNull() &&
"DynamicTypeInfo should always be a pointer.");
786 assert(!RD->
isDerivedFrom(MD->getParent()) &&
"Couldn't find known method");
826 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
837 std::optional<SVal>
V =
846 ThisVal = SVB.
evalCast(ThisVal, Ty, StaticTy);
852 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
865 if (
const auto *ME = dyn_cast<MemberExpr>(
getOriginExpr()->getCallee()))
866 if (ME->hasQualifier())
880 return dyn_cast_or_null<BlockDataRegion>(DataReg);
887 return D->parameters();
902 auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
903 Params = LambdaOperatorDecl->parameters();
911 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
913 Params = cast<BlockDecl>(CalleeCtx->
getDecl())->parameters();
929 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC);
930 NS && NS->isStdNamespace())
946 if (
const MemRegion *Obj =
V.getAsRegion(); Obj && IsStdClassCtor) {
962 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
964 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
971 while (isa<CXXInheritedCtorInitExpr>(SFC->
getCallSite()))
995 return D->parameters();
1005 if (
const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
1014 Values.push_back(IvarLVal);
1035 assert(SelfVal.
isValid() &&
"Calling super but not in ObjC method");
1050 return (RecVal == SelfVal);
1061 llvm_unreachable(
"unknown message kind");
1066const PseudoObjectExpr *ObjCMethodCall::getContainingPseudoObjectExpr()
const {
1067 assert(
Data &&
"Lazy lookup not yet performed.");
1069 return ObjCMessageDataTy::getFromOpaqueValue(
Data).getPointer();
1078 if (
const auto *BO = dyn_cast<BinaryOperator>(Syntactic))
1091 if (
const auto *POE = dyn_cast_or_null<PseudoObjectExpr>(S)) {
1096 case Stmt::ObjCPropertyRefExprClass:
1099 case Stmt::ObjCSubscriptRefExprClass:
1123 if (!Info.getPointer())
1132 assert(POE &&
"Property access without PseudoObjectExpr?");
1135 auto *RefExpr = cast<ObjCPropertyRefExpr>(Syntactic);
1137 if (RefExpr->isExplicitProperty())
1138 return RefExpr->getExplicitProperty();
1154 getState()->getStateManager().getOwningEngine().getAnalysisManager();
1185 if (
D->isOverriding()) {
1187 IDecl =
D->getClassInterface();
1201 llvm_unreachable(
"The while loop should always terminate.");
1212 MD = cast<ObjCMethodDecl>(I);
1229 return {InterfaceInfo::getEmptyKey(), SelectorInfo::getEmptyKey(),
false};
1233 return {InterfaceInfo::getTombstoneKey(), SelectorInfo::getTombstoneKey(),
1238 return llvm::hash_combine(
1239 llvm::hash_code(InterfaceInfo::getHashValue(Key.
Interface)),
1255 Selector LookupSelector,
bool InstanceMethod) {
1270 using PrivateMethodCache =
1271 llvm::DenseMap<PrivateMethodKey, std::optional<const ObjCMethodDecl *>>;
1273 static PrivateMethodCache PMC;
1274 std::optional<const ObjCMethodDecl *> &Val =
1275 PMC[{
Interface, LookupSelector, InstanceMethod}];
1279 Val =
Interface->lookupPrivateMethod(LookupSelector, InstanceMethod);
1283 Val =
Interface->lookupMethod(LookupSelector, InstanceMethod);
1295 if (
E->isInstanceMessage()) {
1298 bool CanBeSubClassed =
false;
1299 bool LookingForInstanceMethod =
true;
1300 QualType SupersType =
E->getSuperType();
1303 if (!SupersType.
isNull()) {
1307 ReceiverT = cast<ObjCObjectPointerType>(SupersType)->getObjectType();
1315 assert(isa<AllocaRegion>(Receiver) &&
1316 "Unhandled untyped region class!");
1323 const auto *ReceiverDynT =
1327 ReceiverT = ReceiverDynT->getObjectType();
1352 LookingForInstanceMethod =
false;
1357 if (CanBeSubClassed)
1375 if (CanBeSubClassed)
1407 const auto *
D = cast<ObjCMethodDecl>(CalleeCtx->
getDecl());
1417 Bindings.push_back(std::make_pair(SelfLoc, SelfVal));
1425 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
1426 return create<CXXMemberCall>(MCE, State, LCtx, ElemRef);
1428 if (
const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
1429 const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
1430 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee)) {
1431 if (MD->isImplicitObjectMemberFunction())
1432 return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef);
1434 return create<CXXStaticOperatorCall>(OpCE, State, LCtx, ElemRef);
1438 return create<BlockCall>(CE, State, LCtx, ElemRef);
1443 return create<SimpleFunctionCall>(CE, State, LCtx, ElemRef);
1453 assert(CallerCtx &&
"This should not be used for top-level stack frames");
1461 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1462 const auto *Ctor = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
1464 SVal ThisVal = State->getSVal(ThisPtr);
1466 if (
const auto *CE = dyn_cast<CXXConstructExpr>(CallSite))
1469 else if (
const auto *CIE = dyn_cast<CXXInheritedCtorInitExpr>(CallSite))
1471 CallerCtx, ElemRef);
1474 llvm_unreachable(
"This is not an inlineable statement");
1483 "All other CFG elements should have exprs");
1485 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1486 const auto *Dtor = cast<CXXDestructorDecl>(CalleeCtx->
getDecl());
1488 SVal ThisVal = State->getSVal(ThisPtr);
1490 const Stmt *Trigger;
1491 if (std::optional<CFGAutomaticObjDtor> AutoDtor =
1493 Trigger = AutoDtor->getTriggerStmt();
1494 else if (std::optional<CFGDeleteDtor> DeleteDtor =
E.getAs<
CFGDeleteDtor>())
1495 Trigger = DeleteDtor->getDeleteExpr();
1497 Trigger = Dtor->getBody();
1501 CallerCtx, ElemRef);
1507 if (
const auto *CE = dyn_cast<CallExpr>(S)) {
1509 }
else if (
const auto *NE = dyn_cast<CXXNewExpr>(S)) {
1511 }
else if (
const auto *DE = dyn_cast<CXXDeleteExpr>(S)) {
1513 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(S)) {
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static bool isZeroConstant(const llvm::Value *Value)
static bool isVoidPointerToNonConst(QualType T)
static const ObjCMethodDecl * findDefiningRedecl(const ObjCMethodDecl *MD)
static const ObjCMethodDecl * lookupRuntimeDefinition(const ObjCInterfaceDecl *Interface, Selector LookupSelector, bool InstanceMethod)
static void addParameterValuesToBindings(const StackFrameContext *CalleeCtx, CallEvent::BindingsTy &Bindings, SValBuilder &SVB, const CallEvent &Call, ArrayRef< ParmVarDecl * > parameters)
static const Expr * getSyntacticFromForPseudoObjectExpr(const PseudoObjectExpr *POE)
static bool isTransparentUnion(QualType T)
llvm::PointerIntPair< const PseudoObjectExpr *, 2 > ObjCMessageDataTy
static bool isCallback(QualType T)
static SVal castArgToParamTypeIfNeeded(const CallEvent &Call, unsigned ArgIdx, SVal ArgVal, SValBuilder &SVB)
Cast the argument value to the type of the parameter at the function declaration.
static bool isWithinStdNamespace(const Decl *D)
static SVal processArgument(SVal Value, const Expr *ArgumentExpr, const ParmVarDecl *Parameter, SValBuilder &SVB)
static void findPtrToConstParams(llvm::SmallSet< unsigned, 4 > &PreserveArgs, const CallEvent &Call)
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.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
static bool isPointerToConst(const QualType &QT)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getRecordType(const RecordDecl *Decl) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
const clang::PrintingPolicy & getPrintingPolicy() const
AnalysisDeclContext * getContext(const Decl *D)
const StackFrameContext * getStackFrame(const Decl *D)
Obtain the beginning context of the analysis.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
CFGStmtMap * getCFGStmtMap()
const Decl * getDecl() const
const ImplicitParamDecl * getSelfDecl() const
AnalysisDeclContextManager * getManager() const
Stores options for the analyzer from the command line.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Represents C++ object destructor implicitly generated for base object in destructor.
Represents a single basic block in a source-level CFG.
ElementRefImpl< true > ConstCFGElementRef
Represents a function call that returns a C++ object by value.
Represents C++ constructor call.
Represents C++ object destructor generated from a call to delete.
Represents a top-level expression in a basic block.
std::optional< T > getAs() const
Convert to the specified CFGElement type, returning std::nullopt if this CFGElement is not of the des...
Represents C++ object destructor implicitly generated by compiler on various occasions.
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
bool hasDefinition() const
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
ConstructionContext's subclasses describe different ways of constructing an object in C++.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Expr * IgnoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
FunctionType - C99 6.7.5.3 - Function Declarators.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
const ParentMap & getParentMap() const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
const LocationContext * getParent() const
It might return null.
const StackFrameContext * getStackFrame() const
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Represents an ObjC class declaration.
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class,...
SourceLocation getEndOfDefinitionLoc() const
ObjCInterfaceDecl * getSuperClass() const
ObjCIvarDecl - Represents an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
@ SuperInstance
The receiver is the instance of the superclass object.
@ SuperClass
The receiver is a superclass.
ObjCMethodDecl - Represents an instance or class method declaration.
bool hasBody() const override
Determine whether this method has a body.
bool isPropertyAccessor() const
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a class type in Objective C.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
Represents one property declaration in an Objective-C interface.
Stmt * getParentIgnoreParenCasts(Stmt *) const
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Represents a program point just after an implicit call event.
Represents a program point just before an implicit call event.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
Represents a struct/union/class.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
unsigned getNumArgs() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
It represents a stack frame of the call stack (based on CallEvent).
unsigned getIndex() const
CFGElement getCallSiteCFGElement() const
const Stmt * getCallSite() const
const CFGBlock * getCallSiteBlock() const
Stmt - This represents one statement.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
A container of type source information.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isFunctionPointerType() const
bool isPointerType() const
bool isObjCSelType() const
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const RecordType * getAsStructureType() const
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a variable declaration or definition.
This class is used for tools that requires cross translation unit capability.
llvm::Expected< const FunctionDecl * > getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir, StringRef IndexName, bool DisplayCTUProgress=false)
This function loads a function or variable definition from an external AST file and merges it into th...
bool hasError(const Decl *ToDecl) const
Returns true if the given Decl is mapped (or created) during an import but there was an unrecoverable...
bool isImportedAsNew(const Decl *ToDecl) const
Returns true if the given Decl is newly created during the import.
static bool isInCodeFile(SourceLocation SL, const SourceManager &SM)
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...
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.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
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...
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
llvm::ImmutableList< SVal > getEmptySValList()
llvm::ImmutableList< SVal > prependSVal(SVal X, llvm::ImmutableList< SVal > L)
const BlockDecl * getDecl() const override
Returns the declaration 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.
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...
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...
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.
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.
const StackFrameContext * getInheritingStackFrame() const
Obtain the stack frame of the inheriting constructor.
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.
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...
const CXXMemberCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
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)
CallEventRef getCaller(const StackFrameContext *CalleeCtx, ProgramStateRef State)
Gets an outside caller given a callee context.
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
virtual const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
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
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.
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...
param_type_iterator param_type_begin() const
Returns an iterator over the types of the call's formal parameters.
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
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.
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...
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.
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.
static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name=StringRef())
Returns true if the given function is an externally-visible function in the top-level namespace,...
Stores the currently inferred strictest bound on the runtime type of a region in a given state along ...
bool canBeASubClass() const
Returns false if the type information is precise (the type 'DynTy' is the only type in the lattice),...
QualType getType() const
Returns the currently inferred upper bound on the runtime type.
bool isValid() const
Returns true if the dynamic type info is available.
SVal computeObjectUnderConstruction(const Expr *E, ProgramStateRef State, const NodeBuilderContext *BldrCtx, const LocationContext *LCtx, const ConstructionContext *CC, EvalCallOptions &CallOpts, unsigned Idx=0)
Find location of the object that is being constructed by a given constructor.
const NodeBuilderContext & getBuilderContext()
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
MemRegion - The root abstract class for all memory regions.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
Represents any expression that calls an Objective-C method.
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.
bool isInstanceMessage() const
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
const ObjCMessageExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
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.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
Selector getSelector() const
const ObjCPropertyDecl * getAccessedProperty() const
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.
SValBuilder & getSValBuilder()
StoreManager & getStoreManager()
Information about invalidation for a particular region/symbol.
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_DoNotInvalidateSuperRegion
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
void setTrait(SymbolRef Sym, InvalidationKinds IK)
Defines the runtime definition of the called function.
BasicValueFactory & getBasicValueFactory()
NonLoc makeCompoundVal(QualType type, llvm::ImmutableList< SVal > vals)
MemRegionManager & getRegionManager()
ASTContext & getContext()
loc::MemRegionVal makeLoc(SymbolRef sym)
SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy)
Cast a given SVal to another SVal using given QualType's.
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
bool isUnknownOrUndef() const
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
QualType getType(const ASTContext &) const
Try to get a reasonable type for the given value.
const MemRegion * getAsRegion() const
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.
std::optional< SVal > evalBaseToDerived(SVal Base, QualType DerivedPtrType)
Attempts to do a down cast.
TypedValueRegion - An abstract class representing regions having a typed value.
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
ObjCMessageKind
Represents the ways an Objective-C message send can occur.
DynamicTypeInfo getClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym)
Get dynamic type information stored in a class object represented by Sym.
The JSON file list parser is used to communicate input to InstallAPI.
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Diagnostic wrappers for TextAPI types for error reporting.
const ObjCInterfaceDecl * Interface
Hints for figuring out of a call should be inlined during evalCall().
DenseMapInfo< Selector > SelectorInfo
static unsigned getHashValue(const PrivateMethodKey &Key)
static PrivateMethodKey getEmptyKey()
DenseMapInfo< const ObjCInterfaceDecl * > InterfaceInfo
static bool isEqual(const PrivateMethodKey &LHS, const PrivateMethodKey &RHS)
static PrivateMethodKey getTombstoneKey()