Go to the documentation of this file.
49 #include "llvm/ADT/ArrayRef.h"
50 #include "llvm/ADT/DenseMap.h"
51 #include "llvm/ADT/ImmutableList.h"
52 #include "llvm/ADT/None.h"
53 #include "llvm/ADT/Optional.h"
54 #include "llvm/ADT/PointerIntPair.h"
55 #include "llvm/ADT/SmallSet.h"
56 #include "llvm/ADT/SmallVector.h"
57 #include "llvm/ADT/StringExtras.h"
58 #include "llvm/ADT/StringRef.h"
59 #include "llvm/Support/Casting.h"
60 #include "llvm/Support/Compiler.h"
61 #include "llvm/Support/Debug.h"
62 #include "llvm/Support/ErrorHandling.h"
63 #include "llvm/Support/raw_ostream.h"
67 #define DEBUG_TYPE "static-analyzer-call-event"
69 using namespace clang;
95 for (
const auto *I : RD->
fields()) {
126 I != E && Idx < NumOfArgs; ++I, ++Idx) {
146 const auto *FD = dyn_cast_or_null<FunctionDecl>(
getDecl());
184 unsigned Idx = 0, Sz = B->
size();
185 for (; Idx < Sz; ++Idx)
186 if (
auto StmtElem = (*B)[Idx].getAs<CFGStmt>())
187 if (StmtElem->getStmt() == E)
202 State->getStateManager().getRegionManager().getParamVarRegion(
224 const CallEvent &Call) {
227 E = Call.param_type_end();
228 I != E; ++I, ++Idx) {
230 PreserveArgs.insert(Idx);
240 if (callee->hasAttr<PureAttr>() || callee->hasAttr<ConstAttr>())
249 llvm::SmallSet<unsigned, 4> PreserveArgs;
253 for (
unsigned Idx = 0, Count =
getNumArgs(); Idx != Count; ++Idx) {
256 if (PreserveArgs.count(Idx))
258 ETraits.
setTrait(MR->getBaseRegion(),
262 ValuesToInvalidate.push_back(
getArgSVal(Idx));
283 return Result->invalidateRegions(ValuesToInvalidate,
getOriginExpr(),
286 nullptr,
this, &ETraits);
298 assert(D &&
"Cannot get a program point without a statement or decl");
346 return isa<CallExpr, ObjCMessageExpr, CXXConstructExpr, CXXNewExpr>(S);
351 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
352 return FD->getReturnType();
353 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
354 return MD->getReturnType();
355 if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
367 Ty = FT->getReturnType();
375 llvm_unreachable(
"unknown callable kind");
381 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
382 return FD->isVariadic();
383 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
384 return MD->isVariadic();
385 if (
const auto *BD = dyn_cast<BlockDecl>(D))
386 return BD->isVariadic();
388 llvm_unreachable(
"unknown callable kind");
415 BasicValueFactory &BVF = SVB.getBasicValueFactory();
417 llvm::ImmutableList<SVal> CompoundSVals = BVF.getEmptySValList();
418 CompoundSVals = BVF.prependSVal(
Value, CompoundSVals);
421 return SVB.makeCompoundVal(ParamType, CompoundSVals);
430 const CallEvent &Call,
431 ArrayRef<ParmVarDecl*> parameters) {
432 MemRegionManager &MRMgr = SVB.getRegionManager();
436 unsigned NumArgs = Call.getNumArgs();
438 ArrayRef<ParmVarDecl*>::iterator I = parameters.begin(), E = parameters.end();
439 for (; I != E && Idx < NumArgs; ++I, ++Idx) {
440 assert(*I &&
"Formal parameter has no decl?");
444 if (Call.isArgumentConstructedDirectly(Call.getASTArgumentIndex(Idx)))
450 SVal ArgVal = Call.getArgSVal(Idx);
451 const Expr *ArgExpr = Call.getArgExpr(Idx);
452 if (!ArgVal.isUnknown()) {
453 Loc ParamLoc = SVB.makeLoc(
454 MRMgr.getParamVarRegion(Call.getOriginExpr(), Idx, CalleeCtx));
470 return Ctor->getConstructionContext();
474 return RecCall->getConstructionContext();
510 getManager()->getContext(FD);
511 bool IsAutosynthesized;
514 if (IsAutosynthesized)
515 llvm::dbgs() <<
"Using autosynthesized body for " << FD->
getName()
521 *Engine.getCrossTranslationUnitContext();
537 if (!Opts.IsNaiveCTUEnabled)
542 Opts.DisplayCTUProgress);
544 if (!CTUDeclOrError) {
545 handleAllErrors(CTUDeclOrError.takeError(),
547 CTUCtx.emitCrossTUDiagnostics(IE);
558 const auto *D = cast<FunctionDecl>(CalleeCtx->
getDecl());
582 if (II->
isStr(
"pthread_setspecific"))
587 if (II->
isStr(
"xpc_connection_set_context"))
591 if (II->
isStr(
"funopen"))
596 if (II->
isStr(
"__cxa_demangle"))
599 StringRef FName = II->
getName();
603 if (FName.endswith(
"NoCopy"))
608 if (FName.startswith(
"NS") && FName.contains(
"Insert"))
613 if (FName.startswith(
"CF") || FName.startswith(
"CG")) {
614 return StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
615 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
616 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
617 StrInStrNoCase(FName,
"WithData") != StringRef::npos ||
618 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
619 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos;
648 Values.push_back(ThisVal);
651 if (
const auto *D = cast_or_null<CXXMethodDecl>(
getDecl())) {
663 assert(ParentRecord);
694 const auto *MD = cast<CXXMethodDecl>(D);
695 if (!MD->isVirtual())
710 assert(!RegionType.
isNull() &&
"DynamicTypeInfo should always be a pointer.");
717 const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD,
true);
723 assert(!RD->
isDerivedFrom(MD->getParent()) &&
"Couldn't find known method");
737 if (!Result->
hasBody(Definition)) {
762 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
782 ThisVal = SVB.
evalCast(ThisVal, Ty, StaticTy);
788 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
801 if (
const auto *ME = dyn_cast<MemberExpr>(
getOriginExpr()->getCallee()))
802 if (ME->hasQualifier())
816 return dyn_cast_or_null<BlockDataRegion>(DataReg);
838 auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
839 Params = LambdaOperatorDecl->parameters();
847 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
849 Params = cast<BlockDecl>(CalleeCtx->
getDecl())->parameters();
879 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
881 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
888 while (isa<CXXInheritedCtorInitExpr>(SFC->
getCallSite()))
922 if (
const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
931 Values.push_back(IvarLVal);
952 assert(SelfVal.
isValid() &&
"Calling super but not in ObjC method");
967 return (RecVal == SelfVal);
978 llvm_unreachable(
"unknown message kind");
983 const PseudoObjectExpr *ObjCMethodCall::getContainingPseudoObjectExpr()
const {
984 assert(
Data &&
"Lazy lookup not yet performed.");
986 return ObjCMessageDataTy::getFromOpaqueValue(
Data).getPointer();
995 if (
const auto *BO = dyn_cast<BinaryOperator>(Syntactic))
1008 if (
const auto *POE = dyn_cast_or_null<PseudoObjectExpr>(S)) {
1013 case Stmt::ObjCPropertyRefExprClass:
1016 case Stmt::ObjCSubscriptRefExprClass:
1040 if (!Info.getPointer())
1049 assert(POE &&
"Property access without PseudoObjectExpr?");
1052 auto *RefExpr = cast<ObjCPropertyRefExpr>(Syntactic);
1054 if (RefExpr->isExplicitProperty())
1055 return RefExpr->getExplicitProperty();
1071 getState()->getStateManager().getOwningEngine().getAnalysisManager();
1118 llvm_unreachable(
"The while loop should always terminate.");
1129 MD = cast<ObjCMethodDecl>(I);
1146 return {InterfaceInfo::getEmptyKey(), SelectorInfo::getEmptyKey(),
false};
1150 return {InterfaceInfo::getTombstoneKey(), SelectorInfo::getTombstoneKey(),
1156 llvm::hash_code(InterfaceInfo::getHashValue(Key.
Interface)),
1172 Selector LookupSelector,
bool InstanceMethod) {
1187 using PrivateMethodCache =
1188 llvm::DenseMap<PrivateMethodKey, Optional<const ObjCMethodDecl *>>;
1190 static PrivateMethodCache PMC;
1192 PMC[{Interface, LookupSelector, InstanceMethod}];
1195 if (!Val.hasValue()) {
1200 Val = Interface->
lookupMethod(LookupSelector, InstanceMethod);
1204 return Val.getValue();
1215 bool CanBeSubClassed =
false;
1216 bool LookingForInstanceMethod =
true;
1220 if (!SupersType.
isNull()) {
1224 ReceiverT = cast<ObjCObjectPointerType>(SupersType)->getObjectType();
1232 assert(isa<AllocaRegion>(Receiver) &&
1233 "Unhandled untyped region class!");
1240 const auto *ReceiverDynT =
1244 ReceiverT = ReceiverDynT->getObjectType();
1269 LookingForInstanceMethod =
false;
1274 if (CanBeSubClassed)
1292 if (CanBeSubClassed)
1324 const auto *D = cast<ObjCMethodDecl>(CalleeCtx->
getDecl());
1334 Bindings.push_back(std::make_pair(SelfLoc, SelfVal));
1341 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
1342 return create<CXXMemberCall>(MCE,
State, LCtx);
1344 if (
const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
1345 const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
1346 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
1347 if (MD->isInstance())
1348 return create<CXXMemberOperatorCall>(OpCE,
State, LCtx);
1351 return create<BlockCall>(CE,
State, LCtx);
1356 return create<SimpleFunctionCall>(CE,
State, LCtx);
1364 assert(CallerCtx &&
"This should not be used for top-level stack frames");
1373 const auto *Ctor = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
1377 if (
const auto *CE = dyn_cast<CXXConstructExpr>(CallSite))
1379 else if (
const auto *CIE = dyn_cast<CXXInheritedCtorInitExpr>(CallSite))
1384 llvm_unreachable(
"This is not an inlineable statement");
1393 "All other CFG elements should have exprs");
1396 const auto *Dtor = cast<CXXDestructorDecl>(CalleeCtx->
getDecl());
1400 const Stmt *Trigger;
1402 Trigger = AutoDtor->getTriggerStmt();
1404 Trigger = DeleteDtor->getDeleteExpr();
1406 Trigger = Dtor->getBody();
1415 if (
const auto *CE = dyn_cast<CallExpr>(S)) {
1417 }
else if (
const auto *
NE = dyn_cast<CXXNewExpr>(S)) {
1419 }
else if (
const auto *DE = dyn_cast<CXXDeleteExpr>(S)) {
1421 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(S)) {
CFGStmtMap * getCFGStmtMap()
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
@ SuperInstance
The receiver is the instance of the superclass object.
Represents an ObjC class declaration.
static void findPtrToConstParams(llvm::SmallSet< unsigned, 4 > &PreserveArgs, const CallEvent &Call)
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.
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
ArrayRef< ParmVarDecl * > parameters() const
static void addParameterValuesToBindings(const StackFrameContext *CalleeCtx, CallEvent::BindingsTy &Bindings, SValBuilder &SVB, const CallEvent &Call, ArrayRef< ParmVarDecl * > parameters)
YAML serialization mapping.
CallEventRef getCall(const Stmt *S, ProgramStateRef State, const LocationContext *LC)
Gets a call event for a function call, Objective-C method call, a 'new', or a 'delete' call.
const CXXMemberCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
bool isBlockPointerType() const
const ObjCMessageExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
bool isArgumentConstructedDirectly(unsigned Index) const
Returns true if on the current path, the argument was constructed by calling a C++ constructor over i...
QualType getType() const
Returns the currently inferred upper bound on the runtime type.
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...
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const StackFrameContext * getStackFrame() const
CallEventRef< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const LocationContext *LCtx)
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,...
A trivial tuple used to represent a source range.
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
@ Parameter
The parameter type of a method or function.
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 isConstQualified() const
Determine whether this type is const-qualified.
Selector getSelector() const
const MemRegion * getAsRegion() const
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
const ObjCInterfaceDecl * Interface
Stores the currently inferred strictest bound on the runtime type of a region in a given state along ...
virtual const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
const StackFrameContext * getStackFrame(const Decl *D)
Obtain the beginning context of the analysis.
const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
Stmt * getParentIgnoreParenCasts(Stmt *) const
Encodes a location in the source.
static PrivateMethodKey getEmptyKey()
CallEventRef< CXXDeallocatorCall > getCXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef State, const LocationContext *LCtx)
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
SourceLocation getBegin() const
SValBuilder & getSValBuilder()
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
A (possibly-)qualified type.
ConstructionContext's subclasses describe different ways of constructing an object in C++.
CallEventRef< ObjCMethodCall > getObjCMethodCall(const ObjCMessageExpr *E, ProgramStateRef State, const LocationContext *LCtx)
AnalysisDeclContext contains the context data for the function, method or block under analysis.
const ImplicitParamDecl * getSelfDecl() const
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
QualType getCanonicalType() const
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
Represents a parameter to a function.
bool hasVoidPointerToNonConstArg() const
Returns true if any of the arguments is void*.
CFGElement getCallSiteCFGElement() const
bool isObjCSelType() const
ObjCInterfaceDecl * getClassInterface()
const CFGBlock * getCallSiteBlock() const
param_type_iterator param_type_end() const
const ConstructionContext * getConstructionContext() const
Returns the construction context of the call, if it is a C++ constructor call or a call of a function...
It represents a stack frame of the call stack (based on CallEvent).
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace,...
const ObjCPropertyDecl * getAccessedProperty() const
unsigned getIndex() const
static QualType getDeclaredResultType(const Decl *D)
Returns the result type of a function or method declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
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...
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
@ SuperClass
The receiver is a superclass.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
virtual bool argumentsMayEscape() const
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Represents a program point just after an implicit call event.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type.
Represents a class type in Objective C.
const RecordType * getAsStructureType() const
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
MemRegion - The root abstract class for all memory regions.
const ProgramStateRef & getState() const
The state in which the call is being evaluated.
Represents a single basic block in a source-level CFG.
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
const ObjCMethodDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
static const ObjCMethodDecl * lookupRuntimeDefinition(const ObjCInterfaceDecl *Interface, Selector LookupSelector, bool InstanceMethod)
DenseMapInfo< Selector > SelectorInfo
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
bool isReferenceType() const
SVal getReturnValue() const
Returns the return value of the call.
const LocationContext * getLocationContext() const
The context in which the call is being evaluated.
Selector getSelector() const
Hints for figuring out of a call should be inlined during evalCall().
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static bool isEqual(const PrivateMethodKey &LHS, const PrivateMethodKey &RHS)
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
const CallExpr * 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.
static bool isInCodeFile(SourceLocation SL, const SourceManager &SM)
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents C++ constructor call.
AnalysisDeclContext * getAnalysisDeclContext() const
virtual const Expr * getCXXThisExpr() const
Returns the expression representing the implicit 'this' object.
virtual SourceRange getSourceRange() const
Returns a source range for the entire call, suitable for outputting in diagnostics.
ASTContext & getContext()
This class is used for tools that requires cross translation unit capability.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
bool isFunctionPointerType() const
SVal computeObjectUnderConstruction(const Expr *E, ProgramStateRef State, const LocationContext *LCtx, const ConstructionContext *CC, EvalCallOptions &CallOpts)
Find location of the object that is being constructed by a given constructor.
void setTrait(SymbolRef Sym, InvalidationKinds IK)
llvm::PointerIntPair< const PseudoObjectExpr *, 2 > ObjCMessageDataTy
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
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...
SmallVectorImpl< FrameBindingTy > BindingsTy
const BlockDataRegion * getBlockRegion() const
Returns the region associated with this instance of the block.
unsigned getNumArgs() const
const T * getAs() const
Member-template getAs<specific type>'.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
MemRegionManager & getRegionManager()
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
static SVal processArgument(SVal Value, const Expr *ArgumentExpr, const ParmVarDecl *Parameter, SValBuilder &SVB)
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
BlockDataRegion - A region that represents a block instance.
CallEventRef< CXXInheritedConstructorCall > getCXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx)
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx)
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...
ProgramStateRef invalidateRegions(unsigned BlockCount, ProgramStateRef Orig=nullptr) const
Returns a new state with all argument regions invalidated.
static bool isPointerToConst(QualType Ty)
Returns true if a type is a pointer-to-const or reference-to-const with no further indirection.
SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
QualType getRecordType(const RecordDecl *Decl) const
static const ObjCMethodDecl * findDefiningRedecl(const ObjCMethodDecl *MD)
Represents a variable declaration or definition.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Represents a function call that returns a C++ object by value.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const LocationContext *LCtx)
bool isValid() const
Returns true if the dynamic type info is available.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
CallEventRef getCaller(const StackFrameContext *CalleeCtx, ProgramStateRef State)
Gets an outside caller given a callee context.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
An expression that sends a message to the given Objective-C object or class.
static bool isVoidPointerToNonConst(QualType T)
AnalysisDeclContext * getContext(const Decl *D)
virtual SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const LocationContext *LCtx)
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.
bool hasNonZeroCallbackArg() const
Returns true if any of the arguments appear to represent callbacks.
AnalysisDeclContextManager * getManager() const
Represents C++ object destructor implicitly generated by compiler on various occasions.
static const Expr * getSyntacticFromForPseudoObjectExpr(const PseudoObjectExpr *POE)
const LocationContext * getParent() const
bool isConversionFromLambda() const
virtual const Expr * getArgExpr(unsigned Index) const
Returns the expression associated with a given argument.
Represents a C++ struct/union/class.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
loc::MemRegionVal makeLoc(SymbolRef sym)
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
StmtClass getStmtClass() const
bool isPointerType() const
ObjCMessageKind
Represents the ways an Objective-C message send can occur.
SVal getCXXThisVal() const override
Returns the value of the implicit 'this' object.
SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy)
Cast a given SVal to another SVal using given QualType's.
llvm::mapped_iterator< ArrayRef< ParmVarDecl * >::iterator, GetTypeFn > param_type_iterator
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Optional< T > getAs() const
Convert to the specified CFGElement type, returning None if this CFGElement is not of the desired typ...
static const Decl * getCanonicalDecl(const Decl *D)
const clang::PrintingPolicy & getPrintingPolicy() const
field_range fields() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
DenseMapInfo< const ObjCInterfaceDecl * > InterfaceInfo
param_type_iterator param_type_begin() const
Returns an iterator over the types of the call's formal parameters.
Decl - This represents one declaration (or definition), e.g.
Represents one property declaration in an Objective-C interface.
bool hasNonNullArgumentsWithType(bool(*Condition)(QualType)) const
Returns true if the type of any of the non-null arguments satisfies the condition.
virtual void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const
Used to specify non-argument regions that will be invalidated as a result of this call.
const Stmt * getCallSite() const
virtual bool canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, Selector Sel) const
Check if the selector may have multiple definitions (may have overrides).
const CallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
Represents a program point just before an implicit call event.
bool hasError(const Decl *ToDecl) const
Returns true if the given Decl is mapped (or created) during an import but there was an unrecoverable...
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
virtual Optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const
Some calls have parameter numbering mismatched from argument numbering.
virtual StringRef getKindAsString() const =0
Stores options for the analyzer from the command line.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
ObjCInterfaceDecl * getSuperClass() const
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
Represents any expression that calls an Objective-C method.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
One of these records is kept for each identifier that is lexed.
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
bool isInstanceMessage() const
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name=StringRef())
Returns true if the callee is an externally-visible function in the top-level namespace,...
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...
QualType getResultType() const
Returns the result type, adjusted for references.
Represents a top-level expression in a basic block.
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
StoreManager & getStoreManager()
const BlockDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
virtual Kind getKind() const =0
Returns the kind of call this is.
ObjCMethodDecl - Represents an instance or class method declaration.
PointerType - C99 6.7.5.1 - Pointer Declarators.
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
bool hasBody() const override
Determine whether this method has a body.
bool NE(InterpState &S, CodePtr OpPC)
SourceLocation getEndOfDefinitionLoc() const
@ TK_PreserveContents
Tells that a region's contents is not changed.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
StringRef getName() const
Return the actual identifier string.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isAnyPointerType() const
static bool isVariadic(const Decl *D)
Returns true if the given decl is known to be variadic.
bool isInSystemHeader() const
Returns true if the callee is known to be from a system header.
Represents C++ object destructor generated from a call to delete.
Smart pointer class that efficiently represents Objective-C method names.
bool isUnknownOrUndef() const
const Decl * getDecl() const
Stmt - This represents one statement.
ObjCIvarDecl - Represents an ObjC instance variable.
static unsigned getHashValue(const PrivateMethodKey &Key)
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
Represents C++ object destructor implicitly generated for base object in destructor.
@ TK_DoNotInvalidateSuperRegion
Expr * IgnoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool hasDefinition() const
A container of type source information.
const ObjCMethodDecl * getMethodDecl() const
static bool isTransparentUnion(QualType T)
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
const VarRegion * getRegionStoringCapturedLambda() const
For a block converted from a C++ lambda, returns the block VarRegion for the variable holding the cap...
bool canBeASubClass() const
Returns false if the type information is precise (the type 'DynTy' is the only type in the lattice),...
bool isPropertyAccessor() const
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
RecordDecl * getDecl() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
AnalysisDeclContext * getCalleeAnalysisDeclContext() const
Returns AnalysisDeclContext for the callee stack frame.
ArrayRef< ParmVarDecl * > parameters() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
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...
TypedValueRegion - An abstract class representing regions having a typed value.
static bool isCallback(QualType T)
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
QualType getSuperType() const
Retrieve the type referred to by 'super'.
const MemRegion * getBaseRegion() const
Information about invalidation for a particular region/symbol.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
This represents one expression.
DynamicTypeInfo getClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym)
Get dynamic type information stored in a class object represented by Sym.
bool isImportedAsNew(const Decl *ToDecl) const
Returns true if the given Decl is newly created during the import.
const ParamVarRegion * getParameterLocation(unsigned Index, unsigned BlockCount) const
Returns memory location for a parameter variable within the callee stack frame.
static PrivateMethodKey getTombstoneKey()
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
Optional< SVal > evalBaseToDerived(SVal Base, QualType DerivedPtrType)
Attempts to do a down cast.
ArrayRef< ParmVarDecl * > parameters() const
SourceLocation getLocation() const
const Decl * getDecl() const
Represents a function declaration or definition.
Represents a struct/union/class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
const StackFrameContext * getCalleeStackFrame(unsigned BlockCount) const
Returns the callee stack frame.
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.
ParamVarRegion - Represents a region for paremters.
const ParentMap & getParentMap() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a static or instance method of a struct/union/class.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.