47 #include "llvm/ADT/ArrayRef.h" 48 #include "llvm/ADT/DenseMap.h" 49 #include "llvm/ADT/None.h" 50 #include "llvm/ADT/Optional.h" 51 #include "llvm/ADT/PointerIntPair.h" 52 #include "llvm/ADT/SmallSet.h" 53 #include "llvm/ADT/SmallVector.h" 54 #include "llvm/ADT/StringExtras.h" 55 #include "llvm/ADT/StringRef.h" 56 #include "llvm/Support/Casting.h" 57 #include "llvm/Support/Compiler.h" 58 #include "llvm/Support/Debug.h" 59 #include "llvm/Support/ErrorHandling.h" 60 #include "llvm/Support/raw_ostream.h" 64 #define DEBUG_TYPE "static-analyzer-call-event" 66 using namespace clang;
111 for (
const auto *I : RD->
fields()) {
142 I != E && Idx < NumOfArgs; ++I, ++Idx) {
162 const auto *FD = dyn_cast_or_null<FunctionDecl>(
getDecl());
213 unsigned Idx = 0, Sz = B->
size();
214 for (; Idx < Sz; ++Idx)
215 if (
auto StmtElem = (*B)[Idx].getAs<CFGStmt>())
216 if (StmtElem->getStmt() == E)
237 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
238 PVD = FD->parameters()[Index];
239 else if (
const auto *BD = dyn_cast<BlockDecl>(D))
240 PVD = BD->parameters()[Index];
241 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
242 PVD = MD->parameters()[Index];
243 else if (
const auto *CD = dyn_cast<CXXConstructorDecl>(D))
244 PVD = CD->parameters()[Index];
245 assert(PVD &&
"Unexpected Decl kind!");
248 State->getStateManager().getRegionManager().getVarRegion(PVD, SFC);
277 E = Call.param_type_end();
278 I != E; ++I, ++Idx) {
280 PreserveArgs.insert(Idx);
290 if (callee->hasAttr<PureAttr>() || callee->hasAttr<ConstAttr>())
299 llvm::SmallSet<unsigned, 4> PreserveArgs;
303 for (
unsigned Idx = 0, Count =
getNumArgs(); Idx != Count; ++Idx) {
306 if (PreserveArgs.count(Idx))
308 ETraits.
setTrait(MR->getBaseRegion(),
312 ValuesToInvalidate.push_back(
getArgSVal(Idx));
332 return Result->invalidateRegions(ValuesToInvalidate,
getOriginExpr(),
335 nullptr,
this, &ETraits);
347 assert(D &&
"Cannot get a program point without a statement or decl");
369 (!CD.RequiredArgs || CD.RequiredArgs <=
getNumArgs());
372 if (!CD.IsLookupDone) {
373 CD.IsLookupDone =
true;
374 CD.II = &
getState()->getStateManager().getContext().Idents.get(
383 if (CD.QualifiedName.size() > 1 && FD) {
386 size_t NumUnmatched = CD.QualifiedName.size() - 1;
387 for (; Ctx && isa<NamedDecl>(Ctx); Ctx = Ctx->
getParent()) {
388 if (NumUnmatched == 0)
391 if (
const auto *ND = dyn_cast<NamespaceDecl>(Ctx)) {
392 if (ND->getName() == CD.QualifiedName[NumUnmatched - 1])
397 if (
const auto *RD = dyn_cast<RecordDecl>(Ctx)) {
398 if (RD->getName() == CD.QualifiedName[NumUnmatched - 1])
404 if (NumUnmatched > 0)
408 return (!CD.RequiredArgs || CD.RequiredArgs ==
getNumArgs());
449 Out <<
"Unknown call (type " <<
getKind() <<
")";
453 return isa<CallExpr>(S) || isa<ObjCMessageExpr>(S)
454 || isa<CXXConstructExpr>(S)
455 || isa<CXXNewExpr>(S);
460 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
461 return FD->getReturnType();
462 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
463 return MD->getReturnType();
464 if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
476 Ty = FT->getReturnType();
484 llvm_unreachable(
"unknown callable kind");
490 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
491 return FD->isVariadic();
492 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
493 return MD->isVariadic();
494 if (
const auto *BD = dyn_cast<BlockDecl>(D))
495 return BD->isVariadic();
497 llvm_unreachable(
"unknown callable kind");
505 MemRegionManager &MRMgr = SVB.getRegionManager();
509 unsigned NumArgs = Call.getNumArgs();
511 ArrayRef<ParmVarDecl*>::iterator I = parameters.begin(), E = parameters.end();
512 for (; I != E && Idx < NumArgs; ++I, ++Idx) {
514 assert(ParamDecl &&
"Formal parameter has no decl?");
518 if (Call.isArgumentConstructedDirectly(Idx))
524 SVal ArgVal = Call.getArgSVal(Idx);
525 if (!ArgVal.isUnknown()) {
526 Loc ParamLoc = SVB.makeLoc(MRMgr.getVarRegion(ParamDecl, CalleeCtx));
527 Bindings.push_back(std::make_pair(ParamLoc, ArgVal));
550 getManager()->getContext(FD);
551 bool IsAutosynthesized;
554 if (IsAutosynthesized)
555 llvm::dbgs() <<
"Using autosynthesized body for " << FD->
getName()
567 if (!Opts.IsNaiveCTUEnabled)
574 Opts.DisplayCTUProgress);
576 if (!CTUDeclOrError) {
577 handleAllErrors(CTUDeclOrError.takeError(),
590 const auto *D = cast<FunctionDecl>(CalleeCtx->
getDecl());
614 if (II->
isStr(
"pthread_setspecific"))
619 if (II->
isStr(
"xpc_connection_set_context"))
623 if (II->
isStr(
"funopen"))
628 if (II->
isStr(
"__cxa_demangle"))
631 StringRef FName = II->
getName();
635 if (FName.endswith(
"NoCopy"))
640 if (FName.startswith(
"NS") && (FName.find(
"Insert") != StringRef::npos))
645 if (FName.startswith(
"CF") || FName.startswith(
"CG")) {
646 return StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
647 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
648 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
649 StrInStrNoCase(FName,
"WithData") != StringRef::npos ||
650 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
651 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos;
674 return getSVal(CE->getCallee()).getAsFunctionDecl();
678 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
679 SVal ThisVal = getCXXThisVal();
680 Values.push_back(ThisVal);
683 if (
const auto *D = cast_or_null<CXXMethodDecl>(
getDecl())) {
695 assert(ParentRecord);
699 const MemRegion *ThisRegion = ThisVal.getAsRegion();
703 ETraits->setTrait(ThisRegion->getBaseRegion(),
709 const Expr *
Base = getCXXThisExpr();
715 assert(ThisVal.isUnknownOrUndef() || ThisVal.getAs<Loc>());
726 const auto *MD = cast<CXXMethodDecl>(D);
727 if (!MD->isVirtual())
731 const MemRegion *R = getCXXThisVal().getAsRegion();
737 if (!DynType.isValid())
742 assert(!RegionType.
isNull() &&
"DynamicTypeInfo should always be a pointer.");
745 if (!RD || !RD->hasDefinition())
749 const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD,
true);
755 assert(!RD->isDerivedFrom(MD->getParent()) &&
"Couldn't find known method");
769 if (!Result->
hasBody(Definition)) {
770 if (!DynType.canBeASubClass())
778 if (DynType.canBeASubClass())
779 return RuntimeDefinition(Definition, R->StripCasts());
780 return RuntimeDefinition(Definition,
nullptr);
789 SVal ThisVal = getCXXThisVal();
790 if (!ThisVal.isUnknown()) {
791 ProgramStateManager &StateMgr =
getState()->getStateManager();
792 SValBuilder &SVB = StateMgr.getSValBuilder();
794 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
795 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
806 ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, Failed);
814 ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
818 if (!ThisVal.isUnknown())
819 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
832 if (
const auto *ME = dyn_cast<MemberExpr>(
getOriginExpr()->getCallee()))
833 if (ME->hasQualifier())
847 return dyn_cast_or_null<BlockDataRegion>(DataReg);
858 RegionAndSymbolInvalidationTraits *ETraits)
const {
860 if (
const MemRegion *R = getBlockRegion())
861 Values.push_back(loc::MemRegionVal(R));
866 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
868 if (isConversionFromLambda()) {
869 auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
870 Params = LambdaOperatorDecl->parameters();
875 const VarRegion *CapturedLambdaRegion = getRegionStoringCapturedLambda();
876 SVal ThisVal = loc::MemRegionVal(CapturedLambdaRegion);
877 Loc ThisLoc = SVB.getCXXThis(LambdaOperatorDecl, CalleeCtx);
878 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
889 return loc::MemRegionVal(static_cast<const MemRegion *>(
Data));
894 RegionAndSymbolInvalidationTraits *ETraits)
const {
896 loc::MemRegionVal MV(static_cast<const MemRegion *>(
Data));
897 if (
SymbolRef Sym = MV.getAsSymbol(
true))
898 ETraits->setTrait(Sym,
900 Values.push_back(MV);
909 SVal ThisVal = getCXXThisVal();
910 if (!ThisVal.isUnknown()) {
911 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
912 const auto *MD = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
913 Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
914 Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
920 return loc::MemRegionVal(DtorDataTy::getFromOpaqueValue(
Data).getPointer());
927 if (isBaseDestructor())
941 ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits)
const {
947 if (
const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
948 SVal IvarLVal =
getState()->getLValue(PropIvar, getReceiverSVal());
949 if (
const MemRegion *IvarRegion = IvarLVal.getAsRegion()) {
956 Values.push_back(IvarLVal);
962 Values.push_back(getReceiverSVal());
975 if (!isInstanceMessage())
984 SVal SelfVal = getSelfSVal();
985 assert(SelfVal.isValid() &&
"Calling super but not in ObjC method");
994 if (!isInstanceMessage())
999 return (RecVal == getSelfSVal());
1003 switch (getMessageKind()) {
1008 return getContainingPseudoObjectExpr()->getSourceRange();
1010 llvm_unreachable(
"unknown message kind");
1015 const PseudoObjectExpr *ObjCMethodCall::getContainingPseudoObjectExpr()
const {
1016 assert(
Data &&
"Lazy lookup not yet performed.");
1017 assert(getMessageKind() !=
OCM_Message &&
"Explicit message send.");
1018 return ObjCMessageDataTy::getFromOpaqueValue(
Data).getPointer();
1027 if (
const auto *BO = dyn_cast<BinaryOperator>(Syntactic))
1028 Syntactic = BO->getLHS();
1040 if (
const auto *POE = dyn_cast_or_null<PseudoObjectExpr>(S)) {
1045 case Stmt::ObjCPropertyRefExprClass:
1048 case Stmt::ObjCSubscriptRefExprClass:
1060 assert(getMessageKind() == K);
1072 if (!Info.getPointer())
1081 assert(POE &&
"Property access without PseudoObjectExpr?");
1084 auto *RefExpr = cast<ObjCPropertyRefExpr>(Syntactic);
1086 if (RefExpr->isExplicitProperty())
1087 return RefExpr->getExplicitProperty();
1102 AnalysisManager &AMgr =
1103 getState()->getStateManager().getOwningEngine().getAnalysisManager();
1109 if (InterfLoc.
isValid() && AMgr.isInCodeFile(InterfLoc))
1150 llvm_unreachable(
"The while loop should always terminate.");
1161 MD = cast<ObjCMethodDecl>(I);
1173 if (!InstRecIg || !InstRecIg->getFoundDecl() ||
1174 !InstRecIg->getFoundDecl()->getName().equals(
"self"))
1193 bool CanBeSubClassed =
false;
1195 const MemRegion *Receiver =
nullptr;
1197 if (!SupersType.
isNull()) {
1201 ReceiverT = cast<ObjCObjectPointerType>(SupersType);
1203 Receiver = getReceiverSVal().getAsRegion();
1208 if (!DTI.isValid()) {
1209 assert(isa<AllocaRegion>(Receiver) &&
1210 "Unhandled untyped region class!");
1215 CanBeSubClassed = DTI.canBeASubClass();
1218 if (ReceiverT && CanBeSubClassed)
1220 if (!canBeOverridenInSubclass(IDecl, Sel))
1221 CanBeSubClassed =
false;
1227 if (
auto *PT = dyn_cast_or_null<ObjCObjectPointerType>(ReceiverT)) {
1229 if (PT->getObjectType()->isObjCClass() &&
1230 Receiver == getSelfSVal().getAsRegion())
1266 using PrivateMethodKey = std::pair<const ObjCInterfaceDecl *, Selector>;
1267 using PrivateMethodCache =
1268 llvm::DenseMap<PrivateMethodKey, Optional<const ObjCMethodDecl *>>;
1270 static PrivateMethodCache PMC;
1274 if (!Val.hasValue()) {
1275 Val = IDecl->lookupPrivateMethod(Sel);
1281 if (CompileTimeMD->isPropertyAccessor()) {
1282 if (!CompileTimeMD->getSelfDecl() &&
1283 isa<ObjCCategoryDecl>(CompileTimeMD->getDeclContext())) {
1294 auto *
ID = CompileTimeMD->getClassInterface();
1295 for (
auto *CatDecl :
ID->visible_extensions()) {
1296 Val = CatDecl->getMethod(Sel,
1297 CompileTimeMD->isInstanceMethod());
1303 Val = IDecl->lookupInstanceMethod(Sel);
1308 if (CanBeSubClassed)
1309 return RuntimeDefinition(MD, Receiver);
1311 return RuntimeDefinition(MD,
nullptr);
1319 return RuntimeDefinition(IDecl->lookupPrivateClassMethod(Sel));
1340 const auto *D = cast<ObjCMethodDecl>(CalleeCtx->
getDecl());
1341 SValBuilder &SVB =
getState()->getStateManager().getSValBuilder();
1345 SVal SelfVal = getReceiverSVal();
1346 if (!SelfVal.isUnknown()) {
1348 MemRegionManager &MRMgr = SVB.getRegionManager();
1349 Loc SelfLoc = SVB.makeLoc(MRMgr.getVarRegion(SelfD, CalleeCtx));
1350 Bindings.push_back(std::make_pair(SelfLoc, SelfVal));
1357 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
1358 return create<CXXMemberCall>(MCE, State, LCtx);
1360 if (
const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
1361 const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
1362 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
1363 if (MD->isInstance())
1364 return create<CXXMemberOperatorCall>(OpCE, State, LCtx);
1367 return create<BlockCall>(CE, State, LCtx);
1372 return create<SimpleFunctionCall>(CE, State, LCtx);
1380 assert(CallerCtx &&
"This should not be used for top-level stack frames");
1385 if (CallEventRef<> Out = getCall(CallSite, State, CallerCtx))
1389 assert(isa<CXXConstructExpr>(CallSite) &&
1390 "This is not an inlineable statement");
1392 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1393 const auto *Ctor = cast<CXXMethodDecl>(CalleeCtx->
getDecl());
1394 Loc ThisPtr = SVB.getCXXThis(Ctor, CalleeCtx);
1395 SVal ThisVal = State->getSVal(ThisPtr);
1397 return getCXXConstructorCall(cast<CXXConstructExpr>(CallSite),
1398 ThisVal.getAsRegion(), State, CallerCtx);
1406 "All other CFG elements should have exprs");
1408 SValBuilder &SVB = State->getStateManager().getSValBuilder();
1409 const auto *Dtor = cast<CXXDestructorDecl>(CalleeCtx->
getDecl());
1410 Loc ThisPtr = SVB.getCXXThis(Dtor, CalleeCtx);
1411 SVal ThisVal = State->getSVal(ThisPtr);
1413 const Stmt *Trigger;
1415 Trigger = AutoDtor->getTriggerStmt();
1417 Trigger = DeleteDtor->getDeleteExpr();
1419 Trigger = Dtor->getBody();
1421 return getCXXDestructorCall(Dtor, Trigger, ThisVal.getAsRegion(),
1428 if (
const auto *CE = dyn_cast<CallExpr>(S)) {
1429 return getSimpleCall(CE, State, LC);
1430 }
else if (
const auto *NE = dyn_cast<CXXNewExpr>(S)) {
1431 return getCXXAllocatorCall(NE, State, LC);
1432 }
else if (
const auto *ME = dyn_cast<ObjCMessageExpr>(S)) {
1433 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
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.
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.
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)
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.
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)
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.
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.
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.
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
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.
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.
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
ArrayRef< SVal > ValueList
const StackFrameContext * getCalleeStackFrame() const
Returns the callee stack frame.
virtual AnalysisManager & getAnalysisManager()=0