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());
214 unsigned Idx = 0, Sz = B->
size();
215 for (; Idx < Sz; ++Idx)
216 if (
auto StmtElem = (*B)[Idx].getAs<CFGStmt>())
217 if (StmtElem->getStmt() == E)
238 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
239 PVD = FD->parameters()[Index];
240 else if (
const auto *BD = dyn_cast<BlockDecl>(D))
241 PVD = BD->parameters()[Index];
242 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
243 PVD = MD->parameters()[Index];
244 else if (
const auto *CD = dyn_cast<CXXConstructorDecl>(D))
245 PVD = CD->parameters()[Index];
246 assert(PVD &&
"Unexpected Decl kind!");
249 State->getStateManager().getRegionManager().getVarRegion(PVD, SFC);
278 E = Call.param_type_end();
279 I != E; ++I, ++Idx) {
281 PreserveArgs.insert(Idx);
291 if (callee->hasAttr<PureAttr>() || callee->hasAttr<ConstAttr>())
300 llvm::SmallSet<unsigned, 4> PreserveArgs;
304 for (
unsigned Idx = 0, Count =
getNumArgs(); Idx != Count; ++Idx) {
307 if (PreserveArgs.count(Idx))
309 ETraits.
setTrait(MR->getBaseRegion(),
313 ValuesToInvalidate.push_back(
getArgSVal(Idx));
333 return Result->invalidateRegions(ValuesToInvalidate,
getOriginExpr(),
336 nullptr,
this, &ETraits);
348 assert(D &&
"Cannot get a program point without a statement or decl");
360 if (!CD.IsLookupDone) {
361 CD.IsLookupDone =
true;
362 CD.II = &
getState()->getStateManager().getContext().Idents.get(
366 if (!II || II != CD.II)
372 if (CD.QualifiedName.size() > 1 && D) {
375 size_t NumUnmatched = CD.QualifiedName.size() - 1;
376 for (; Ctx && isa<NamedDecl>(Ctx); Ctx = Ctx->
getParent()) {
377 if (NumUnmatched == 0)
380 if (
const auto *ND = dyn_cast<NamespaceDecl>(Ctx)) {
381 if (ND->getName() == CD.QualifiedName[NumUnmatched - 1])
386 if (
const auto *RD = dyn_cast<RecordDecl>(Ctx)) {
387 if (RD->getName() == CD.QualifiedName[NumUnmatched - 1])
393 if (NumUnmatched > 0)
439 Out <<
"Unknown call (type " <<
getKind() <<
")";
443 return isa<CallExpr>(S) || isa<ObjCMessageExpr>(S)
444 || isa<CXXConstructExpr>(S)
445 || isa<CXXNewExpr>(S);
450 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
451 return FD->getReturnType();
452 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
453 return MD->getReturnType();
454 if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
466 Ty = FT->getReturnType();
474 llvm_unreachable(
"unknown callable kind");
480 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
481 return FD->isVariadic();
482 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
483 return MD->isVariadic();
484 if (
const auto *BD = dyn_cast<BlockDecl>(D))
485 return BD->isVariadic();
487 llvm_unreachable(
"unknown callable kind");
495 MemRegionManager &MRMgr = SVB.getRegionManager();
499 unsigned NumArgs = Call.getNumArgs();
502 for (; I != E && Idx < NumArgs; ++I, ++Idx) {
504 assert(ParamDecl &&
"Formal parameter has no decl?");
508 if (Call.isArgumentConstructedDirectly(Idx))
514 SVal ArgVal = Call.getArgSVal(Idx);
515 if (!ArgVal.isUnknown()) {
516 Loc ParamLoc = SVB.makeLoc(MRMgr.getVarRegion(ParamDecl, CalleeCtx));
517 Bindings.push_back(std::make_pair(ParamLoc, ArgVal));
540 getManager()->getContext(FD);
541 bool IsAutosynthesized;
544 if (IsAutosynthesized)
545 llvm::dbgs() <<
"Using autosynthesized body for " << FD->
getName()
557 if (!Opts.IsNaiveCTUEnabled)
564 Opts.DisplayCTUProgress);
566 if (!CTUDeclOrError) {
567 handleAllErrors(CTUDeclOrError.takeError(),
580 const auto *D = cast<FunctionDecl>(CalleeCtx->
getDecl());
604 if (II->
isStr(
"pthread_setspecific"))
609 if (II->
isStr(
"xpc_connection_set_context"))
613 if (II->
isStr(
"funopen"))
618 if (II->
isStr(
"__cxa_demangle"))
621 StringRef FName = II->
getName();
625 if (FName.endswith(
"NoCopy"))
630 if (FName.startswith(
"NS") && (FName.find(
"Insert") != StringRef::npos))
635 if (FName.startswith(
"CF") || FName.startswith(
"CG")) {
636 return StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
637 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
638 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
639 StrInStrNoCase(FName,
"WithData") != StringRef::npos ||
640 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
641 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos;
664 return getSVal(CE->getCallee()).getAsFunctionDecl();
668 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
669 SVal ThisVal = getCXXThisVal();
670 Values.push_back(ThisVal);
673 if (
const auto *D = cast_or_null<CXXMethodDecl>(
getDecl())) {
685 assert(ParentRecord);
689 const MemRegion *ThisRegion = ThisVal.getAsRegion();
693 ETraits->setTrait(ThisRegion->getBaseRegion(),
699 const Expr *
Base = getCXXThisExpr();
705 assert(ThisVal.isUnknownOrUndef() || ThisVal.getAs<Loc>());
716 const auto *MD = cast<CXXMethodDecl>(D);
717 if (!MD->isVirtual())
721 const MemRegion *R = getCXXThisVal().getAsRegion();
727 if (!DynType.isValid())
732 assert(!RegionType.
isNull() &&
"DynamicTypeInfo should always be a pointer.");
735 if (!RD || !RD->hasDefinition())
739 const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD,
true);
745 assert(!RD->isDerivedFrom(MD->getParent()) &&
"Couldn't find known method");
759 if (!Result->
hasBody(Definition))
765 if (DynType.canBeASubClass())
766 return RuntimeDefinition(Definition, R->StripCasts());
767 return RuntimeDefinition(Definition,
nullptr);
776 SVal ThisVal = getCXXThisVal();
777 if (!ThisVal.isUnknown()) {
778 ProgramStateManager &StateMgr =
getState()->getStateManager();
779 SValBuilder &SVB = StateMgr.getSValBuilder();
781 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
782 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
793 ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, Failed);
801 ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
805 if (!ThisVal.isUnknown())
806 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
819 if (
const auto *ME = dyn_cast<MemberExpr>(
getOriginExpr()->getCallee()))
820 if (ME->hasQualifier())
834 return dyn_cast_or_null<BlockDataRegion>(DataReg);
845 RegionAndSymbolInvalidationTraits *ETraits)
const {
847 if (
const MemRegion *R = getBlockRegion())
848 Values.push_back(loc::MemRegionVal(R));
853 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
855 if (isConversionFromLambda()) {
856 auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
857 Params = LambdaOperatorDecl->parameters();
862 const VarRegion *CapturedLambdaRegion = getRegionStoringCapturedLambda();
863 SVal ThisVal = loc::MemRegionVal(CapturedLambdaRegion);
864 Loc ThisLoc = SVB.getCXXThis(LambdaOperatorDecl, CalleeCtx);
865 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
876 return loc::MemRegionVal(static_cast<const MemRegion *>(
Data));
881 RegionAndSymbolInvalidationTraits *ETraits)
const {
883 loc::MemRegionVal MV(static_cast<const MemRegion *>(
Data));
884 if (
SymbolRef Sym = MV.getAsSymbol(
true))
885 ETraits->setTrait(Sym,
887 Values.push_back(MV);
896 SVal ThisVal = getCXXThisVal();
897 if (!ThisVal.isUnknown()) {
898 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
899 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
900 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
901 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
907 return loc::MemRegionVal(DtorDataTy::getFromOpaqueValue(
Data).getPointer());
914 if (isBaseDestructor())
928 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
934 if (
const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
935 SVal IvarLVal =
getState()->getLValue(PropIvar, getReceiverSVal());
936 if (
const MemRegion *IvarRegion = IvarLVal.getAsRegion()) {
943 Values.push_back(IvarLVal);
949 Values.push_back(getReceiverSVal());
962 if (!isInstanceMessage())
971 SVal SelfVal = getSelfSVal();
972 assert(SelfVal.isValid() &&
"Calling super but not in ObjC method");
981 if (!isInstanceMessage())
986 return (RecVal == getSelfSVal());
990 switch (getMessageKind()) {
995 return getContainingPseudoObjectExpr()->getSourceRange();
997 llvm_unreachable(
"unknown message kind");
1002 const PseudoObjectExpr *ObjCMethodCall::getContainingPseudoObjectExpr()
const {
1003 assert(
Data &&
"Lazy lookup not yet performed.");
1004 assert(getMessageKind() !=
OCM_Message &&
"Explicit message send.");
1005 return ObjCMessageDataTy::getFromOpaqueValue(
Data).getPointer();
1014 if (
const auto *BO = dyn_cast<BinaryOperator>(Syntactic))
1015 Syntactic = BO->getLHS();
1027 if (
const auto *POE = dyn_cast_or_null<PseudoObjectExpr>(S)) {
1032 case Stmt::ObjCPropertyRefExprClass:
1035 case Stmt::ObjCSubscriptRefExprClass:
1047 assert(getMessageKind() == K);
1059 if (!Info.getPointer())
1068 assert(POE &&
"Property access without PseudoObjectExpr?");
1071 auto *RefExpr = cast<ObjCPropertyRefExpr>(Syntactic);
1073 if (RefExpr->isExplicitProperty())
1074 return RefExpr->getExplicitProperty();
1089 AnalysisManager &AMgr =
1090 getState()->getStateManager().getOwningEngine().getAnalysisManager();
1096 if (InterfLoc.
isValid() && AMgr.isInCodeFile(InterfLoc))
1137 llvm_unreachable(
"The while loop should always terminate.");
1148 MD = cast<ObjCMethodDecl>(I);
1160 if (!InstRecIg || !InstRecIg->getFoundDecl() ||
1161 !InstRecIg->getFoundDecl()->getName().equals(
"self"))
1180 bool CanBeSubClassed =
false;
1182 const MemRegion *Receiver =
nullptr;
1184 if (!SupersType.
isNull()) {
1188 ReceiverT = cast<ObjCObjectPointerType>(SupersType);
1190 Receiver = getReceiverSVal().getAsRegion();
1195 if (!DTI.isValid()) {
1196 assert(isa<AllocaRegion>(Receiver) &&
1197 "Unhandled untyped region class!");
1202 CanBeSubClassed = DTI.canBeASubClass();
1205 if (ReceiverT && CanBeSubClassed)
1207 if (!canBeOverridenInSubclass(IDecl, Sel))
1208 CanBeSubClassed =
false;
1214 if (
auto *PT = dyn_cast_or_null<ObjCObjectPointerType>(ReceiverT)) {
1216 if (PT->getObjectType()->isObjCClass() &&
1217 Receiver == getSelfSVal().getAsRegion())
1253 using PrivateMethodKey = std::pair<const ObjCInterfaceDecl *, Selector>;
1254 using PrivateMethodCache =
1255 llvm::DenseMap<PrivateMethodKey, Optional<const ObjCMethodDecl *>>;
1257 static PrivateMethodCache PMC;
1261 if (!Val.hasValue()) {
1262 Val = IDecl->lookupPrivateMethod(Sel);
1268 if (CompileTimeMD->isPropertyAccessor()) {
1269 if (!CompileTimeMD->getSelfDecl() &&
1270 isa<ObjCCategoryDecl>(CompileTimeMD->getDeclContext())) {
1281 auto *
ID = CompileTimeMD->getClassInterface();
1282 for (
auto *CatDecl :
ID->visible_extensions()) {
1283 Val = CatDecl->getMethod(Sel,
1284 CompileTimeMD->isInstanceMethod());
1290 Val = IDecl->lookupInstanceMethod(Sel);
1295 if (CanBeSubClassed)
1296 return RuntimeDefinition(MD, Receiver);
1298 return RuntimeDefinition(MD,
nullptr);
1306 return RuntimeDefinition(IDecl->lookupPrivateClassMethod(Sel));
1327 const auto *D = cast<ObjCMethodDecl>(CalleeCtx->
getDecl());
1328 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
1332 SVal SelfVal = getReceiverSVal();
1333 if (!SelfVal.isUnknown()) {
1335 MemRegionManager &MRMgr = SVB.getRegionManager();
1336 Loc SelfLoc = SVB.makeLoc(MRMgr.getVarRegion(SelfD, CalleeCtx));
1337 Bindings.push_back(std::make_pair(SelfLoc, SelfVal));
1344 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
1345 return create<CXXMemberCall>(MCE, State, LCtx);
1347 if (
const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
1348 const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
1349 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
1350 if (MD->isInstance())
1351 return create<CXXMemberOperatorCall>(OpCE, State, LCtx);
1354 return create<BlockCall>(CE, State, LCtx);
1359 return create<SimpleFunctionCall>(CE, State, LCtx);
1367 assert(CallerCtx &&
"This should not be used for top-level stack frames");
1372 if (CallEventRef<> Out = getCall(CallSite, State, CallerCtx))
1376 assert(isa<CXXConstructExpr>(CallSite) &&
1377 "This is not an inlineable statement");
1379 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1380 const auto *Ctor = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
1381 Loc ThisPtr = SVB.getCXXThis(Ctor, CalleeCtx);
1382 SVal ThisVal = State->getSVal(ThisPtr);
1384 return getCXXConstructorCall(cast<CXXConstructExpr>(CallSite),
1385 ThisVal.getAsRegion(), State, CallerCtx);
1393 "All other CFG elements should have exprs");
1395 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1396 const auto *Dtor = cast<CXXDestructorDecl>(CalleeCtx->
getDecl());
1397 Loc ThisPtr = SVB.getCXXThis(Dtor, CalleeCtx);
1398 SVal ThisVal = State->getSVal(ThisPtr);
1400 const Stmt *Trigger;
1402 Trigger = AutoDtor->getTriggerStmt();
1404 Trigger = DeleteDtor->getDeleteExpr();
1406 Trigger = Dtor->getBody();
1408 return getCXXDestructorCall(Dtor, Trigger, ThisVal.getAsRegion(),
1415 if (
const auto *CE = dyn_cast<CallExpr>(S)) {
1416 return getSimpleCall(CE, State, LC);
1417 }
else if (
const auto *NE = dyn_cast<CXXNewExpr>(S)) {
1418 return getCXXAllocatorCall(NE, State, LC);
1419 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(S)) {
1420 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.
const VarRegion * getParameterLocation(unsigned Index) const
Returns memory location for a parameter variable within the callee stack frame.
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()
const SymExpr * SymbolRef
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
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.
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
Ignore parentheses and derived-to-base casts.
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.
One of these records is kept for each identifier that is lexed.
RuntimeDefinition getRuntimeDefinition() const override
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)
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.
virtual ArrayRef< ParmVarDecl * > parameters() const =0
Return call's formal parameters.
const CFGBlock * getCallSiteBlock() const
SmallVectorImpl< FrameBindingTy > BindingsTy
const StackFrameContext * getStackFrame(AnalysisDeclContext *Ctx, LocationContext const *Parent, const Stmt *S, const CFGBlock *Blk, unsigned Idx)
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)
Pepresents 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.
StringRef getFunctionName() const
Get the name of the function that this object matches.
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.
ParentMap & getParentMap() const
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.
This class represents a description of a function call using the number of arguments and the name of ...
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...
static const unsigned NoArgRequirement
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.
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg)
Get dynamic type information for a region.
RuntimeDefinition getRuntimeDefinition() const override
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
Returns the parent of this method declaration, which is the class in which this method is defined...
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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.
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 definition from an external AST file and merge it into the original AS...
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.
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.
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
const StackFrameContext * getCalleeStackFrame() const
Returns the callee stack frame.
virtual AnalysisManager & getAnalysisManager()=0