48 #include "llvm/ADT/ArrayRef.h" 49 #include "llvm/ADT/DenseMap.h" 50 #include "llvm/ADT/None.h" 51 #include "llvm/ADT/Optional.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" 65 #define DEBUG_TYPE "static-analyzer-call-event" 67 using namespace clang;
112 for (
const auto *I : RD->
fields()) {
143 I != E && Idx < NumOfArgs; ++I, ++Idx) {
163 const auto *FD = dyn_cast_or_null<FunctionDecl>(
getDecl());
215 unsigned Idx = 0, Sz = B->
size();
216 for (; Idx < Sz; ++Idx)
217 if (
auto StmtElem = (*B)[Idx].getAs<CFGStmt>())
218 if (StmtElem->getStmt() == E)
226 unsigned BlockCount)
const {
240 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
241 PVD = FD->parameters()[Index];
242 else if (
const auto *BD = dyn_cast<BlockDecl>(D))
243 PVD = BD->parameters()[Index];
244 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
245 PVD = MD->parameters()[Index];
246 else if (
const auto *CD = dyn_cast<CXXConstructorDecl>(D))
247 PVD = CD->parameters()[Index];
248 assert(PVD &&
"Unexpected Decl kind!");
251 State->getStateManager().getRegionManager().getVarRegion(PVD, SFC);
280 E = Call.param_type_end();
281 I != E; ++I, ++Idx) {
283 PreserveArgs.insert(Idx);
293 if (callee->hasAttr<PureAttr>() || callee->hasAttr<ConstAttr>())
302 llvm::SmallSet<unsigned, 4> PreserveArgs;
306 for (
unsigned Idx = 0, Count =
getNumArgs(); Idx != Count; ++Idx) {
309 if (PreserveArgs.count(Idx))
311 ETraits.
setTrait(MR->getBaseRegion(),
315 ValuesToInvalidate.push_back(
getArgSVal(Idx));
335 return Result->invalidateRegions(ValuesToInvalidate,
getOriginExpr(),
338 nullptr,
this, &ETraits);
350 assert(D &&
"Cannot get a program point without a statement or decl");
372 (!CD.RequiredArgs || CD.RequiredArgs <=
getNumArgs()) &&
373 (!CD.RequiredParams || CD.RequiredParams <=
parameters().size());
376 if (!CD.IsLookupDone) {
377 CD.IsLookupDone =
true;
378 CD.II = &
getState()->getStateManager().getContext().Idents.get(
387 if (CD.QualifiedName.size() > 1 && FD) {
390 size_t NumUnmatched = CD.QualifiedName.size() - 1;
391 for (; Ctx && isa<NamedDecl>(Ctx); Ctx = Ctx->
getParent()) {
392 if (NumUnmatched == 0)
395 if (
const auto *ND = dyn_cast<NamespaceDecl>(Ctx)) {
396 if (ND->getName() == CD.QualifiedName[NumUnmatched - 1])
401 if (
const auto *RD = dyn_cast<RecordDecl>(Ctx)) {
402 if (RD->getName() == CD.QualifiedName[NumUnmatched - 1])
408 if (NumUnmatched > 0)
412 return (!CD.RequiredArgs || CD.RequiredArgs ==
getNumArgs()) &&
413 (!CD.RequiredParams || CD.RequiredParams ==
parameters().size());
454 Out <<
"Unknown call (type " <<
getKind() <<
")";
458 return isa<CallExpr>(S) || isa<ObjCMessageExpr>(S)
459 || isa<CXXConstructExpr>(S)
460 || isa<CXXNewExpr>(S);
465 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
466 return FD->getReturnType();
467 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
468 return MD->getReturnType();
469 if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
481 Ty = FT->getReturnType();
489 llvm_unreachable(
"unknown callable kind");
495 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
496 return FD->isVariadic();
497 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
498 return MD->isVariadic();
499 if (
const auto *BD = dyn_cast<BlockDecl>(D))
500 return BD->isVariadic();
502 llvm_unreachable(
"unknown callable kind");
510 MemRegionManager &MRMgr = SVB.getRegionManager();
514 unsigned NumArgs = Call.getNumArgs();
516 ArrayRef<ParmVarDecl*>::iterator I = parameters.begin(), E = parameters.end();
517 for (; I != E && Idx < NumArgs; ++I, ++Idx) {
519 assert(ParamDecl &&
"Formal parameter has no decl?");
523 if (Call.isArgumentConstructedDirectly(Call.getASTArgumentIndex(Idx)))
529 SVal ArgVal = Call.getArgSVal(Idx);
530 if (!ArgVal.isUnknown()) {
531 Loc ParamLoc = SVB.makeLoc(MRMgr.getVarRegion(ParamDecl, CalleeCtx));
532 Bindings.push_back(std::make_pair(ParamLoc, ArgVal));
555 getManager()->getContext(FD);
556 bool IsAutosynthesized;
559 if (IsAutosynthesized)
560 llvm::dbgs() <<
"Using autosynthesized body for " << FD->
getName()
572 if (!Opts.IsNaiveCTUEnabled)
579 Opts.DisplayCTUProgress);
581 if (!CTUDeclOrError) {
582 handleAllErrors(CTUDeclOrError.takeError(),
595 const auto *D = cast<FunctionDecl>(CalleeCtx->
getDecl());
619 if (II->
isStr(
"pthread_setspecific"))
624 if (II->
isStr(
"xpc_connection_set_context"))
628 if (II->
isStr(
"funopen"))
633 if (II->
isStr(
"__cxa_demangle"))
636 StringRef FName = II->
getName();
640 if (FName.endswith(
"NoCopy"))
645 if (FName.startswith(
"NS") && (FName.find(
"Insert") != StringRef::npos))
650 if (FName.startswith(
"CF") || FName.startswith(
"CG")) {
651 return StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
652 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
653 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
654 StrInStrNoCase(FName,
"WithData") != StringRef::npos ||
655 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
656 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos;
679 return getSVal(CE->getCallee()).getAsFunctionDecl();
683 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
684 SVal ThisVal = getCXXThisVal();
685 Values.push_back(ThisVal);
688 if (
const auto *D = cast_or_null<CXXMethodDecl>(
getDecl())) {
700 assert(ParentRecord);
704 const MemRegion *ThisRegion = ThisVal.getAsRegion();
708 ETraits->setTrait(ThisRegion->getBaseRegion(),
714 const Expr *
Base = getCXXThisExpr();
720 assert(ThisVal.isUnknownOrUndef() || ThisVal.getAs<Loc>());
731 const auto *MD = cast<CXXMethodDecl>(D);
732 if (!MD->isVirtual())
736 const MemRegion *R = getCXXThisVal().getAsRegion();
742 if (!DynType.isValid())
747 assert(!RegionType.
isNull() &&
"DynamicTypeInfo should always be a pointer.");
750 if (!RD || !RD->hasDefinition())
754 const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD,
true);
760 assert(!RD->isDerivedFrom(MD->getParent()) &&
"Couldn't find known method");
774 if (!Result->
hasBody(Definition)) {
775 if (!DynType.canBeASubClass())
783 if (DynType.canBeASubClass())
784 return RuntimeDefinition(Definition, R->StripCasts());
785 return RuntimeDefinition(Definition,
nullptr);
794 SVal ThisVal = getCXXThisVal();
795 if (!ThisVal.isUnknown()) {
796 ProgramStateManager &StateMgr =
getState()->getStateManager();
797 SValBuilder &SVB = StateMgr.getSValBuilder();
799 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
800 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
811 ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, Failed);
819 ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
823 if (!ThisVal.isUnknown())
824 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
837 if (
const auto *ME = dyn_cast<MemberExpr>(
getOriginExpr()->getCallee()))
838 if (ME->hasQualifier())
852 return dyn_cast_or_null<BlockDataRegion>(DataReg);
863 RegionAndSymbolInvalidationTraits *ETraits)
const {
865 if (
const MemRegion *R = getBlockRegion())
866 Values.push_back(loc::MemRegionVal(R));
871 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
873 if (isConversionFromLambda()) {
874 auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
875 Params = LambdaOperatorDecl->parameters();
880 const VarRegion *CapturedLambdaRegion = getRegionStoringCapturedLambda();
881 SVal ThisVal = loc::MemRegionVal(CapturedLambdaRegion);
882 Loc ThisLoc = SVB.getCXXThis(LambdaOperatorDecl, CalleeCtx);
883 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
894 return loc::MemRegionVal(static_cast<const MemRegion *>(
Data));
899 RegionAndSymbolInvalidationTraits *ETraits)
const {
901 loc::MemRegionVal MV(static_cast<const MemRegion *>(
Data));
902 if (
SymbolRef Sym = MV.getAsSymbol(
true))
903 ETraits->setTrait(Sym,
905 Values.push_back(MV);
914 SVal ThisVal = getCXXThisVal();
915 if (!ThisVal.isUnknown()) {
916 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
917 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
918 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
919 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
925 return loc::MemRegionVal(DtorDataTy::getFromOpaqueValue(
Data).getPointer());
932 if (isBaseDestructor())
946 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
952 if (
const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
953 SVal IvarLVal =
getState()->getLValue(PropIvar, getReceiverSVal());
954 if (
const MemRegion *IvarRegion = IvarLVal.getAsRegion()) {
961 Values.push_back(IvarLVal);
967 Values.push_back(getReceiverSVal());
980 if (!isInstanceMessage())
989 SVal SelfVal = getSelfSVal();
990 assert(SelfVal.isValid() &&
"Calling super but not in ObjC method");
999 if (!isInstanceMessage())
1004 return (RecVal == getSelfSVal());
1008 switch (getMessageKind()) {
1013 return getContainingPseudoObjectExpr()->getSourceRange();
1015 llvm_unreachable(
"unknown message kind");
1020 const PseudoObjectExpr *ObjCMethodCall::getContainingPseudoObjectExpr()
const {
1021 assert(
Data &&
"Lazy lookup not yet performed.");
1022 assert(getMessageKind() !=
OCM_Message &&
"Explicit message send.");
1023 return ObjCMessageDataTy::getFromOpaqueValue(
Data).getPointer();
1032 if (
const auto *BO = dyn_cast<BinaryOperator>(Syntactic))
1033 Syntactic = BO->getLHS();
1045 if (
const auto *POE = dyn_cast_or_null<PseudoObjectExpr>(S)) {
1050 case Stmt::ObjCPropertyRefExprClass:
1053 case Stmt::ObjCSubscriptRefExprClass:
1065 assert(getMessageKind() == K);
1077 if (!Info.getPointer())
1086 assert(POE &&
"Property access without PseudoObjectExpr?");
1089 auto *RefExpr = cast<ObjCPropertyRefExpr>(Syntactic);
1091 if (RefExpr->isExplicitProperty())
1092 return RefExpr->getExplicitProperty();
1107 AnalysisManager &AMgr =
1108 getState()->getStateManager().getOwningEngine().getAnalysisManager();
1114 if (InterfLoc.
isValid() && AMgr.isInCodeFile(InterfLoc))
1155 llvm_unreachable(
"The while loop should always terminate.");
1166 MD = cast<ObjCMethodDecl>(I);
1178 if (!InstRecIg || !InstRecIg->getFoundDecl() ||
1179 !InstRecIg->getFoundDecl()->getName().equals(
"self"))
1198 bool CanBeSubClassed =
false;
1200 const MemRegion *Receiver =
nullptr;
1202 if (!SupersType.
isNull()) {
1206 ReceiverT = cast<ObjCObjectPointerType>(SupersType);
1208 Receiver = getReceiverSVal().getAsRegion();
1213 if (!DTI.isValid()) {
1214 assert(isa<AllocaRegion>(Receiver) &&
1215 "Unhandled untyped region class!");
1220 CanBeSubClassed = DTI.canBeASubClass();
1223 if (ReceiverT && CanBeSubClassed)
1225 if (!canBeOverridenInSubclass(IDecl, Sel))
1226 CanBeSubClassed =
false;
1232 if (
auto *PT = dyn_cast_or_null<ObjCObjectPointerType>(ReceiverT)) {
1234 if (PT->getObjectType()->isObjCClass() &&
1235 Receiver == getSelfSVal().getAsRegion())
1271 using PrivateMethodKey = std::pair<const ObjCInterfaceDecl *, Selector>;
1272 using PrivateMethodCache =
1273 llvm::DenseMap<PrivateMethodKey, Optional<const ObjCMethodDecl *>>;
1275 static PrivateMethodCache PMC;
1279 if (!Val.hasValue()) {
1280 Val = IDecl->lookupPrivateMethod(Sel);
1286 if (CompileTimeMD->isPropertyAccessor()) {
1287 if (!CompileTimeMD->getSelfDecl() &&
1288 isa<ObjCCategoryDecl>(CompileTimeMD->getDeclContext())) {
1299 auto *
ID = CompileTimeMD->getClassInterface();
1300 for (
auto *CatDecl :
ID->visible_extensions()) {
1301 Val = CatDecl->getMethod(Sel,
1302 CompileTimeMD->isInstanceMethod());
1308 Val = IDecl->lookupInstanceMethod(Sel);
1315 if (CanBeSubClassed)
1316 return RuntimeDefinition(MD, Receiver);
1318 return RuntimeDefinition(MD,
nullptr);
1326 return RuntimeDefinition(IDecl->lookupPrivateClassMethod(Sel));
1347 const auto *D = cast<ObjCMethodDecl>(CalleeCtx->
getDecl());
1348 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
1352 SVal SelfVal = getReceiverSVal();
1353 if (!SelfVal.isUnknown()) {
1355 MemRegionManager &MRMgr = SVB.getRegionManager();
1356 Loc SelfLoc = SVB.makeLoc(MRMgr.getVarRegion(SelfD, CalleeCtx));
1357 Bindings.push_back(std::make_pair(SelfLoc, SelfVal));
1364 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
1365 return create<CXXMemberCall>(MCE, State, LCtx);
1367 if (
const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
1368 const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
1369 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
1370 if (MD->isInstance())
1371 return create<CXXMemberOperatorCall>(OpCE, State, LCtx);
1374 return create<BlockCall>(CE, State, LCtx);
1379 return create<SimpleFunctionCall>(CE, State, LCtx);
1387 assert(CallerCtx &&
"This should not be used for top-level stack frames");
1392 if (CallEventRef<> Out = getCall(CallSite, State, CallerCtx))
1396 assert(isa<CXXConstructExpr>(CallSite) &&
1397 "This is not an inlineable statement");
1399 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1400 const auto *Ctor = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
1401 Loc ThisPtr = SVB.getCXXThis(Ctor, CalleeCtx);
1402 SVal ThisVal = State->getSVal(ThisPtr);
1404 return getCXXConstructorCall(cast<CXXConstructExpr>(CallSite),
1405 ThisVal.getAsRegion(), State, CallerCtx);
1413 "All other CFG elements should have exprs");
1415 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1416 const auto *Dtor = cast<CXXDestructorDecl>(CalleeCtx->
getDecl());
1417 Loc ThisPtr = SVB.getCXXThis(Dtor, CalleeCtx);
1418 SVal ThisVal = State->getSVal(ThisPtr);
1420 const Stmt *Trigger;
1422 Trigger = AutoDtor->getTriggerStmt();
1424 Trigger = DeleteDtor->getDeleteExpr();
1426 Trigger = Dtor->getBody();
1428 return getCXXDestructorCall(Dtor, Trigger, ThisVal.getAsRegion(),
1435 if (
const auto *CE = dyn_cast<CallExpr>(S)) {
1436 return getSimpleCall(CE, State, LC);
1437 }
else if (
const auto *
NE = dyn_cast<CXXNewExpr>(S)) {
1438 return getCXXAllocatorCall(
NE, State, LC);
1439 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(S)) {
1440 return getObjCMethodCall(ME, State, LC);
Suppress pointer-escaping of a region.
The receiver is the instance of the superclass object.
Defines the clang::ASTContext interface.
SVal getSelfSVal() const
Return the value of 'self' if available.
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Represents a function declaration or definition.
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
bool isBlockPointerType() const
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
Selector getSelector() const
ObjCInterfaceDecl * getClassInterface()
Stmt * getBody() const
Get the body of the Declaration.
CFGStmtMap * getCFGStmtMap()
static const Expr * getSyntacticFromForPseudoObjectExpr(const PseudoObjectExpr *POE)
Stmt - This represents one statement.
Information about invalidation for a particular region/symbol.
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool isCallToSelfClass(const ObjCMessageExpr *ME)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
C Language Family Type Representation.
Defines the SourceManager interface.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
AnalysisDeclContext * getCalleeAnalysisDeclContext() const
Returns AnalysisDeclContext for the callee stack frame.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
Decl - This represents one declaration (or definition), e.g.
const RecordType * getAsStructureType() const
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
StringRef getFunctionName() const
Get the name of the function that this object matches.
Represents C++ object destructor generated from a call to delete.
SourceRange getSourceRange() const override
Represents a program point just before an implicit call event.
A container of type source information.
const StackFrameContext * getCalleeStackFrame(unsigned BlockCount) const
Returns the callee stack frame.
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const LocationContext *LCtx)
virtual RuntimeDefinition getRuntimeDefinition() const =0
Returns the definition of the function or method that will be called.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Expr * ignoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point. ...
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
Represents a variable declaration or definition.
const T * getAs() const
Member-template getAs<specific type>'.
void setTrait(SymbolRef Sym, InvalidationKinds IK)
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
ObjCMethodDecl - Represents an instance or class method declaration.
static bool isVoidPointerToNonConst(QualType T)
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
const StackFrameContext * getStackFrame(AnalysisDeclContext *Ctx, const LocationContext *Parent, const Stmt *S, const CFGBlock *Blk, unsigned BlockCount, unsigned Idx)
One of these records is kept for each identifier that is lexed.
RuntimeDefinition getRuntimeDefinition() const override
const SymExpr * SymbolRef
param_type_iterator param_type_end() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
field_range fields() const
AnalysisDeclContext contains the context data for the function or method under analysis.
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
bool isReferenceType() const
virtual const Expr * getArgExpr(unsigned Index) const
Returns the expression associated with a given argument.
bool isObjCSelType() const
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ArrayRef< ParmVarDecl * > parameters() const
static void addParameterValuesToBindings(const StackFrameContext *CalleeCtx, CallEvent::BindingsTy &Bindings, SValBuilder &SVB, const CallEvent &Call, ArrayRef< ParmVarDecl *> parameters)
This class represents a description of a function call using the number of arguments and the name of ...
Represents any expression that calls an Objective-C method.
virtual Kind getKind() const =0
Returns the kind of call this is.
const ImplicitParamDecl * getSelfDecl() const
bool hasNonZeroCallbackArg() const
Returns true if any of the arguments appear to represent callbacks.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
static void findPtrToConstParams(llvm::SmallSet< unsigned, 4 > &PreserveArgs, const CallEvent &Call)
const clang::PrintingPolicy & getPrintingPolicy() const
const LocationContext * getParent() const
static bool isPointerToConst(QualType Ty)
Returns true if a type is a pointer-to-const or reference-to-const with no further indirection...
static const ObjCMethodDecl * findDefiningRedecl(const ObjCMethodDecl *MD)
SVal getReturnValue() const
Returns the return value of the call.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
param_type_iterator param_type_begin() const
Returns an iterator over the types of the call's formal parameters.
Represents an ObjC class declaration.
static bool isVariadic(const Decl *D)
Returns true if the given decl is known to be variadic.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
virtual ArrayRef< ParmVarDecl * > parameters() const =0
Return call's formal parameters.
const CFGBlock * getCallSiteBlock() const
SmallVectorImpl< FrameBindingTy > BindingsTy
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
ObjCMessageKind
Represents the ways an Objective-C message send can occur.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const Stmt * getCallSite() const
ArrayRef< ParmVarDecl * > parameters() const override
Represents a single basic block in a source-level CFG.
bool argumentsMayEscape() const override
ArrayRef< ParmVarDecl * > parameters() const override
AnalysisDeclContext * getContext(const Decl *D)
const LocationContext * getLocationContext() const
The context in which the call is being evaluated.
static bool isCallback(QualType T)
Represents a block literal declaration, which is like an unnamed FunctionDecl.
This represents one expression.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
CallEventRef getCaller(const StackFrameContext *CalleeCtx, ProgramStateRef State)
Gets an outside caller given a callee context.
static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name=StringRef())
Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc.
llvm::mapped_iterator< ArrayRef< ParmVarDecl * >::iterator, GetTypeFn > param_type_iterator
bool isInSystemHeader() const
Returns true if the callee is known to be from a system header.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
DeclContext * getDeclContext()
ObjCInterfaceDecl * getSuperClass() const
virtual SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
virtual cross_tu::CrossTranslationUnitContext * getCrossTranslationUnitContext()=0
QualType getRecordType(const RecordDecl *Decl) const
unsigned getNumArgs() const
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Represents C++ object destructor implicitly generated for base object in destructor.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
virtual bool argumentsMayEscape() const
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
RuntimeDefinition getRuntimeDefinition() const override
bool isConstQualified() const
Determine whether this type is const-qualified.
virtual SourceRange getSourceRange() const
Returns a source range for the entire call, suitable for outputting in diagnostics.
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 ImplicitParamDecl * getSelfDecl() const
Return the ImplicitParamDecl* associated with 'self' if this AnalysisDeclContext wraps an ObjCMethodD...
Defines the runtime definition of the called function.
QualType getCanonicalType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Encodes a location in the source.
const FunctionDecl * getDecl() const override
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity...
const MemRegion * getAsRegion() const
bool isArgumentConstructedDirectly(unsigned Index) const
Returns true if on the current path, the argument was constructed by calling a C++ constructor over i...
Represents a static or instance method of a struct/union/class.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
const StackFrameContext * getStackFrame() const
const Decl * getDecl() const
bool isAnyPointerType() const
virtual Optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const
Some calls have parameter numbering mismatched from argument numbering.
Represents one property declaration in an Objective-C interface.
AnalyzerOptions & options
RuntimeDefinition getRuntimeDefinition() const override
const ObjCMethodDecl * getMethodDecl() const
Tells that a region's contents is not changed.
virtual void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const
Used to specify non-argument regions that will be invalidated as a result of this call...
Optional< T > getAs() const
Convert to the specified CFGElement type, returning None if this CFGElement is not of the desired typ...
Defines various enumerations that describe declaration and type specifiers.
CallEventRef getCall(const Stmt *S, ProgramStateRef State, const LocationContext *LC)
Gets a call event for a function call, Objective-C method call, or a 'new' call.
StringRef getName() const
Return the actual identifier string.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
Dataflow Directional Tag Classes.
virtual bool canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, Selector Sel) const
Check if the selector may have multiple definitions (may have overrides).
const BlockDataRegion * getBlockRegion() const
Returns the region associated with this instance of the block.
AnalysisDeclContextManager * getManager() const
Return the AnalysisDeclContextManager (if any) that created this AnalysisDeclContext.
bool isValid() const
Return true if this is a valid SourceLocation object.
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a program point just after an implicit call event.
RuntimeDefinition getRuntimeDefinition() const override
bool NE(InterpState &S, CodePtr OpPC)
QualType getSuperType() const
Retrieve the type referred to by 'super'.
StmtClass getStmtClass() const
bool hasVoidPointerToNonConstArg() const
Returns true if any of the arguments is void*.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
Describes a C standard function that is sometimes implemented as a macro that expands to a compiler b...
bool mayHaveOtherDefinitions()
Check if the definition we have is precise.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
This class is used for tools that requires cross translation unit capability.
const Decl * getDecl() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Represents a pointer to an Objective C object.
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
unsigned getIndex() const
bool hasBody() const override
Determine whether this method has a body.
static QualType getDeclaredResultType(const Decl *D)
Returns the result type of a function or method declaration.
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
const StackFrameContext * getStackFrame() const
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc.
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, its categories, and its super classes (using a linear search).
Stores options for the analyzer from the command line.
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.
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasNonNullArgumentsWithType(bool(*Condition)(QualType)) const
Returns true if the type of any of the non-null arguments satisfies the condition.
const ProgramStateRef & getState() const
The state in which the call is being evaluated.
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
SVal getCXXThisVal() const override
Returns the value of the implicit 'this' object.
Represents C++ object destructor implicitly generated by compiler on various occasions.
bool isCalled(const CallDescription &CD) const
Returns true if the CallEvent is a call to a function that matches the CallDescription.
const ParentMap & getParentMap() const
ObjCIvarDecl - Represents an ObjC instance variable.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
Represents a top-level expression in a basic block.
llvm::PointerIntPair< const PseudoObjectExpr *, 2 > ObjCMessageDataTy
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
void emitCrossTUDiagnostics(const IndexError &IE)
Emit diagnostics for the user for potential configuration errors.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
const ObjCPropertyDecl * getAccessedProperty() const
Stmt * getParentIgnoreParenCasts(Stmt *) const
ProgramStateRef invalidateRegions(unsigned BlockCount, ProgramStateRef Orig=nullptr) const
Returns a new state with all argument regions invalidated.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
ArrayRef< ParmVarDecl * > parameters() const
bool isPointerType() const
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
const VarRegion * getParameterLocation(unsigned Index, unsigned BlockCount) const
Returns memory location for a parameter variable within the callee stack frame.
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
bool isPropertyAccessor() const
AnalysisDeclContext * getAnalysisDeclContext() const
SourceLocation getEndOfDefinitionLoc() const
bool isFunctionPointerType() const
The receiver is a superclass.
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
SourceLocation getBegin() const
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
SourceLocation getLocation() const
ArrayRef< ParmVarDecl * > parameters() const
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
ArrayRef< SVal > ValueList
virtual AnalysisManager & getAnalysisManager()=0